-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader_test.go
More file actions
67 lines (50 loc) · 1.33 KB
/
Copy pathheader_test.go
File metadata and controls
67 lines (50 loc) · 1.33 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package microui
import (
"testing"
"github.com/user/microui-go/types"
)
func TestHeader_Basic(t *testing.T) {
ui := New(Config{})
ui.BeginFrame()
ui.BeginWindow("Test", types.Rect{X: 0, Y: 0, W: 400, H: 300})
ui.LayoutRow(1, []int{-1}, 0)
// Header should return true when expanded (default)
if ui.Header("Section 1") {
ui.Label("Content 1")
}
// Another header
if ui.Header("Section 2") {
ui.Label("Content 2")
}
ui.EndWindow()
ui.EndFrame()
}
func TestHeader_Toggle(t *testing.T) {
ui := New(Config{})
// First frame - render header
ui.BeginFrame()
ui.BeginWindow("Test", types.Rect{X: 0, Y: 0, W: 400, H: 300})
ui.LayoutRow(1, []int{-1}, 30)
expanded1 := ui.Header("Section")
ui.EndWindow()
ui.EndFrame()
// Default should be expanded
if !expanded1 {
t.Error("Header should be expanded by default")
}
// Click on header to toggle
// Header is at Y ~= 29 (after title 24 + padding 5), height ~= 20 (size.Y 10 + padding*2)
// So click at Y=35 to be inside the control
ui.MouseMove(50, 35)
ui.MouseDown(50, 35, MouseLeft)
ui.BeginFrame()
ui.BeginWindow("Test", types.Rect{X: 0, Y: 0, W: 400, H: 300})
ui.LayoutRow(1, []int{-1}, 30)
expanded2 := ui.Header("Section")
ui.EndWindow()
ui.EndFrame()
// Should now be collapsed after click
if expanded2 {
t.Error("Header should be collapsed after click")
}
}