summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-07 10:27:23 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-08-09 10:25:30 -0700
commit0a3dfe8b5c19a624476b18d94455b78fa972c006 (patch)
tree0f437ac034ddd8b246436610e6b195e1d4fbd4a3 /src/tests
parent1334514cfea35ec95a5e25ebc007283e7a88b5c3 (diff)
tests/popup: add unit tests for scroll_alert expandable sizing
these correspond to the cases in elm_test Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9522
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/elementary/efl_ui_test_popup.c170
1 files changed, 151 insertions, 19 deletions
diff --git a/src/tests/elementary/efl_ui_test_popup.c b/src/tests/elementary/efl_ui_test_popup.c
index bdbce8d728..2f4f5401de 100644
--- a/src/tests/elementary/efl_ui_test_popup.c
+++ b/src/tests/elementary/efl_ui_test_popup.c
@@ -8,6 +8,7 @@
8 8
9#define WIN_SIZE 500 9#define WIN_SIZE 500
10#define POPUP_SIZE 160 10#define POPUP_SIZE 160
11#define POPUP_SIZE_EXPAND POPUP_SIZE * 2
11 12
12static Eo * 13static Eo *
13_popup_layout_create(Eo *popup) 14_popup_layout_create(Eo *popup)
@@ -20,6 +21,32 @@ _popup_layout_create(Eo *popup)
20 return layout; 21 return layout;
21} 22}
22 23
24static Eina_Size2D
25_popup_scroll_alert_setup(Eo **popup_ret, Eo **layout_ret)
26{
27 Eo *win, *popup;
28 Eina_Size2D layout_sz_min;
29
30 win = win_add();
31 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
32
33 *popup_ret = popup = efl_add(EFL_UI_SCROLL_ALERT_POPUP_CLASS, win);
34 efl_text_set(efl_part(popup, "title"), "title");
35 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_POSITIVE, "Yes", NULL);
36 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_NEGATIVE, "No", NULL);
37 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_USER, "Cancel", NULL);
38
39
40 Eo *layout = *layout_ret = _popup_layout_create(popup);
41
42 /* should be 200x200 */
43 layout_sz_min = efl_gfx_hint_size_combined_min_get(layout);
44 efl_gfx_entity_size_set(layout, layout_sz_min);
45
46 efl_content_set(popup, layout);
47 return layout_sz_min;
48}
49
23EFL_START_TEST(efl_ui_test_popup_basic_align) 50EFL_START_TEST(efl_ui_test_popup_basic_align)
24{ 51{
25 Eo *win, *popup; 52 Eo *win, *popup;
@@ -252,27 +279,10 @@ EFL_END_TEST
252 279
253EFL_START_TEST(efl_ui_test_popup_scroll_alert) 280EFL_START_TEST(efl_ui_test_popup_scroll_alert)
254{ 281{
255 Eo *win, *popup; 282 Eo *popup, *layout;
256 Eina_Size2D layout_sz_min;
257 Eina_Size2D popup_sz_min; 283 Eina_Size2D popup_sz_min;
284 Eina_Size2D layout_sz_min = _popup_scroll_alert_setup(&popup, &layout);
258 285
259 win = win_add();
260 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
261
262 popup = efl_add(EFL_UI_SCROLL_ALERT_POPUP_CLASS, win);
263 efl_text_set(efl_part(popup, "title"), "title");
264 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_POSITIVE, "Yes", NULL);
265 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_NEGATIVE, "No", NULL);
266 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_USER, "Cancel", NULL);
267
268
269 Eo *layout = _popup_layout_create(popup);
270
271 /* should be 200x200 */
272 layout_sz_min = efl_gfx_hint_size_combined_min_get(layout);
273 efl_gfx_entity_size_set(layout, layout_sz_min);
274
275 efl_content_set(popup, layout);
276 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE)); 286 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
277 get_me_to_those_events(popup); 287 get_me_to_those_events(popup);
278 288
@@ -299,6 +309,127 @@ EFL_START_TEST(efl_ui_test_popup_scroll_alert)
299} 309}
300EFL_END_TEST 310EFL_END_TEST
301 311
312EFL_START_TEST(efl_ui_test_popup_scroll_alert_expand)
313{
314 Eo *popup, *layout;
315 Eina_Size2D popup_sz_min, popup_sz_min1, popup_sz1;
316 Eina_Size2D layout_sz_min = _popup_scroll_alert_setup(&popup, &layout);
317
318 get_me_to_those_events(popup);
319
320 /* base popup size without content */
321 popup_sz_min = popup_sz_min1 = efl_gfx_hint_size_combined_min_get(popup);
322
323 /* first test horizontal expand */
324 efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(POPUP_SIZE_EXPAND, -1));
325 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
326 efl_canvas_group_calculate(popup);
327
328
329 {
330 /* the layout should currently be AT LEAST the size of its calculated (edje) min size
331 * this popup should expand.
332 */
333 Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
334 ck_assert_int_ge(layout_sz.w, layout_sz_min.w);
335 ck_assert_int_ge(layout_sz.h, layout_sz_min.h);
336 }
337
338 {
339 Eina_Size2D popup_sz = popup_sz1 = efl_gfx_entity_size_get(popup);
340 /* this popup expands horizontally, so its width should be greater than the
341 * layout's min size even though the popup's size was explicitly set to be smaller
342 */
343 ck_assert_int_gt(popup_sz.w, layout_sz_min.w);
344 ck_assert_int_le(popup_sz.w, POPUP_SIZE_EXPAND);
345 /* it does not expand vertically, so this should still be small. */
346 ck_assert_int_eq(popup_sz.h, MAX(POPUP_SIZE, popup_sz_min.h));
347 }
348
349 /* now expand vertically */
350 efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(-1, POPUP_SIZE_EXPAND));
351 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
352 efl_canvas_group_calculate(popup);
353
354 /* base popup size without content */
355 popup_sz_min = efl_gfx_hint_size_combined_min_get(popup);
356 {
357 /* the layout should currently be AT LEAST the size of its calculated (edje) min size
358 * this popup should expand.
359 */
360 Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
361 ck_assert_int_ge(layout_sz.w, layout_sz_min.w);
362 ck_assert_int_ge(layout_sz.h, layout_sz_min.h);
363 }
364
365 {
366 Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup);
367 /* this popup expands vertically, so its height should be greater than the
368 * layout's min size even though the popup's size was explicitly set to be smaller
369 */
370 ck_assert_int_gt(popup_sz.h, layout_sz_min.h);
371 ck_assert_int_le(popup_sz.h, POPUP_SIZE_EXPAND);
372 /* it does not expand horizontally, so this should still be small. */
373 ck_assert_int_eq(popup_sz.w, MAX(POPUP_SIZE, popup_sz_min.w));
374 }
375
376 /* now both */
377 efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(POPUP_SIZE_EXPAND, POPUP_SIZE_EXPAND));
378 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
379 efl_canvas_group_calculate(popup);
380
381 /* base popup size without content */
382 popup_sz_min = efl_gfx_hint_size_combined_min_get(popup);
383 {
384 /* the layout should currently be AT LEAST the size of its calculated (edje) min size
385 * this popup should expand.
386 */
387 Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
388 ck_assert_int_ge(layout_sz.w, layout_sz_min.w);
389 ck_assert_int_ge(layout_sz.h, layout_sz_min.h);
390 }
391
392 {
393 Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup);
394
395 /* this popup expands horizontally, so its width should be greater than the
396 * layout's min size even though the popup's size was explicitly set to be smaller
397 */
398 ck_assert_int_gt(popup_sz.w, layout_sz_min.w);
399 ck_assert_int_le(popup_sz.w, POPUP_SIZE_EXPAND);
400
401 /* this popup expands vertically, so its height should be greater than the
402 * layout's min size even though the popup's size was explicitly set to be smaller
403 */
404 ck_assert_int_gt(popup_sz.h, layout_sz_min.h);
405 ck_assert_int_le(popup_sz.h, POPUP_SIZE_EXPAND);
406 }
407
408 /* now use a confining expand which ignores content min size */
409 efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(POPUP_SIZE / 2, POPUP_SIZE / 2));
410 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
411 efl_canvas_group_calculate(popup);
412
413 {
414 /* the layout should currently be the size of its calculated (edje) min size */
415 Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
416 ck_assert_int_eq(layout_sz.w, layout_sz_min.w);
417 ck_assert_int_eq(layout_sz.h, layout_sz_min.h);
418 }
419
420
421 {
422 Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup);
423
424 /* this popup is confined, so its size should be the popup's min size without content */
425 ck_assert_int_eq(popup_sz.w, popup_sz_min1.w);
426 ck_assert_int_eq(popup_sz.h, popup_sz_min1.h);
427 /* this popup should NOT be the same height as the popup in the first test */
428 ck_assert_int_ne(popup_sz.h, popup_sz1.h);
429 }
430}
431EFL_END_TEST
432
302void efl_ui_test_popup(TCase *tc) 433void efl_ui_test_popup(TCase *tc)
303{ 434{
304 tcase_add_test(tc, efl_ui_test_popup_events); 435 tcase_add_test(tc, efl_ui_test_popup_events);
@@ -307,4 +438,5 @@ void efl_ui_test_popup(TCase *tc)
307 tcase_add_test(tc, efl_ui_test_popup_backwall_img); 438 tcase_add_test(tc, efl_ui_test_popup_backwall_img);
308 tcase_add_test(tc, efl_ui_test_popup_alert); 439 tcase_add_test(tc, efl_ui_test_popup_alert);
309 tcase_add_test(tc, efl_ui_test_popup_scroll_alert); 440 tcase_add_test(tc, efl_ui_test_popup_scroll_alert);
441 tcase_add_test(tc, efl_ui_test_popup_scroll_alert_expand);
310} 442}