summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_relative_container.c
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-11-12 13:46:20 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2019-11-12 14:33:13 +0100
commit246485ca928d26144ca3188d895bb7b44a73d3ad (patch)
treeb9c981b1d3e5098c60bebfde02379f9ee1c13659 /src/tests/elementary/efl_ui_test_relative_container.c
parenta5daa2b72fa725c6a8129f990351f18b694ef357 (diff)
efl_ui_relative_container: rename relative_layout
Summary: Also, Rename parameter name `target` to `base`. Rename parameter name `relative` to `relative_position`. ref T8380 Depends On D10639 Test Plan: ninja test Reviewers: woohyun, segfaultxavi Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8380 Differential Revision: https://phab.enlightenment.org/D10640
Diffstat (limited to 'src/tests/elementary/efl_ui_test_relative_container.c')
-rw-r--r--src/tests/elementary/efl_ui_test_relative_container.c374
1 files changed, 374 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_relative_container.c b/src/tests/elementary/efl_ui_test_relative_container.c
new file mode 100644
index 0000000..35cf5a2
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_relative_container.c
@@ -0,0 +1,374 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Efl_Ui.h>
6#include <Elementary.h>
7#include "elm_suite.h"
8
9#define COORD_EQ(a, b) (!!(abs(a - b) < 2))
10#define GEOMETRY_EQ(a, b) (COORD_EQ(a.x, b.x) && COORD_EQ(a.y, b.y) && \
11 COORD_EQ(a.w, b.w) && COORD_EQ(a.h, b.h))
12
13typedef struct {
14 Eina_Size2D max;
15 Eina_Size2D min;
16 double weightx;
17 double weighty;
18 double alignx;
19 double aligny;
20 int marginl;
21 int marginr;
22 int margint;
23 int marginb;
24 Efl_Gfx_Hint_Aspect mode;
25 Eina_Size2D aspect;
26 Eina_Bool fillx;
27 Eina_Bool filly;
28 Eina_Size2D layout_size;
29 Eina_Size2D layout_expected;
30 Eina_Rect expected;
31 char testname[1024];
32} Hint;
33
34static Hint hints[] = {
35 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
36 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
37 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
38 EINA_RECT(0, 0, 200, 200), "[0]" },
39 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.5, 0, 0, 0, 0,
40 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
41 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
42 EINA_RECT(0, 0, 200, 200), "[1]" },
43 { EINA_SIZE2D(50, 150), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
44 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
45 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
46 EINA_RECT((200 - 70) * 0.3, (200 - 150) * 0.7, 70, 150), "[2]" },
47 { EINA_SIZE2D(150, -1), EINA_SIZE2D(70, 70), 0, 0, 0.3, 0.7, 0, 0, 0, 0,
48 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
49 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
50 EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.7, 70, 70), "[3]" },
51 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
52 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
53 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
54 EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.7, 70, 70), "[4]" },
55 { EINA_SIZE2D(150, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
56 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
57 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
58 EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.7, 70, 70), "[5]" },
59 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
60 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
61 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
62 EINA_RECT((200 - 70) * 0.3, -7, 70, 70 * 3), "[6]" },
63 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
64 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
65 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
66 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[7]" },
67 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
68 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
69 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
70 EINA_RECT((200 - 70) * 0.3, -7, 70, 70 * 3), "[8]" },
71 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
72 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
73 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
74 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[9]" },
75 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
76 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
77 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
78 EINA_RECT((200 - 70) * 0.3, -7, 70, 70 * 3), "[10]" },
79 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
80 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
81 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
82 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[11]" },
83 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
84 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
85 EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
86 EINA_RECT((200 - 70) * 0.3, -7, 70, 70 * 3), "[12]" },
87 { EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
88 EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
89 EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
90 EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[13]" },
91};
92
93static Hint hints2[][2] = {
94 {
95 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
96 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
97 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
98 EINA_RECT((150 - 70) * 0.3, (150 - 70) * 0.7, 70, 70), "[1/1 weight btn]" },
99 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
100 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
101 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
102 EINA_RECT((150 - 70) * 0.8, (150 - 70) * 0.2 + 150, 70, 70), "[1/1 weight btn2]" }
103 },
104 {
105 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
106 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
107 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
108 EINA_RECT((150 - 70) * 0.3, 0, 70, 70), "[0/1 weight btn]" },
109 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
110 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
111 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
112 EINA_RECT((150 - 70) * 0.8, (300 - 140) * 0.2 + 70, 70, 70), "[0/1 weight btn2]" }
113 },
114 {
115 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
116 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
117 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
118 EINA_RECT((150 - 70) * 0.3, (300 - 140) * 0.7, 70, 70), "[0/0 weight btn]" },
119 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.8, 0.2, 0, 0, 0, 0,
120 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
121 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
122 EINA_RECT((150 - 70) * 0.8, (300 - 140) * 0.7 + 70, 70, 70), "[0/0 weight btn2]" }
123 },
124};
125
126static Hint hints3[][3] = {
127 {
128 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
129 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
130 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
131 EINA_RECT(0, 0, 150, 100), "[1/1/1 weight_l btn]" },
132 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
133 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
134 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
135 EINA_RECT(0, 100, 150, 100), "[1/1/1 weight_l btn2]" },
136 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
137 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
138 EINA_SIZE2D(150, 300), EINA_SIZE2D(150, 300),
139 EINA_RECT(0, 100 + 100, 150, 100), "[1/1/1 weight_l btn2]" }
140 },
141 {
142 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
143 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
144 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
145 EINA_RECT(0, 0, 150, 85), "[1/1/1 weight_m btn]" },
146 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
147 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
148 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
149 EINA_RECT(0, 85, 150, 100), "[1/1/1 weight_m btn2]" },
150 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
151 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
152 EINA_SIZE2D(150, 270), EINA_SIZE2D(150, 270),
153 EINA_RECT(0, 100 + 85, 150, 85), "[1/1/1 weight_m btn2]" }
154 },
155 {
156 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
157 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
158 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
159 EINA_RECT(0, -28, 150, 70), "[1/1/1 weight_s btn]" },
160 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 100), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
161 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
162 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
163 EINA_RECT(0, 42, 150, 100), "[1/1/1 weight_s btn2]" },
164 { EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.8, 0.2, 0, 0, 0, 0,
165 EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
166 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 200),
167 EINA_RECT(0, 142, 150, 70), "[1/1/1 weight_s btn2]" }
168 },
169};
170
171static Eo *win, *layout;
172
173static void
174btn_hint_set(Eo *btn, Hint *hint)
175{
176 efl_gfx_entity_size_set(layout, hint->layout_size);
177 efl_gfx_hint_size_max_set(btn, hint->max);
178 efl_gfx_hint_size_min_set(btn, hint->min);
179 efl_gfx_hint_margin_set(btn, hint->marginl, hint->marginr, hint->margint,
180 hint->marginb);
181 efl_gfx_hint_weight_set(btn, hint->weightx, hint->weighty);
182 efl_gfx_hint_align_set(btn, hint->alignx, hint->aligny);
183 efl_gfx_hint_fill_set(btn, hint->fillx, hint->filly);
184 efl_gfx_hint_aspect_set(btn, hint->mode, hint->aspect);
185 efl_canvas_group_calculate(layout);
186}
187
188static void
189btn_geom_assert(Hint *hint, Eina_Rect btn_geom)
190{
191 Eina_Size2D layout_size, layout_min;
192
193 layout_size = efl_gfx_entity_size_get(layout);
194 layout_min = efl_gfx_hint_size_min_get(layout);
195 layout_size.w = layout_size.w > layout_min.w ? layout_size.w : layout_min.w;
196 layout_size.h = layout_size.h > layout_min.h ? layout_size.h : layout_min.h;
197
198 ck_assert_msg(GEOMETRY_EQ(btn_geom, hint->expected),
199 "Case %s failed... button geometry: (%d, %d, %d, %d) expected geometry: (%d, %d, %d, %d)",
200 hint->testname, btn_geom.x, btn_geom.y, btn_geom.w, btn_geom.h,
201 hint->expected.x, hint->expected.y, hint->expected.w, hint->expected.h);
202 ck_assert_msg(COORD_EQ(layout_size.w, hint->layout_expected.w) &&
203 COORD_EQ(layout_size.h, hint->layout_expected.h),
204 "Case %s failed... layout size: (%d, %d) expected size: (%d, %d)",
205 hint->testname, layout_size.w, layout_size.h,
206 hint->layout_expected.w, hint->layout_expected.h);
207}
208
209static void
210layout_setup()
211{
212 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
213 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC));
214
215 layout = efl_add(EFL_UI_RELATIVE_CONTAINER_CLASS, win,
216 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(200, 200)));
217
218 efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 200));
219}
220
221EFL_START_TEST (efl_ui_relative_container_class_check)
222{
223 const char *class;
224
225 class = efl_class_name_get(layout);
226
227 ck_assert(class != NULL);
228 ck_assert(!strcmp(class, "Efl.Ui.Relative_Container"));
229}
230EFL_END_TEST
231
232EFL_START_TEST (efl_ui_relative_container_layout_update)
233{
234 int i, max_index = (sizeof(hints) / sizeof(Hint));
235
236 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, layout, efl_pack(layout, efl_added));
237
238 for (i = 0; i < max_index; i++)
239 {
240 btn_hint_set(btn, &hints[i]);
241 btn_geom_assert(&hints[i], efl_gfx_entity_geometry_get(btn));
242 }
243}
244EFL_END_TEST
245
246EFL_START_TEST (efl_ui_relative_container_layout_update_chain)
247{
248 int i, max_index2, max_index3;
249 Eo *btn, *btn2, *btn3;
250
251 btn = efl_add(EFL_UI_BUTTON_CLASS, layout);
252 btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout);
253
254 max_index2 = ((sizeof(hints2) / sizeof(Hint)) / 2);
255 max_index3 = ((sizeof(hints3) / sizeof(Hint)) / 3);
256
257 efl_ui_relative_container_relation_bottom_set(layout, btn, btn2, 0.0);
258 efl_ui_relative_container_relation_top_set(layout, btn2, btn, 1.0);
259
260 for (i = 0; i < max_index2; i++)
261 {
262 btn_hint_set(btn, &hints2[i][0]);
263 btn_hint_set(btn2, &hints2[i][1]);
264 btn_geom_assert(&hints2[i][0], efl_gfx_entity_geometry_get(btn));
265 btn_geom_assert(&hints2[i][1], efl_gfx_entity_geometry_get(btn2));
266 }
267
268 btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout);
269 efl_ui_relative_container_relation_bottom_set(layout, btn2, btn3, 0.0);
270 efl_ui_relative_container_relation_top_set(layout, btn3, btn2, 1.0);
271
272 for (i = 0; i < max_index3; i++)
273 {
274 btn_hint_set(btn, &hints3[i][0]);
275 btn_hint_set(btn2, &hints3[i][1]);
276 btn_hint_set(btn3, &hints3[i][2]);
277 btn_geom_assert(&hints3[i][0], efl_gfx_entity_geometry_get(btn));
278 btn_geom_assert(&hints3[i][1], efl_gfx_entity_geometry_get(btn2));
279 btn_geom_assert(&hints3[i][2], efl_gfx_entity_geometry_get(btn3));
280 }
281}
282EFL_END_TEST
283
284EFL_START_TEST (efl_ui_relative_container_relation_set)
285{
286 Eo *btn;
287 Eo *target = NULL;
288 double relative;
289
290 btn = efl_add(EFL_UI_BUTTON_CLASS, layout);
291
292 // negative test
293 efl_ui_relative_container_relation_top_get(layout, NULL, &target, &relative);
294 ck_assert_ptr_eq(target, NULL);
295 ck_assert(EINA_DBL_EQ(relative, 0.0));
296
297 efl_ui_relative_container_relation_top_get(layout, btn, &target, &relative);
298 ck_assert_ptr_eq(target, NULL);
299 ck_assert(EINA_DBL_EQ(relative, 0.0));
300
301 efl_ui_relative_container_relation_top_set(layout, NULL, NULL, 0.0);
302 ck_assert_ptr_eq(target, NULL);
303 ck_assert(EINA_DBL_EQ(relative, 0.0));
304
305 // default value test
306 efl_ui_relative_container_relation_top_set(layout, btn, layout, 0.0);
307
308 efl_ui_relative_container_relation_top_get(layout, btn, &target, &relative);
309 ck_assert_ptr_eq(target, layout);
310 ck_assert(EINA_DBL_EQ(relative, 0.0));
311 efl_ui_relative_container_relation_bottom_get(layout, btn, &target, &relative);
312 ck_assert_ptr_eq(target, layout);
313 ck_assert(EINA_DBL_EQ(relative, 1.0));
314 efl_ui_relative_container_relation_left_get(layout, btn, &target, &relative);
315 ck_assert_ptr_eq(target, layout);
316 ck_assert(EINA_DBL_EQ(relative, 0.0));
317 efl_ui_relative_container_relation_right_get(layout, btn, &target, &relative);
318 ck_assert_ptr_eq(target, layout);
319 ck_assert(EINA_DBL_EQ(relative, 1.0));
320
321 // positive test
322 efl_ui_relative_container_relation_top_set(layout, btn, layout, 0.123);
323 efl_ui_relative_container_relation_top_get(layout, btn, &target, &relative);
324 ck_assert_ptr_eq(target, layout);
325 ck_assert(EINA_DBL_EQ(relative, 0.123));
326
327 efl_ui_relative_container_relation_top_set(layout, btn, NULL, 0.456);
328 efl_ui_relative_container_relation_top_get(layout, btn, &target, &relative);
329 ck_assert_ptr_eq(target, layout);
330 ck_assert(EINA_DBL_EQ(relative, 0.456));
331}
332EFL_END_TEST
333
334EFL_START_TEST (efl_ui_relative_container_pack)
335{
336 Eo *btn[3], *child;
337 Eina_Iterator *it;
338 int i;
339
340 for (i = 0; i < 3; i++)
341 btn[i] = efl_add(EFL_UI_BUTTON_CLASS, layout, efl_pack(layout, efl_added));
342 ck_assert_int_eq(efl_content_count(layout), 3);
343
344 it = efl_content_iterate(layout);
345 EINA_ITERATOR_FOREACH(it, child)
346 ck_assert_ptr_eq(layout, efl_canvas_object_render_parent_get(child));
347 eina_iterator_free(it);
348
349 efl_pack_unpack(layout, NULL);
350 ck_assert_int_eq(efl_content_count(layout), 3);
351 efl_pack_unpack(layout, btn[0]);
352 ck_assert_int_eq(efl_content_count(layout), 2);
353 efl_pack_unpack_all(layout);
354 ck_assert_int_eq(efl_content_count(layout), 0);
355
356 for (i = 0; i < 3; i++)
357 efl_pack(layout, btn[i]);
358 ck_assert_int_eq(efl_content_count(layout), 3);
359 efl_pack_clear(layout);
360 ck_assert_int_eq(efl_content_count(layout), 0);
361 for (i = 0; i < 3; i++)
362 ck_assert(efl_invalidated_get(btn[i]));
363}
364EFL_END_TEST
365
366void efl_ui_test_relative_container(TCase *tc)
367{
368 tcase_add_checked_fixture(tc, layout_setup, NULL);
369 tcase_add_test(tc, efl_ui_relative_container_class_check);
370 tcase_add_test(tc, efl_ui_relative_container_layout_update);
371 tcase_add_test(tc, efl_ui_relative_container_layout_update_chain);
372 tcase_add_test(tc, efl_ui_relative_container_relation_set);
373 tcase_add_test(tc, efl_ui_relative_container_pack);
374}