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
This commit is contained in:
Mike Blumenkrantz 2019-08-07 10:27:23 -04:00 committed by Cedric BAIL
parent 1334514cfe
commit 0a3dfe8b5c
1 changed files with 151 additions and 19 deletions

View File

@ -8,6 +8,7 @@
#define WIN_SIZE 500
#define POPUP_SIZE 160
#define POPUP_SIZE_EXPAND POPUP_SIZE * 2
static Eo *
_popup_layout_create(Eo *popup)
@ -20,6 +21,32 @@ _popup_layout_create(Eo *popup)
return layout;
}
static Eina_Size2D
_popup_scroll_alert_setup(Eo **popup_ret, Eo **layout_ret)
{
Eo *win, *popup;
Eina_Size2D layout_sz_min;
win = win_add();
efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
*popup_ret = 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 = *layout_ret = _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);
return layout_sz_min;
}
EFL_START_TEST(efl_ui_test_popup_basic_align)
{
Eo *win, *popup;
@ -252,27 +279,10 @@ EFL_END_TEST
EFL_START_TEST(efl_ui_test_popup_scroll_alert)
{
Eo *win, *popup;
Eina_Size2D layout_sz_min;
Eo *popup, *layout;
Eina_Size2D popup_sz_min;
Eina_Size2D layout_sz_min = _popup_scroll_alert_setup(&popup, &layout);
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);
@ -299,6 +309,127 @@ EFL_START_TEST(efl_ui_test_popup_scroll_alert)
}
EFL_END_TEST
EFL_START_TEST(efl_ui_test_popup_scroll_alert_expand)
{
Eo *popup, *layout;
Eina_Size2D popup_sz_min, popup_sz_min1, popup_sz1;
Eina_Size2D layout_sz_min = _popup_scroll_alert_setup(&popup, &layout);
get_me_to_those_events(popup);
/* base popup size without content */
popup_sz_min = popup_sz_min1 = efl_gfx_hint_size_combined_min_get(popup);
/* first test horizontal expand */
efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(POPUP_SIZE_EXPAND, -1));
efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
efl_canvas_group_calculate(popup);
{
/* the layout should currently be AT LEAST the size of its calculated (edje) min size
* this popup should expand.
*/
Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
ck_assert_int_ge(layout_sz.w, layout_sz_min.w);
ck_assert_int_ge(layout_sz.h, layout_sz_min.h);
}
{
Eina_Size2D popup_sz = popup_sz1 = efl_gfx_entity_size_get(popup);
/* this popup expands horizontally, so its width should be greater than the
* layout's min size even though the popup's size was explicitly set to be smaller
*/
ck_assert_int_gt(popup_sz.w, layout_sz_min.w);
ck_assert_int_le(popup_sz.w, POPUP_SIZE_EXPAND);
/* it does not expand vertically, so this should still be small. */
ck_assert_int_eq(popup_sz.h, MAX(POPUP_SIZE, popup_sz_min.h));
}
/* now expand vertically */
efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(-1, POPUP_SIZE_EXPAND));
efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
efl_canvas_group_calculate(popup);
/* base popup size without content */
popup_sz_min = efl_gfx_hint_size_combined_min_get(popup);
{
/* the layout should currently be AT LEAST the size of its calculated (edje) min size
* this popup should expand.
*/
Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
ck_assert_int_ge(layout_sz.w, layout_sz_min.w);
ck_assert_int_ge(layout_sz.h, layout_sz_min.h);
}
{
Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup);
/* this popup expands vertically, so its height should be greater than the
* layout's min size even though the popup's size was explicitly set to be smaller
*/
ck_assert_int_gt(popup_sz.h, layout_sz_min.h);
ck_assert_int_le(popup_sz.h, POPUP_SIZE_EXPAND);
/* it does not expand horizontally, so this should still be small. */
ck_assert_int_eq(popup_sz.w, MAX(POPUP_SIZE, popup_sz_min.w));
}
/* now both */
efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(POPUP_SIZE_EXPAND, POPUP_SIZE_EXPAND));
efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
efl_canvas_group_calculate(popup);
/* base popup size without content */
popup_sz_min = efl_gfx_hint_size_combined_min_get(popup);
{
/* the layout should currently be AT LEAST the size of its calculated (edje) min size
* this popup should expand.
*/
Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
ck_assert_int_ge(layout_sz.w, layout_sz_min.w);
ck_assert_int_ge(layout_sz.h, layout_sz_min.h);
}
{
Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup);
/* this popup expands horizontally, so its width should be greater than the
* layout's min size even though the popup's size was explicitly set to be smaller
*/
ck_assert_int_gt(popup_sz.w, layout_sz_min.w);
ck_assert_int_le(popup_sz.w, POPUP_SIZE_EXPAND);
/* this popup expands vertically, so its height should be greater than the
* layout's min size even though the popup's size was explicitly set to be smaller
*/
ck_assert_int_gt(popup_sz.h, layout_sz_min.h);
ck_assert_int_le(popup_sz.h, POPUP_SIZE_EXPAND);
}
/* now use a confining expand which ignores content min size */
efl_ui_scroll_alert_popup_expandable_set(popup, EINA_SIZE2D(POPUP_SIZE / 2, POPUP_SIZE / 2));
efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
efl_canvas_group_calculate(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);
}
{
Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup);
/* this popup is confined, so its size should be the popup's min size without content */
ck_assert_int_eq(popup_sz.w, popup_sz_min1.w);
ck_assert_int_eq(popup_sz.h, popup_sz_min1.h);
/* this popup should NOT be the same height as the popup in the first test */
ck_assert_int_ne(popup_sz.h, popup_sz1.h);
}
}
EFL_END_TEST
void efl_ui_test_popup(TCase *tc)
{
tcase_add_test(tc, efl_ui_test_popup_events);
@ -307,4 +438,5 @@ void efl_ui_test_popup(TCase *tc)
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);
tcase_add_test(tc, efl_ui_test_popup_scroll_alert_expand);
}