/
tabs_test.go
48 lines (38 loc) · 1.06 KB
/
tabs_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
package container
import (
"testing"
"github.com/stretchr/testify/assert"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/internal/cache"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
func TestTabButton_Icon_Change(t *testing.T) {
b := &tabButton{icon: theme.CancelIcon()}
r := cache.Renderer(b)
icon := r.Objects()[3].(*canvas.Image)
oldResource := icon.Resource
b.icon = theme.ConfirmIcon()
b.Refresh()
assert.NotEqual(t, oldResource, icon.Resource)
}
func TestTab_ThemeChange(t *testing.T) {
a := test.NewApp()
defer test.NewApp()
a.Settings().SetTheme(theme.LightTheme())
tabs := NewAppTabs(
NewTabItem("a", widget.NewLabel("a")),
NewTabItem("b", widget.NewLabel("b")))
w := test.NewWindow(tabs)
w.Resize(fyne.NewSize(180, 120))
initial := w.Canvas().Capture()
a.Settings().SetTheme(theme.DarkTheme())
tabs.SelectIndex(1)
second := w.Canvas().Capture()
assert.NotEqual(t, initial, second)
a.Settings().SetTheme(theme.LightTheme())
tabs.SelectIndex(0)
assert.Equal(t, initial, w.Canvas().Capture())
}