-
Notifications
You must be signed in to change notification settings - Fork 1
/
edge_test.go
141 lines (117 loc) · 4.34 KB
/
edge_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package flex
import "testing"
func TestStart_overrides(t *testing.T) {
root := NewNode()
root.StyleSetFlexDirection(FlexDirectionRow)
root.StyleSetWidth(100)
root.StyleSetHeight(100)
rootChild0 := NewNode()
rootChild0.StyleSetFlexGrow(1)
rootChild0.StyleSetMargin(EdgeStart, 10)
rootChild0.StyleSetMargin(EdgeLeft, 20)
rootChild0.StyleSetMargin(EdgeRight, 20)
root.InsertChild(rootChild0, 0)
CalculateLayout(root, Undefined, Undefined, DirectionLTR)
assertFloatEqual(t, 10, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 20, rootChild0.LayoutGetRight())
CalculateLayout(root, Undefined, Undefined, DirectionRTL)
assertFloatEqual(t, 20, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 10, rootChild0.LayoutGetRight())
}
func TestEnd_overrides(t *testing.T) {
root := NewNode()
root.StyleSetFlexDirection(FlexDirectionRow)
root.StyleSetWidth(100)
root.StyleSetHeight(100)
rootChild0 := NewNode()
rootChild0.StyleSetFlexGrow(1)
rootChild0.StyleSetMargin(EdgeEnd, 10)
rootChild0.StyleSetMargin(EdgeLeft, 20)
rootChild0.StyleSetMargin(EdgeRight, 20)
root.InsertChild(rootChild0, 0)
CalculateLayout(root, Undefined, Undefined, DirectionLTR)
assertFloatEqual(t, 20, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 10, rootChild0.LayoutGetRight())
CalculateLayout(root, Undefined, Undefined, DirectionRTL)
assertFloatEqual(t, 10, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 20, rootChild0.LayoutGetRight())
}
func TestHorizontal_overridden(t *testing.T) {
root := NewNode()
root.StyleSetFlexDirection(FlexDirectionRow)
root.StyleSetWidth(100)
root.StyleSetHeight(100)
rootChild0 := NewNode()
rootChild0.StyleSetFlexGrow(1)
rootChild0.StyleSetMargin(EdgeHorizontal, 10)
rootChild0.StyleSetMargin(EdgeLeft, 20)
root.InsertChild(rootChild0, 0)
CalculateLayout(root, Undefined, Undefined, DirectionLTR)
assertFloatEqual(t, 20, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 10, rootChild0.LayoutGetRight())
}
func TestVertical_overridden(t *testing.T) {
root := NewNode()
root.StyleSetFlexDirection(FlexDirectionColumn)
root.StyleSetWidth(100)
root.StyleSetHeight(100)
rootChild0 := NewNode()
rootChild0.StyleSetFlexGrow(1)
rootChild0.StyleSetMargin(EdgeVertical, 10)
rootChild0.StyleSetMargin(EdgeTop, 20)
root.InsertChild(rootChild0, 0)
CalculateLayout(root, Undefined, Undefined, DirectionLTR)
assertFloatEqual(t, 20, rootChild0.LayoutGetTop())
assertFloatEqual(t, 10, rootChild0.LayoutGetBottom())
}
func TestHorizontal_overrides_all(t *testing.T) {
root := NewNode()
root.StyleSetFlexDirection(FlexDirectionColumn)
root.StyleSetWidth(100)
root.StyleSetHeight(100)
rootChild0 := NewNode()
rootChild0.StyleSetFlexGrow(1)
rootChild0.StyleSetMargin(EdgeHorizontal, 10)
rootChild0.StyleSetMargin(EdgeAll, 20)
root.InsertChild(rootChild0, 0)
CalculateLayout(root, Undefined, Undefined, DirectionLTR)
assertFloatEqual(t, 10, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 20, rootChild0.LayoutGetTop())
assertFloatEqual(t, 10, rootChild0.LayoutGetRight())
assertFloatEqual(t, 20, rootChild0.LayoutGetBottom())
}
func TestVertical_overrides_all(t *testing.T) {
root := NewNode()
root.StyleSetFlexDirection(FlexDirectionColumn)
root.StyleSetWidth(100)
root.StyleSetHeight(100)
rootChild0 := NewNode()
rootChild0.StyleSetFlexGrow(1)
rootChild0.StyleSetMargin(EdgeVertical, 10)
rootChild0.StyleSetMargin(EdgeAll, 20)
root.InsertChild(rootChild0, 0)
CalculateLayout(root, Undefined, Undefined, DirectionLTR)
assertFloatEqual(t, 20, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 10, rootChild0.LayoutGetTop())
assertFloatEqual(t, 20, rootChild0.LayoutGetRight())
assertFloatEqual(t, 10, rootChild0.LayoutGetBottom())
}
func TestAll_overridden(t *testing.T) {
root := NewNode()
root.StyleSetFlexDirection(FlexDirectionColumn)
root.StyleSetWidth(100)
root.StyleSetHeight(100)
rootChild0 := NewNode()
rootChild0.StyleSetFlexGrow(1)
rootChild0.StyleSetMargin(EdgeLeft, 10)
rootChild0.StyleSetMargin(EdgeTop, 10)
rootChild0.StyleSetMargin(EdgeRight, 10)
rootChild0.StyleSetMargin(EdgeBottom, 10)
rootChild0.StyleSetMargin(EdgeAll, 20)
root.InsertChild(rootChild0, 0)
CalculateLayout(root, Undefined, Undefined, DirectionLTR)
assertFloatEqual(t, 10, rootChild0.LayoutGetLeft())
assertFloatEqual(t, 10, rootChild0.LayoutGetTop())
assertFloatEqual(t, 10, rootChild0.LayoutGetRight())
assertFloatEqual(t, 10, rootChild0.LayoutGetBottom())
}