summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-11 13:38:07 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-09-11 13:38:07 -0400
commit6088557233f9c8fce259e58ae28d105ef1635bcd (patch)
treed937a1757bd5b0ef20624039932ede8ea70d2d06 /src/tests
parentc9399b2154d6cdad89fd2e8bc45627c3fcf8be05 (diff)
efl_ui_test_list_collection: add test for item placement
Summary: this test checks if the placement of the items is correct with and without scrolling, with and without groups. Depends on D9869 Reviewers: segfaultxavi, zmike, cedric Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9870
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/elementary/efl_ui_test_list_collection.c281
1 files changed, 281 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_list_collection.c b/src/tests/elementary/efl_ui_test_list_collection.c
index 98af17e7ec..1d4f913901 100644
--- a/src/tests/elementary/efl_ui_test_list_collection.c
+++ b/src/tests/elementary/efl_ui_test_list_collection.c
@@ -16,6 +16,7 @@ item_container_setup()
16 win = win_add(); 16 win = win_add();
17 item_container = efl_add(EFL_UI_COLLECTION_CLASS, win, 17 item_container = efl_add(EFL_UI_COLLECTION_CLASS, win,
18 efl_ui_collection_position_manager_set(efl_added, list)); 18 efl_ui_collection_position_manager_set(efl_added, list));
19 efl_content_set(win, item_container);
19 20
20} 21}
21 22
@@ -27,10 +28,290 @@ item_container_teardown()
27 win = NULL; 28 win = NULL;
28} 29}
29 30
31
32EFL_START_TEST(placement_test_only_items)
33{
34 Eo *item[3];
35
36 for (int i = 0; i < 2; ++i)
37 {
38 Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
39 efl_pack_end(item_container, item);
40 efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
41 }
42
43 for (int i = 0; i < 3; ++i)
44 {
45 item[i] = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
46 efl_pack_end(item_container, item[i]);
47 efl_gfx_hint_size_min_set(item[i], EINA_SIZE2D(40, 40));
48
49 }
50
51 //now fill up to trigger the scrollbar to be visible
52 for (int i = 0; i < 10; ++i)
53 {
54 Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
55 efl_pack_end(item_container, item);
56 efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
57 }
58
59 efl_gfx_entity_geometry_set(win, EINA_RECT(0, 0, 200, 200));
60
61 get_me_to_those_events(item_container);
62
63 for (int i = 0; i < 3; ++i)
64 {
65 Eina_Rect r = efl_gfx_entity_geometry_get(item[i]);
66
67 ck_assert_int_eq(r.x, 1);
68 ck_assert_int_eq(r.y, 1+(i+2)*40);
69 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
70 ck_assert_int_eq(r.h, 40);
71 }
72
73 efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 80));
74
75 for (int i = 0; i < 3; ++i)
76 {
77 Eina_Rect r = efl_gfx_entity_geometry_get(item[i]);
78
79 ck_assert_int_eq(r.x, 1);
80 ck_assert_int_eq(r.y, 1+i*40);
81 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
82 ck_assert_int_eq(r.h, 40);
83 }
84
85}
86EFL_END_TEST
87
88EFL_START_TEST(placement_test_group)
89{
90 Eo *core_item[4];
91 Eo *group;
92 Eina_Rect r;
93
94 for (int i = 0; i < 1; ++i)
95 {
96 Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
97 efl_pack_end(item_container, item);
98 efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
99 }
100
101 core_item[0] = group = efl_add(EFL_UI_GROUP_ITEM_CLASS, item_container);
102 efl_pack_end(item_container, group);
103 efl_gfx_hint_size_min_set(group, EINA_SIZE2D(40, 40));
104
105 Eo **item = core_item+1;
106 for (int i = 0; i < 3; ++i)
107 {
108 item[i] = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
109 efl_pack_end(group, item[i]);
110 efl_gfx_hint_size_min_set(item[i], EINA_SIZE2D(40, 40));
111
112 }
113
114 //now fill up to trigger the scrollbar to be visible
115 for (int i = 0; i < 10; ++i)
116 {
117 Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
118 efl_pack_end(group, item);
119 efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
120 }
121
122 efl_gfx_entity_geometry_set(win, EINA_RECT(0, 0, 200, 200));
123
124 get_me_to_those_events(item_container);
125
126 for (int i = 0; i < 4; ++i)
127 {
128 r = efl_gfx_entity_geometry_get(core_item[i]);
129
130 ck_assert_int_eq(r.x, 1);
131 ck_assert_int_eq(r.y, 1+(i+1)*40);
132 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
133 ck_assert_int_eq(r.h, 40);
134 }
135
136 // test when we have scrolled to the top of the group item - just testing normal scrolling
137 efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 40));
138
139 for (int i = 0; i < 4; ++i)
140 {
141 r = efl_gfx_entity_geometry_get(core_item[i]);
142
143 ck_assert_int_eq(r.x, 1);
144 ck_assert_int_eq(r.y, 1+i*40);
145 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
146 ck_assert_int_eq(r.h, 40);
147 }
148
149 //testing the placement in the middle of the item - group must already be warped
150 efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 60));
151
152 r = efl_gfx_entity_geometry_get(core_item[0]);
153
154 ck_assert_int_eq(r.x, 1);
155 ck_assert_int_eq(r.y, 1);
156 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
157 ck_assert_int_eq(r.h, 40);
158
159 for (int i = 1; i < 4; ++i)
160 {
161 r = efl_gfx_entity_geometry_get(core_item[i]);
162
163 ck_assert_int_eq(r.x, 1);
164 ck_assert_int_eq(r.y, 21+(i - 1)*40);
165 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
166 ck_assert_int_eq(r.h, 40);
167 }
168
169 // testing if we have scrolled into the middle of the group the group item is not even in the calculated index anymore
170 efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 120));
171
172 r = efl_gfx_entity_geometry_get(core_item[0]);
173
174 ck_assert_int_eq(r.x, 1);
175 ck_assert_int_eq(r.y, 1);
176 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
177 ck_assert_int_eq(r.h, 40);
178
179 for (int i = 2; i < 4; ++i)
180 {
181 r = efl_gfx_entity_geometry_get(core_item[i]);
182
183 ck_assert_int_eq(r.x, 1);
184 ck_assert_int_eq(r.y, 1+(i-2)*40);
185 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
186 ck_assert_int_eq(r.h, 40);
187 }
188
189}
190EFL_END_TEST
191
192EFL_START_TEST(placement_test_group_crazy)
193{
194 Eo *core_item[4];
195 Eo *group;
196 Eina_Rect r;
197
198 for (int i = 0; i < 1; ++i)
199 {
200 Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
201 efl_pack_end(item_container, item);
202 efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
203 }
204
205 core_item[0] = group = efl_add(EFL_UI_GROUP_ITEM_CLASS, item_container);
206 efl_pack_end(item_container, group);
207 efl_gfx_hint_size_min_set(group, EINA_SIZE2D(40, 40));
208
209 Eo **item = core_item+1;
210 for (int i = 0; i < 3; ++i)
211 {
212 item[i] = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
213 efl_pack_end(group, item[i]);
214 efl_gfx_hint_size_min_set(item[i], EINA_SIZE2D(40, 40));
215
216 }
217
218 //now fill up to trigger the scrollbar to be visible
219 for (int i = 0; i < 10; ++i)
220 {
221 Eo *group2 = efl_add(EFL_UI_GROUP_ITEM_CLASS, item_container);
222 efl_pack_end(item_container, group2);
223 efl_gfx_hint_size_min_set(group2, EINA_SIZE2D(40, 40));
224 for (int i = 0; i < 3; ++i)
225 {
226 Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
227 efl_pack_end(group2, item);
228 efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
229 }
230 }
231
232 efl_gfx_entity_geometry_set(win, EINA_RECT(0, 0, 200, 800));
233
234 get_me_to_those_events(item_container);
235
236 for (int i = 0; i < 4; ++i)
237 {
238 r = efl_gfx_entity_geometry_get(core_item[i]);
239
240 ck_assert_int_eq(r.x, 1);
241 ck_assert_int_eq(r.y, 1+(i+1)*40);
242 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
243 ck_assert_int_eq(r.h, 40);
244 ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
245 }
246
247 // test when we have scrolled to the top of the group item - just testing normal scrolling
248 efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 40));
249
250 for (int i = 0; i < 4; ++i)
251 {
252 r = efl_gfx_entity_geometry_get(core_item[i]);
253
254 ck_assert_int_eq(r.x, 1);
255 ck_assert_int_eq(r.y, 1+i*40);
256 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
257 ck_assert_int_eq(r.h, 40);
258 ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
259 }
260
261 //testing the placement in the middle of the item - group must already be warped
262 efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 60));
263
264 r = efl_gfx_entity_geometry_get(core_item[0]);
265
266 ck_assert_int_eq(r.x, 1);
267 ck_assert_int_eq(r.y, 1);
268 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
269 ck_assert_int_eq(r.h, 40);
270 ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[0]), EINA_TRUE);
271
272 for (int i = 1; i < 4; ++i)
273 {
274 r = efl_gfx_entity_geometry_get(core_item[i]);
275
276 ck_assert_int_eq(r.x, 1);
277 ck_assert_int_eq(r.y, 21+(i - 1)*40);
278 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
279 ck_assert_int_eq(r.h, 40);
280 ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
281 }
282
283 // testing if we have scrolled into the middle of the group the group item is not even in the calculated index anymore
284 efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 120));
285
286 r = efl_gfx_entity_geometry_get(core_item[0]);
287
288 ck_assert_int_eq(r.x, 1);
289 ck_assert_int_eq(r.y, 1);
290 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
291 ck_assert_int_eq(r.h, 40);
292 ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[0]), EINA_TRUE);
293
294 for (int i = 2; i < 4; ++i)
295 {
296 r = efl_gfx_entity_geometry_get(core_item[i]);
297
298 ck_assert_int_eq(r.x, 1);
299 ck_assert_int_eq(r.y, 1+(i-2)*40);
300 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
301 ck_assert_int_eq(r.h, 40);
302 ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
303 }
304
305}
306EFL_END_TEST
307
30void efl_ui_test_list_container(TCase *tc) 308void efl_ui_test_list_container(TCase *tc)
31{ 309{
32 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown); 310 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
33 tcase_add_checked_fixture(tc, item_container_setup, item_container_teardown); 311 tcase_add_checked_fixture(tc, item_container_setup, item_container_teardown);
34 efl_ui_test_item_container_common_add(tc); 312 efl_ui_test_item_container_common_add(tc);
35 efl_ui_test_position_manager_common_add(tc); 313 efl_ui_test_position_manager_common_add(tc);
314 tcase_add_test(tc, placement_test_only_items);
315 tcase_add_test(tc, placement_test_group);
316 tcase_add_test(tc, placement_test_group_crazy);
36} 317}