summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-07 11:18:18 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-08-09 10:25:33 -0700
commit2c33744a8adb6c13f041fa7581ab4e808034541e (patch)
tree2eafd07af430e8558f92bd78026fe21cda7eebe5 /src/tests
parent0a3dfe8b5c19a624476b18d94455b78fa972c006 (diff)
tests/popup: add test units for all the text_alert popups in elm_test
this is mostly to verify that the internal label is sizing as expected Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9523
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/elementary/efl_ui_test_popup.c121
1 files changed, 116 insertions, 5 deletions
diff --git a/src/tests/elementary/efl_ui_test_popup.c b/src/tests/elementary/efl_ui_test_popup.c
index 2f4f5401de..8537549f9d 100644
--- a/src/tests/elementary/efl_ui_test_popup.c
+++ b/src/tests/elementary/efl_ui_test_popup.c
@@ -21,22 +21,27 @@ _popup_layout_create(Eo *popup)
21 return layout; 21 return layout;
22} 22}
23 23
24static Eina_Size2D 24static Eo *
25_popup_scroll_alert_setup(Eo **popup_ret, Eo **layout_ret) 25_popup_alert_setup(const Efl_Class *klass)
26{ 26{
27 Eo *win, *popup; 27 Eo *win, *popup;
28 Eina_Size2D layout_sz_min;
29 28
30 win = win_add(); 29 win = win_add();
31 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE)); 30 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
32 31
33 *popup_ret = popup = efl_add(EFL_UI_SCROLL_ALERT_POPUP_CLASS, win); 32 popup = efl_add(klass, win);
34 efl_text_set(efl_part(popup, "title"), "title"); 33 efl_text_set(efl_part(popup, "title"), "title");
35 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_POSITIVE, "Yes", NULL); 34 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); 35 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); 36 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_USER, "Cancel", NULL);
37 return popup;
38}
38 39
39 40static Eina_Size2D
41_popup_scroll_alert_setup(Eo **popup_ret, Eo **layout_ret)
42{
43 Eina_Size2D layout_sz_min;
44 Eo *popup = *popup_ret = _popup_alert_setup(EFL_UI_SCROLL_ALERT_POPUP_CLASS);
40 Eo *layout = *layout_ret = _popup_layout_create(popup); 45 Eo *layout = *layout_ret = _popup_layout_create(popup);
41 46
42 /* should be 200x200 */ 47 /* should be 200x200 */
@@ -430,6 +435,111 @@ EFL_START_TEST(efl_ui_test_popup_scroll_alert_expand)
430} 435}
431EFL_END_TEST 436EFL_END_TEST
432 437
438
439
440EFL_START_TEST(efl_ui_test_popup_text_alert)
441{
442 Eo *popup = _popup_alert_setup(EFL_UI_TEXT_ALERT_POPUP_CLASS);
443 char test_string[] = "This is Text Popup";
444 unsigned int string_counts[] =
445 {
446 1, 50, 1, 1, 1, 50, 50, 50, 50, 50, 50, 50, 50, 50
447 };
448 Eina_Size2D test_expands[] =
449 {
450 EINA_SIZE2D(-1, -1),
451 EINA_SIZE2D(-1, -1),
452 EINA_SIZE2D(POPUP_SIZE_EXPAND, POPUP_SIZE_EXPAND),
453 EINA_SIZE2D(POPUP_SIZE_EXPAND, -1),
454 EINA_SIZE2D(-1, POPUP_SIZE_EXPAND),
455 EINA_SIZE2D(POPUP_SIZE_EXPAND, POPUP_SIZE_EXPAND),
456 EINA_SIZE2D(POPUP_SIZE_EXPAND, -1),
457 EINA_SIZE2D(-1, POPUP_SIZE_EXPAND),
458 EINA_SIZE2D(10, 10),
459 EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE),
460 EINA_SIZE2D(POPUP_SIZE, -1),
461 EINA_SIZE2D(POPUP_SIZE_EXPAND, -1),
462 EINA_SIZE2D(-1, POPUP_SIZE),
463 EINA_SIZE2D(-1, POPUP_SIZE_EXPAND),
464 };
465 Eina_Size2D expected_sizes[] =
466 {
467 /* -1 is MAX(POPUP_SIZE, min_size)
468 * 0 is min_size
469 * POPUP_SIZE_EXPAND on height is MIN(POPUP_SIZE_EXPAND, label_min)
470 */
471 EINA_SIZE2D(-1, -1),
472 EINA_SIZE2D(-1, -1),
473 EINA_SIZE2D(-1, 0),
474 EINA_SIZE2D(-1, -1),
475 EINA_SIZE2D(-1, 0),
476 EINA_SIZE2D(POPUP_SIZE_EXPAND, POPUP_SIZE_EXPAND),
477 EINA_SIZE2D(POPUP_SIZE_EXPAND, POPUP_SIZE),
478 EINA_SIZE2D(-1, 0),
479 EINA_SIZE2D(-1, 0),
480 EINA_SIZE2D(-1, POPUP_SIZE),
481 EINA_SIZE2D(-1, POPUP_SIZE),
482 EINA_SIZE2D(POPUP_SIZE_EXPAND, POPUP_SIZE),
483 EINA_SIZE2D(-1, POPUP_SIZE),
484 EINA_SIZE2D(-1, POPUP_SIZE_EXPAND),
485 };
486 unsigned int num_tests = EINA_C_ARRAY_LENGTH(string_counts);
487 unsigned int i;
488 Eina_Size2D popup_sz_min1;
489
490 /* ensure future modifications don't break the test */
491 ck_assert_int_eq(EINA_C_ARRAY_LENGTH(string_counts), EINA_C_ARRAY_LENGTH(test_expands));
492
493 get_me_to_those_events(popup);
494 popup_sz_min1 = efl_gfx_hint_size_combined_min_get(popup);
495
496 for (i = 0; i < num_tests; i++)
497 {
498 unsigned int j;
499 Eina_Size2D popup_sz_min, popup_sz, label_sz_min;
500 Eina_Strbuf *buf = eina_strbuf_new();
501 Eo *label;
502
503 for (j = 0; j < string_counts[i]; j++)
504 eina_strbuf_append(buf, test_string);
505
506 efl_text_set(popup, eina_strbuf_string_get(buf));
507 efl_ui_text_alert_popup_expandable_set(popup, test_expands[i]);
508 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
509 efl_canvas_group_calculate(popup);
510
511 /* get internal label object: VERY illegal */
512 label = efl_content_get(efl_content_get(efl_part(efl_super(popup, efl_ui_text_alert_popup_class_get()), "efl.content")));
513
514 label_sz_min = efl_gfx_hint_size_combined_min_get(label);
515 popup_sz_min = efl_gfx_hint_size_combined_min_get(popup);
516 popup_sz = efl_gfx_entity_size_get(popup);
517 if (expected_sizes[i].w == -1)
518 ck_assert_int_eq(popup_sz.w, MAX(POPUP_SIZE, popup_sz_min.w));
519 else if (expected_sizes[i].w == 0)
520 ck_assert_int_eq(popup_sz.w, popup_sz_min.w);
521 else
522 ck_assert_int_eq(popup_sz.w, expected_sizes[i].w);
523 if (expected_sizes[i].h == -1)
524 ck_assert_int_eq(popup_sz.h, MAX(POPUP_SIZE, popup_sz_min.h));
525 else if (expected_sizes[i].h == 0)
526 {
527 if ((test_expands[i].h >= label_sz_min.h) && (label_sz_min.h > popup_sz_min1.h))
528 ck_assert_int_eq(popup_sz.h, popup_sz_min.h);
529 else
530 ck_assert_int_eq(popup_sz.h, popup_sz_min1.h);
531 }
532 else if (expected_sizes[i].h == POPUP_SIZE_EXPAND)
533 ck_assert_int_eq(popup_sz.h, MIN(POPUP_SIZE_EXPAND, label_sz_min.h));
534 else
535 ck_assert_int_eq(popup_sz.h, expected_sizes[i].h);
536
537 eina_strbuf_free(buf);
538 }
539
540}
541EFL_END_TEST
542
433void efl_ui_test_popup(TCase *tc) 543void efl_ui_test_popup(TCase *tc)
434{ 544{
435 tcase_add_test(tc, efl_ui_test_popup_events); 545 tcase_add_test(tc, efl_ui_test_popup_events);
@@ -439,4 +549,5 @@ void efl_ui_test_popup(TCase *tc)
439 tcase_add_test(tc, efl_ui_test_popup_alert); 549 tcase_add_test(tc, efl_ui_test_popup_alert);
440 tcase_add_test(tc, efl_ui_test_popup_scroll_alert); 550 tcase_add_test(tc, efl_ui_test_popup_scroll_alert);
441 tcase_add_test(tc, efl_ui_test_popup_scroll_alert_expand); 551 tcase_add_test(tc, efl_ui_test_popup_scroll_alert_expand);
552 tcase_add_test(tc, efl_ui_test_popup_text_alert);
442} 553}