summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_box_flow.c
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-03-08 08:22:08 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-03-08 08:22:08 -0500
commitfbc7c31b33270a4d617bead2cf3baec61cc64b62 (patch)
tree24b1afe569ca33e78d6611c2da2a6624b6c21cff /src/tests/elementary/efl_ui_test_box_flow.c
parent8118330d2a34a26078d3642ebbebf188146a5415 (diff)
ui.box_flow: refactor layout_update
Summary: This patch remove evas_box function from Efl.Ui.Box_Flow and add unit test. Depends on D8214 Test Plan: 1. make check 2. `elementary_test -to 'efl.ui.box'` with 'flow' checkbox. Reviewers: zmike, Jaehyun_Cho Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8219
Diffstat (limited to 'src/tests/elementary/efl_ui_test_box_flow.c')
-rw-r--r--src/tests/elementary/efl_ui_test_box_flow.c416
1 files changed, 416 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_box_flow.c b/src/tests/elementary/efl_ui_test_box_flow.c
new file mode 100644
index 0000000..52af8f0
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_box_flow.c
@@ -0,0 +1,416 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_suite.h"
7
8#define COORD_EQ(a, b) (!!(abs(a - b) < 2))
9#define GEOMETRY_EQ(a, b) (COORD_EQ(a.x, b.x) && COORD_EQ(a.y, b.y) && \
10 COORD_EQ(a.w, b.w) && COORD_EQ(a.h, b.h))
11
12typedef struct {
13 Eina_Size2D max;
14 Eina_Size2D min;
15 double weightx;
16 double weighty;
17 double alignx;
18 double aligny;
19 int marginl;
20 int marginr;
21 int margint;
22 int marginb;
23 Efl_Gfx_Hint_Aspect mode;
24 Eina_Size2D aspect;
25 Eina_Bool fillx;
26 Eina_Bool filly;
27 Eina_Size2D layout_size;
28 Eina_Size2D layout_expected;
29 Eina_Rect expected;
30 char testname[1024];
31} Hint;
32
33static Hint hints[] = {
34 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
35 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
36 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
37 EINA_RECT(0, 0, 200, 200), "[0]" },
38 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.5, 0, 0, 0, 0,
39 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
40 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
41 EINA_RECT(0, 0, 200, 200), "[1]" },
42 { EINA_SIZE2D(50, 150), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
43 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
44 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
45 EINA_RECT((200 - 70) * 0.3, (200 - 150) * 0.7, 70, 150), "[2]" },
46 { EINA_SIZE2D(150, -1), EINA_SIZE2D(70, 70), 0, 0, 0.3, 0.7, 0, 0, 0, 0,
47 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
48 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
49 EINA_RECT((200 - 70) * 0.8, (200 - 70) * 0.2, 70, 70), "[3]" },
50 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
51 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
52 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
53 EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.2, 70, 70), "[4]" },
54 { EINA_SIZE2D(150, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
55 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
56 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
57 EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.2, 70, 70), "[5]" },
58 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
59 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
60 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
61 EINA_RECT((200 - 70) * 0.8, 0, 70, 70 * 3), "[6]" },
62 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
63 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
64 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
65 EINA_RECT((300 - 70) * 0.8, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[7]" },
66 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
67 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
68 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
69 EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[8]" },
70 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
71 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
72 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
73 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.2, 70, 70 * 3), "[9]" },
74 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
75 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
76 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
77 EINA_RECT((200 - 70) * 0.8, 0, 70, 70 * 3), "[10]" },
78 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
79 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
80 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
81 EINA_RECT((300 - 70) * 0.8, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[11]" },
82 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
83 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
84 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
85 EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[12]" },
86 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
87 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
88 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
89 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.2, 70, 70 * 3), "[13]" },
90};
91
92static Hint hints2[][2] = {
93 {
94 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
95 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
96 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
97 EINA_RECT((150 - 70) * 0.3, (150 - 70) * 0.7, 70, 70), "[1/1 weight btn]" },
98 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
99 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
100 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
101 EINA_RECT((150 - 70) * 0.8, (150 - 70) * 0.2 + 150, 70, 70), "[1/1 weight btn2]" }
102 },
103 {
104 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
105 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
106 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
107 EINA_RECT((150 - 70) * 0.3, 0, 70, 70), "[0/1 weight btn]" },
108 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
109 EFL_GFX_HINT_ASPECT_VERTICAL, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
110 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
111 EINA_RECT((150 - ((300 - 70) / 3)) * 0.8, 70, (300 - 70) / 3, (300 - 70)), "[0/1 weight btn2]" }
112 },
113 {
114 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
115 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
116 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
117 EINA_RECT((150 - 70) * 0.3, (300 - 280) * 0.2, 70, 70), "[0/0 weight btn]" },
118 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.8, 0.2, 0, 0, 0, 0,
119 EFL_GFX_HINT_ASPECT_HORIZONTAL, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
120 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
121 EINA_RECT((150 - 70) * 0.8, (300 - 280) * 0.2 + 70, 70, 70 * 3), "[0/0 weight btn2]" }
122 },
123};
124
125static Hint hints3[][3] = {
126 {
127 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
128 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
129 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
130 EINA_RECT(0, 0, 150, 100), "[1/1/1 weight_l btn]" },
131 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
132 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
133 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
134 EINA_RECT(0, 100, 150, 100), "[1/1/1 weight_l btn2]" },
135 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
136 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
137 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
138 EINA_RECT(0, 100 + 100, 150, 100), "[1/1/1 weight_l btn3]" }
139 },
140 {
141 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
142 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
143 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
144 EINA_RECT(0, 0, 150, 85), "[1/1/1 weight_m btn]" },
145 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
146 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
147 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
148 EINA_RECT(0, 85, 150, 100), "[1/1/1 weight_m btn2]" },
149 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
150 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
151 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
152 EINA_RECT(0, 100 + 85, 150, 85), "[1/1/1 weight_m btn3]" }
153 },
154 {
155 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
156 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
157 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
158 EINA_RECT(0, 0, 75, 100), "[1/1/1 weight_s btn]" },
159 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
160 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
161 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
162 EINA_RECT(0, 100, 75, 100), "[1/1/1 weight_s btn2]" },
163 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
164 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
165 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
166 EINA_RECT(75, 0, 75, 200), "[1/1/1 weight_s btn3]" }
167 },
168 {
169 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
170 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
171 EINA_SIZE2D(300, 900), EINA_SIZE2D(300, 900),
172 EINA_RECT(100, 0, 100, 300), "[aspect resize btn]" },
173 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
174 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
175 EINA_SIZE2D(300, 900), EINA_SIZE2D(300, 900),
176 EINA_RECT(100, 300, 100, 300), "[aspect resize btn2]" },
177 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
178 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_TRUE,
179 EINA_SIZE2D(300, 900), EINA_SIZE2D(300, 900),
180 EINA_RECT(100, 300 + 300, 100, 300), "[aspect resize btn3]" }
181 },
182};
183
184static Eo *win, *layout;
185
186static void
187btn_hint_set(Eo *btn, Hint *hint)
188{
189 efl_gfx_entity_size_set(layout, hint->layout_size);
190 efl_gfx_hint_size_min_set(layout, hint->layout_size);
191 efl_gfx_hint_size_max_set(btn, hint->max);
192 efl_gfx_hint_size_min_set(btn, hint->min);
193 efl_gfx_hint_weight_set(btn, hint->weightx, hint->weighty);
194 efl_gfx_hint_align_set(btn, hint->alignx, hint->aligny);
195 efl_gfx_hint_fill_set(btn, hint->fillx, hint->filly);
196 efl_gfx_hint_aspect_set(btn, hint->mode, hint->aspect);
197 efl_canvas_group_calculate(layout);
198}
199
200static void
201btn_geom_assert(Hint *hint, Eina_Rect btn_geom)
202{
203 Eina_Size2D layout_size, layout_min;
204
205 layout_size = efl_gfx_entity_size_get(layout);
206 layout_min = efl_gfx_hint_size_combined_min_get(layout);
207 layout_size.w = layout_size.w > layout_min.w ? layout_size.w : layout_min.w;
208 layout_size.h = layout_size.h > layout_min.h ? layout_size.h : layout_min.h;
209
210 ck_assert_msg(GEOMETRY_EQ(btn_geom, hint->expected),
211 "Case %s failed... button geometry: (%d, %d, %d, %d) expected geometry: (%d, %d, %d, %d)",
212 hint->testname, btn_geom.x, btn_geom.y, btn_geom.w, btn_geom.h,
213 hint->expected.x, hint->expected.y, hint->expected.w, hint->expected.h);
214 ck_assert_msg(COORD_EQ(layout_size.w, hint->layout_expected.w) &&
215 COORD_EQ(layout_size.h, hint->layout_expected.h),
216 "Case %s failed... layout size: (%d, %d) expected size: (%d, %d)",
217 hint->testname, layout_size.w, layout_size.h,
218 hint->layout_expected.w, hint->layout_expected.h);
219}
220
221static void
222layout_setup()
223{
224 win = win_add();
225
226 layout = efl_add(EFL_UI_BOX_FLOW_CLASS, win,
227 efl_pack_align_set(efl_added, 0.8, 0.2),
228 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL));
229}
230
231static void
232layout_teardown()
233{
234 if (win)
235 {
236 efl_del(win);
237 win = NULL;
238 }
239}
240
241EFL_START_TEST (efl_ui_box_flow_class_check)
242{
243 const char *class;
244
245 class = efl_class_name_get(layout);
246
247 ck_assert(class != NULL);
248 ck_assert(!strcmp(class, "Efl.Ui.Box_Flow"));
249}
250EFL_END_TEST
251
252EFL_START_TEST (efl_ui_box_flow_layout_update)
253{
254 int i, max_index = (sizeof(hints) / sizeof(Hint));
255
256 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
257 efl_pack_end(layout, efl_added));
258
259 for (i = 0; i < max_index; i++)
260 {
261 btn_hint_set(btn, &hints[i]);
262 btn_geom_assert(&hints[i], efl_gfx_entity_geometry_get(btn));
263 }
264}
265EFL_END_TEST
266
267EFL_START_TEST (efl_ui_box_flow_layout_update_pack)
268{
269 int i, max_index2, max_index3;
270 Eo *btn, *btn2, *btn3;
271
272 max_index2 = ((sizeof(hints2) / sizeof(Hint)) / 2);
273 max_index3 = ((sizeof(hints3) / sizeof(Hint)) / 3);
274
275 btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
276 efl_pack_end(layout, efl_added));
277 btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
278 efl_pack_end(layout, efl_added));
279
280 for (i = 0; i < max_index2; i++)
281 {
282 btn_hint_set(btn, &hints2[i][0]);
283 btn_hint_set(btn2, &hints2[i][1]);
284 btn_geom_assert(&hints2[i][0], efl_gfx_entity_geometry_get(btn));
285 btn_geom_assert(&hints2[i][1], efl_gfx_entity_geometry_get(btn2));
286 }
287
288 btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
289 efl_pack_end(layout, efl_added));
290
291 for (i = 0; i < max_index3; i++)
292 {
293 btn_hint_set(btn, &hints3[i][0]);
294 btn_hint_set(btn2, &hints3[i][1]);
295 btn_hint_set(btn3, &hints3[i][2]);
296 btn_geom_assert(&hints3[i][0], efl_gfx_entity_geometry_get(btn));
297 btn_geom_assert(&hints3[i][1], efl_gfx_entity_geometry_get(btn2));
298 btn_geom_assert(&hints3[i][2], efl_gfx_entity_geometry_get(btn3));
299 }
300
301 // aspect resize test
302 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(150, 450);
303 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(150, 450);
304 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(150, 450);
305 hints3[3][0].expected = EINA_RECT(50, 0, 50, 150);
306 hints3[3][1].expected = EINA_RECT(50, 150, 50, 150);
307 hints3[3][2].expected = EINA_RECT(50, 300, 50, 150);
308
309 btn_hint_set(btn, &hints3[3][0]);
310 btn_hint_set(btn2, &hints3[3][1]);
311 btn_hint_set(btn3, &hints3[3][2]);
312 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
313 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
314 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
315
316 efl_ui_direction_set(layout, EFL_UI_DIR_HORIZONTAL);
317 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(300, 900);
318 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(300, 900);
319 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(300, 900);
320 hints3[3][0].expected = EINA_RECT(0, 300, 100, 300);
321 hints3[3][1].expected = EINA_RECT(100, 300, 100, 300);
322 hints3[3][2].expected = EINA_RECT(200, 300, 100, 300);
323
324 btn_hint_set(btn, &hints3[3][0]);
325 btn_hint_set(btn2, &hints3[3][1]);
326 btn_hint_set(btn3, &hints3[3][2]);
327 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
328 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
329 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
330
331 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(150, 450);
332 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(150, 450);
333 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(150, 450);
334 hints3[3][0].expected = EINA_RECT(0, 150, 50, 150);
335 hints3[3][1].expected = EINA_RECT(50, 150, 50, 150);
336 hints3[3][2].expected = EINA_RECT(100, 150, 50, 150);
337
338 btn_hint_set(btn, &hints3[3][0]);
339 btn_hint_set(btn2, &hints3[3][1]);
340 btn_hint_set(btn3, &hints3[3][2]);
341 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
342 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
343 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
344}
345EFL_END_TEST
346
347EFL_START_TEST (efl_ui_box_flow_size)
348{
349#define USERMIN_CHECK(a, b) \
350 efl_canvas_group_calculate(layout); \
351 user_min = efl_gfx_hint_size_min_get(layout); \
352 ck_assert_msg(COORD_EQ(user_min.w, (a)) && COORD_EQ(user_min.h, (b)), \
353 "Case box_size failed... user_min: (%d, %d) expected user_min: (%d, %d)", \
354 user_min.w, user_min.h, (a), (b));
355
356#define MIN_CHECK(a, b) \
357 efl_canvas_group_calculate(layout); \
358 min = efl_gfx_hint_size_combined_min_get(layout); \
359 ck_assert_msg(COORD_EQ(min.w, (a)) && COORD_EQ(min.h, (b)), \
360 "Case box_size failed... min: (%d, %d) expected min: (%d, %d)", \
361 min.w, min.h, (a), (b));
362
363 Eo *btn, *btn2, *btn3;
364 Eina_Size2D min, user_min;
365
366 btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
367 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
368 efl_pack_end(layout, efl_added));
369
370 USERMIN_CHECK(0, 0);
371 MIN_CHECK(100, 100);
372
373 btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
374 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
375 efl_pack_end(layout, efl_added));
376 btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
377 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
378 efl_pack_end(layout, efl_added));
379 USERMIN_CHECK(0, 0);
380 MIN_CHECK(300, 100);
381
382 efl_pack_unpack(layout, btn2);
383 USERMIN_CHECK(0, 0);
384 MIN_CHECK(200, 100);
385
386 efl_pack_unpack(layout, btn3);
387 USERMIN_CHECK(0, 0);
388 MIN_CHECK(100, 100);
389
390 efl_pack_unpack(layout, btn);
391 USERMIN_CHECK(0, 0);
392 MIN_CHECK(0, 0);
393
394 efl_pack_end(layout, btn);
395 efl_gfx_hint_size_min_set(layout, EINA_SIZE2D(200, 200));
396 USERMIN_CHECK(200, 200);
397 MIN_CHECK(200, 200);
398
399 efl_pack_end(layout, btn2);
400 efl_pack_end(layout, btn3);
401 USERMIN_CHECK(200, 200);
402 MIN_CHECK(300, 200);
403
404#undef USERMIN_ASSERT
405#undef MIN_ASSERT
406}
407EFL_END_TEST
408
409void efl_ui_test_box_flow(TCase *tc)
410{
411 tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
412 tcase_add_test(tc, efl_ui_box_flow_class_check);
413 tcase_add_test(tc, efl_ui_box_flow_layout_update);
414 tcase_add_test(tc, efl_ui_box_flow_layout_update_pack);
415 tcase_add_test(tc, efl_ui_box_flow_size);
416}