diff --git a/src/tests/elementary/efl_ui_test_popup.c b/src/tests/elementary/efl_ui_test_popup.c index c7e2913761..bdbce8d728 100644 --- a/src/tests/elementary/efl_ui_test_popup.c +++ b/src/tests/elementary/efl_ui_test_popup.c @@ -7,6 +7,18 @@ #include "efl_ui_suite.h" #define WIN_SIZE 500 +#define POPUP_SIZE 160 + +static Eo * +_popup_layout_create(Eo *popup) +{ + char buf[PATH_MAX]; + Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, popup); + snprintf(buf, sizeof(buf), "%s/objects/test.edj", ELM_TEST_DATA_DIR); + ck_assert(efl_file_simple_load(layout, buf, "efl_ui_popup_scroll_content")); + efl_canvas_group_calculate(layout); + return layout; +} EFL_START_TEST(efl_ui_test_popup_basic_align) { @@ -16,7 +28,7 @@ EFL_START_TEST(efl_ui_test_popup_basic_align) efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE)); popup = efl_add(EFL_UI_POPUP_CLASS, win); - efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160)); + efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE)); Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup); efl_text_set(btn, "Efl.Ui.Popup"); @@ -100,7 +112,7 @@ EFL_START_TEST(efl_ui_test_popup_basic_sizing) efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE)); popup = efl_add(EFL_UI_POPUP_CLASS, win); - efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160)); + efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE)); Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup); efl_text_set(btn, "Efl.Ui.Popup"); @@ -111,8 +123,8 @@ EFL_START_TEST(efl_ui_test_popup_basic_sizing) get_me_to_those_events(popup); Eina_Size2D sz = efl_gfx_entity_size_get(popup); - ck_assert_int_eq(sz.w, 160); - ck_assert_int_eq(sz.h, 160); + ck_assert_int_eq(sz.w, POPUP_SIZE); + ck_assert_int_eq(sz.h, POPUP_SIZE); } EFL_END_TEST @@ -129,7 +141,7 @@ EFL_START_TEST(efl_ui_test_popup_events) efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_BACKWALL_CLICKED, (void*)event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called, &called); efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_TIMEOUT, event_callback_that_quits_the_main_loop_when_called, NULL); - efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160)); + efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE)); Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup); efl_text_set(btn, "Efl.Ui.Popup"); @@ -186,7 +198,6 @@ _popup_button_click(void *data, const Efl_Event *ev) EFL_START_TEST(efl_ui_test_popup_alert) { Eo *win, *popup; - char buf[PATH_MAX]; Eina_Size2D layout_sz_min; int called; @@ -196,12 +207,9 @@ EFL_START_TEST(efl_ui_test_popup_alert) popup = efl_add(EFL_UI_ALERT_POPUP_CLASS, win); efl_text_set(efl_part(popup, "title"), "title"); - efl_gfx_entity_size_set(popup, EINA_SIZE2D(160, 160)); + efl_gfx_entity_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE)); - Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, popup); - snprintf(buf, sizeof(buf), "%s/objects/test.edj", ELM_TEST_DATA_DIR); - ck_assert(efl_file_simple_load(layout, buf, "efl_ui_popup_scroll_content")); - efl_canvas_group_calculate(layout); + Eo *layout = _popup_layout_create(popup); layout_sz_min = efl_gfx_hint_size_combined_min_get(layout); @@ -242,6 +250,55 @@ EFL_START_TEST(efl_ui_test_popup_alert) } EFL_END_TEST +EFL_START_TEST(efl_ui_test_popup_scroll_alert) +{ + Eo *win, *popup; + Eina_Size2D layout_sz_min; + Eina_Size2D popup_sz_min; + + win = win_add(); + efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE)); + + popup = efl_add(EFL_UI_SCROLL_ALERT_POPUP_CLASS, win); + efl_text_set(efl_part(popup, "title"), "title"); + efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_POSITIVE, "Yes", NULL); + efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_NEGATIVE, "No", NULL); + efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_USER, "Cancel", NULL); + + + Eo *layout = _popup_layout_create(popup); + + /* should be 200x200 */ + layout_sz_min = efl_gfx_hint_size_combined_min_get(layout); + efl_gfx_entity_size_set(layout, layout_sz_min); + + efl_content_set(popup, layout); + efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE)); + get_me_to_those_events(popup); + + /* base popup size without content */ + popup_sz_min = efl_gfx_hint_size_combined_min_get(popup); + { + /* the layout should currently be the size of its calculated (edje) min size */ + Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout); + ck_assert_int_eq(layout_sz.w, layout_sz_min.w); + ck_assert_int_eq(layout_sz.h, layout_sz_min.h); + } + + { + /* the popup should currently be the specified size... + * except that it's not because popup_size_set is just a fucking wrapper for + * efl_gfx_entity_size_set + */ + Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup); + //ck_assert_int_eq(popup_sz.w, POPUP_SIZE); + //ck_assert_int_eq(popup_sz.h, POPUP_SIZE); + ck_assert_int_eq(popup_sz.w, MAX(POPUP_SIZE, popup_sz_min.w)); + ck_assert_int_eq(popup_sz.h, MAX(POPUP_SIZE, popup_sz_min.h)); + } +} +EFL_END_TEST + void efl_ui_test_popup(TCase *tc) { tcase_add_test(tc, efl_ui_test_popup_events); @@ -249,4 +306,5 @@ void efl_ui_test_popup(TCase *tc) tcase_add_test(tc, efl_ui_test_popup_basic_align); tcase_add_test(tc, efl_ui_test_popup_backwall_img); tcase_add_test(tc, efl_ui_test_popup_alert); + tcase_add_test(tc, efl_ui_test_popup_scroll_alert); }