summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-02-13 08:39:07 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-02-13 09:23:01 -0500
commitb1f280f0c2c307c32a5edde5b5f2f304d463dac8 (patch)
treeec3ef75bb1ae38bd3c423fcf781df7479bbf45be
parent846492ebd7b86d2f4f5d2ab7b002a1ac19ce5b82 (diff)
test/ui_box: add unittest for Efl.Ui.Box
Summary: Testcase {F3613173} {F3613174} ref T5487 Depends on D7750 Test Plan: make check Reviewers: jpeg, barbieri, Jaehyun_Cho, zmike Reviewed By: zmike Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T5487 Differential Revision: https://phab.enlightenment.org/D7463
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/tests/elementary/efl_ui_suite.c1
-rw-r--r--src/tests/elementary/efl_ui_suite.h1
-rw-r--r--src/tests/elementary/efl_ui_test_box.c352
-rw-r--r--src/tests/elementary/meson.build1
5 files changed, 356 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 2ed29dd393..8dbff475a1 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -1620,6 +1620,7 @@ tests_elementary_efl_ui_suite_SOURCES = \
1620 tests/elementary/efl_ui_test_focus_common.h \ 1620 tests/elementary/efl_ui_test_focus_common.h \
1621 tests/elementary/efl_ui_test_focus.c \ 1621 tests/elementary/efl_ui_test_focus.c \
1622 tests/elementary/efl_ui_test_focus_sub.c \ 1622 tests/elementary/efl_ui_test_focus_sub.c \
1623 tests/elementary/efl_ui_test_box.c \
1623 tests/elementary/efl_ui_test_grid.c \ 1624 tests/elementary/efl_ui_test_grid.c \
1624 tests/elementary/efl_ui_test_image.c \ 1625 tests/elementary/efl_ui_test_image.c \
1625 tests/elementary/efl_ui_test_image_zoomable.c \ 1626 tests/elementary/efl_ui_test_image_zoomable.c \
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index 91a579a763..5cc88df007 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -12,6 +12,7 @@ static const Efl_Test_Case etc[] = {
12 { "efl_ui_atspi", efl_ui_test_atspi}, 12 { "efl_ui_atspi", efl_ui_test_atspi},
13 { "efl_ui_focus", efl_ui_test_focus}, 13 { "efl_ui_focus", efl_ui_test_focus},
14 { "efl_ui_focus_sub", efl_ui_test_focus_sub}, 14 { "efl_ui_focus_sub", efl_ui_test_focus_sub},
15 { "efl_ui_box", efl_ui_test_box},
15 { "efl_ui_grid", efl_ui_test_grid}, 16 { "efl_ui_grid", efl_ui_test_grid},
16 { "efl_ui_image", efl_ui_test_image}, 17 { "efl_ui_image", efl_ui_test_image},
17 { "efl_ui_image_zoomable", efl_ui_test_image_zoomable}, 18 { "efl_ui_image_zoomable", efl_ui_test_image_zoomable},
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index 5c91331fc5..b65cbe5bfb 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -19,6 +19,7 @@
19 ck_assert_str_eq(expected, actual); \ 19 ck_assert_str_eq(expected, actual); \
20 } 20 }
21 21
22void efl_ui_test_box(TCase *tc);
22void efl_ui_test_grid(TCase *tc); 23void efl_ui_test_grid(TCase *tc);
23void efl_ui_test_atspi(TCase *tc); 24void efl_ui_test_atspi(TCase *tc);
24void efl_ui_test_image_zoomable(TCase *tc); 25void efl_ui_test_image_zoomable(TCase *tc);
diff --git a/src/tests/elementary/efl_ui_test_box.c b/src/tests/elementary/efl_ui_test_box.c
new file mode 100644
index 0000000000..314a2d5007
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_box.c
@@ -0,0 +1,352 @@
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_Size_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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.3, (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_SIZE_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_SIZE_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_SIZE_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.3, 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_SIZE_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.3, (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_SIZE_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_SIZE_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_SIZE_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.3, 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_SIZE_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.3, (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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_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_SIZE_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
157 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 240),
158 EINA_RECT(0, 0, 150, 70), "[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_SIZE_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
161 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 240),
162 EINA_RECT(0, 70, 150, 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_SIZE_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
165 EINA_SIZE2D(150, 200), EINA_SIZE2D(150, 240),
166 EINA_RECT(0, 170, 150, 70), "[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_SIZE_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_SIZE_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_SIZE_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_size_hint_max_set(btn, hint->max);
191 efl_gfx_size_hint_min_set(btn, hint->min);
192 efl_gfx_size_hint_weight_set(btn, hint->weightx, hint->weighty);
193 efl_gfx_size_hint_align_set(btn, hint->alignx, hint->aligny);
194 efl_gfx_size_hint_fill_set(btn, hint->fillx, hint->filly);
195 efl_gfx_size_hint_aspect_set(btn, hint->mode, hint->aspect);
196 efl_canvas_group_calculate(layout);
197}
198
199static void
200btn_geom_assert(Hint *hint, Eina_Rect btn_geom)
201{
202 Eina_Size2D layout_size, layout_min;
203
204 layout_size = efl_gfx_entity_size_get(layout);
205 layout_min = efl_gfx_size_hint_min_get(layout);
206 layout_size.w = layout_size.w > layout_min.w ? layout_size.w : layout_min.w;
207 layout_size.h = layout_size.h > layout_min.h ? layout_size.h : layout_min.h;
208
209 ck_assert_msg(GEOMETRY_EQ(btn_geom, hint->expected),
210 "Case %s failed... button geometry: (%d, %d, %d, %d) expected geometry: (%d, %d, %d, %d)",
211 hint->testname, btn_geom.x, btn_geom.y, btn_geom.w, btn_geom.h,
212 hint->expected.x, hint->expected.y, hint->expected.w, hint->expected.h);
213 ck_assert_msg(COORD_EQ(layout_size.w, hint->layout_expected.w) &&
214 COORD_EQ(layout_size.h, hint->layout_expected.h),
215 "Case %s failed... layout size: (%d, %d) expected size: (%d, %d)",
216 hint->testname, layout_size.w, layout_size.h,
217 hint->layout_expected.w, hint->layout_expected.h);
218}
219
220static void
221layout_setup()
222{
223 win = win_add();
224
225 layout = efl_add(EFL_UI_BOX_CLASS, win,
226 efl_pack_align_set(efl_added, 0.8, 0.2),
227 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL));
228}
229
230static void
231layout_teardown()
232{
233 if (win)
234 {
235 efl_del(win);
236 win = NULL;
237 }
238}
239
240EFL_START_TEST (efl_ui_box_class_check)
241{
242 const char *class;
243
244 class = efl_class_name_get(layout);
245
246 ck_assert(class != NULL);
247 ck_assert(!strcmp(class, "Efl.Ui.Box"));
248}
249EFL_END_TEST
250
251EFL_START_TEST (efl_ui_box_layout_update)
252{
253 int i, max_index = (sizeof(hints) / sizeof(Hint));
254
255 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
256 efl_pack_end(layout, efl_added));
257
258 for (i = 0; i < max_index; i++)
259 {
260 btn_hint_set(btn, &hints[i]);
261 btn_geom_assert(&hints[i], efl_gfx_entity_geometry_get(btn));
262 }
263}
264EFL_END_TEST
265
266EFL_START_TEST (efl_ui_box_layout_update_pack)
267{
268 int i, max_index2, max_index3;
269 Eo *btn, *btn2, *btn3;
270
271 max_index2 = ((sizeof(hints2) / sizeof(Hint)) / 2);
272 max_index3 = ((sizeof(hints3) / sizeof(Hint)) / 3);
273
274 btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
275 efl_pack_end(layout, efl_added));
276 btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
277 efl_pack_end(layout, efl_added));
278
279 for (i = 0; i < max_index2; i++)
280 {
281 btn_hint_set(btn, &hints2[i][0]);
282 btn_hint_set(btn2, &hints2[i][1]);
283 btn_geom_assert(&hints2[i][0], efl_gfx_entity_geometry_get(btn));
284 btn_geom_assert(&hints2[i][1], efl_gfx_entity_geometry_get(btn2));
285 }
286
287 btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
288 efl_pack_end(layout, efl_added));
289
290 for (i = 0; i < max_index3; i++)
291 {
292 btn_hint_set(btn, &hints3[i][0]);
293 btn_hint_set(btn2, &hints3[i][1]);
294 btn_hint_set(btn3, &hints3[i][2]);
295 btn_geom_assert(&hints3[i][0], efl_gfx_entity_geometry_get(btn));
296 btn_geom_assert(&hints3[i][1], efl_gfx_entity_geometry_get(btn2));
297 btn_geom_assert(&hints3[i][2], efl_gfx_entity_geometry_get(btn3));
298 }
299
300 // aspect resize test
301 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(150, 450);
302 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(150, 450);
303 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(150, 450);
304 hints3[3][0].expected = EINA_RECT(50, 0, 50, 150);
305 hints3[3][1].expected = EINA_RECT(50, 150, 50, 150);
306 hints3[3][2].expected = EINA_RECT(50, 300, 50, 150);
307
308 btn_hint_set(btn, &hints3[3][0]);
309 btn_hint_set(btn2, &hints3[3][1]);
310 btn_hint_set(btn3, &hints3[3][2]);
311 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
312 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
313 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
314
315 efl_ui_direction_set(layout, EFL_UI_DIR_HORIZONTAL);
316 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(300, 900);
317 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(300, 900);
318 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(300, 900);
319 hints3[3][0].expected = EINA_RECT(0, 300, 100, 300);
320 hints3[3][1].expected = EINA_RECT(100, 300, 100, 300);
321 hints3[3][2].expected = EINA_RECT(200, 300, 100, 300);
322
323 btn_hint_set(btn, &hints3[3][0]);
324 btn_hint_set(btn2, &hints3[3][1]);
325 btn_hint_set(btn3, &hints3[3][2]);
326 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
327 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
328 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
329
330 hints3[3][0].layout_expected = hints3[3][0].layout_size = EINA_SIZE2D(150, 450);
331 hints3[3][1].layout_expected = hints3[3][1].layout_size = EINA_SIZE2D(150, 450);
332 hints3[3][2].layout_expected = hints3[3][2].layout_size = EINA_SIZE2D(150, 450);
333 hints3[3][0].expected = EINA_RECT(0, 150, 50, 150);
334 hints3[3][1].expected = EINA_RECT(50, 150, 50, 150);
335 hints3[3][2].expected = EINA_RECT(100, 150, 50, 150);
336
337 btn_hint_set(btn, &hints3[3][0]);
338 btn_hint_set(btn2, &hints3[3][1]);
339 btn_hint_set(btn3, &hints3[3][2]);
340 btn_geom_assert(&hints3[3][0], efl_gfx_entity_geometry_get(btn));
341 btn_geom_assert(&hints3[3][1], efl_gfx_entity_geometry_get(btn2));
342 btn_geom_assert(&hints3[3][2], efl_gfx_entity_geometry_get(btn3));
343}
344EFL_END_TEST
345
346void efl_ui_test_box(TCase *tc)
347{
348 tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
349 tcase_add_test(tc, efl_ui_box_class_check);
350 tcase_add_test(tc, efl_ui_box_layout_update);
351 tcase_add_test(tc, efl_ui_box_layout_update_pack);
352}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index c9e4cdffb6..091d1540ef 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -122,6 +122,7 @@ efl_ui_suite_src = [
122 'efl_ui_test_focus_common.h', 122 'efl_ui_test_focus_common.h',
123 'efl_ui_test_focus.c', 123 'efl_ui_test_focus.c',
124 'efl_ui_test_focus_sub.c', 124 'efl_ui_test_focus_sub.c',
125 'efl_ui_test_box.c',
125 'efl_ui_test_grid.c', 126 'efl_ui_test_grid.c',
126 'efl_ui_test_image.c', 127 'efl_ui_test_image.c',
127 'efl_ui_test_image_zoomable.c', 128 'efl_ui_test_image_zoomable.c',