forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaddedlayout_test.go
51 lines (38 loc) · 1.32 KB
/
paddedlayout_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package layout_test
import (
"image/color"
"testing"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"github.com/stretchr/testify/assert"
)
func TestPaddedLayout(t *testing.T) {
size := fyne.NewSize(100, 100)
obj := canvas.NewRectangle(color.Black)
container := &fyne.Container{
Objects: []fyne.CanvasObject{obj},
}
container.Resize(size)
layout.NewPaddedLayout().Layout(container.Objects, size)
assert.Equal(t, obj.Size().Width, size.Width-2*theme.Padding())
assert.Equal(t, obj.Size().Height, size.Height-2*theme.Padding())
}
func TestPaddedLayout_MinSize(t *testing.T) {
text := canvas.NewText("FooBar", color.Black)
minSize := text.MinSize()
container := fyne.NewContainer(text)
layoutMin := layout.NewPaddedLayout().MinSize(container.Objects)
assert.Equal(t, minSize.Width+2*theme.Padding(), layoutMin.Width)
assert.Equal(t, minSize.Height+2*theme.Padding(), layoutMin.Height)
}
func TestContainer_PaddedLayout_MinSize(t *testing.T) {
text := canvas.NewText("FooBar", color.Black)
minSize := text.MinSize()
container := fyne.NewContainer(text)
container.Layout = layout.NewPaddedLayout()
layoutMin := container.MinSize()
assert.Equal(t, minSize.Width+2*theme.Padding(), layoutMin.Width)
assert.Equal(t, minSize.Height+2*theme.Padding(), layoutMin.Height)
}