-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
base_test.go
47 lines (35 loc) · 1.12 KB
/
base_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
package dialog
import (
"image/color"
"testing"
"github.com/stretchr/testify/assert"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
func TestShowCustom_ApplyTheme(t *testing.T) {
test.NewApp()
defer test.NewApp()
w := test.NewWindow(canvas.NewRectangle(color.Transparent))
w.Resize(fyne.NewSize(200, 300))
label := widget.NewLabel("Content")
label.Alignment = fyne.TextAlignCenter
d := NewCustom("Title", "OK", label, w)
d.Show()
test.AssertImageMatches(t, "dialog-custom-default.png", w.Canvas().Capture())
test.ApplyTheme(t, test.NewTheme())
test.AssertImageMatches(t, "dialog-custom-ugly.png", w.Canvas().Capture())
}
func TestShowCustom_Resize(t *testing.T) {
w := test.NewWindow(canvas.NewRectangle(color.Transparent))
w.Resize(fyne.NewSize(300, 300))
label := widget.NewLabel("Content")
label.Alignment = fyne.TextAlignCenter
d := NewCustom("Title", "OK", label, w)
size := fyne.NewSize(200, 200)
d.Resize(size)
d.Show()
assert.Equal(t, size, d.(*dialog).win.Content.Size().Add(fyne.NewSize(theme.Padding()*2, theme.Padding()*2)))
}