summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-06 15:18:01 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-07 14:48:38 +0200
commitc5030346d4b44690c652afa4e6eb91cfa8e552ea (patch)
treee40ae87cffe42a799e336a760849cc3774400842
parenteee58425eae4253abe16e86718fb08afc221a1b9 (diff)
tests/popup: add sizing test for scroll_alert popup
Differential Revision: https://phab.enlightenment.org/D9516
-rw-r--r--src/tests/elementary/efl_ui_test_popup.c80
1 files changed, 69 insertions, 11 deletions
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 @@
7#include "efl_ui_suite.h" 7#include "efl_ui_suite.h"
8 8
9#define WIN_SIZE 500 9#define WIN_SIZE 500
10#define POPUP_SIZE 160
11
12static Eo *
13_popup_layout_create(Eo *popup)
14{
15 char buf[PATH_MAX];
16 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, popup);
17 snprintf(buf, sizeof(buf), "%s/objects/test.edj", ELM_TEST_DATA_DIR);
18 ck_assert(efl_file_simple_load(layout, buf, "efl_ui_popup_scroll_content"));
19 efl_canvas_group_calculate(layout);
20 return layout;
21}
10 22
11EFL_START_TEST(efl_ui_test_popup_basic_align) 23EFL_START_TEST(efl_ui_test_popup_basic_align)
12{ 24{
@@ -16,7 +28,7 @@ EFL_START_TEST(efl_ui_test_popup_basic_align)
16 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE)); 28 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
17 29
18 popup = efl_add(EFL_UI_POPUP_CLASS, win); 30 popup = efl_add(EFL_UI_POPUP_CLASS, win);
19 efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160)); 31 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
20 32
21 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup); 33 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup);
22 efl_text_set(btn, "Efl.Ui.Popup"); 34 efl_text_set(btn, "Efl.Ui.Popup");
@@ -100,7 +112,7 @@ EFL_START_TEST(efl_ui_test_popup_basic_sizing)
100 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE)); 112 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
101 113
102 popup = efl_add(EFL_UI_POPUP_CLASS, win); 114 popup = efl_add(EFL_UI_POPUP_CLASS, win);
103 efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160)); 115 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
104 116
105 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup); 117 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup);
106 efl_text_set(btn, "Efl.Ui.Popup"); 118 efl_text_set(btn, "Efl.Ui.Popup");
@@ -111,8 +123,8 @@ EFL_START_TEST(efl_ui_test_popup_basic_sizing)
111 get_me_to_those_events(popup); 123 get_me_to_those_events(popup);
112 124
113 Eina_Size2D sz = efl_gfx_entity_size_get(popup); 125 Eina_Size2D sz = efl_gfx_entity_size_get(popup);
114 ck_assert_int_eq(sz.w, 160); 126 ck_assert_int_eq(sz.w, POPUP_SIZE);
115 ck_assert_int_eq(sz.h, 160); 127 ck_assert_int_eq(sz.h, POPUP_SIZE);
116} 128}
117EFL_END_TEST 129EFL_END_TEST
118 130
@@ -129,7 +141,7 @@ EFL_START_TEST(efl_ui_test_popup_events)
129 efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_BACKWALL_CLICKED, 141 efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_BACKWALL_CLICKED,
130 (void*)event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called, &called); 142 (void*)event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called, &called);
131 efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_TIMEOUT, event_callback_that_quits_the_main_loop_when_called, NULL); 143 efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_TIMEOUT, event_callback_that_quits_the_main_loop_when_called, NULL);
132 efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160)); 144 efl_ui_popup_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
133 145
134 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup); 146 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup);
135 efl_text_set(btn, "Efl.Ui.Popup"); 147 efl_text_set(btn, "Efl.Ui.Popup");
@@ -186,7 +198,6 @@ _popup_button_click(void *data, const Efl_Event *ev)
186EFL_START_TEST(efl_ui_test_popup_alert) 198EFL_START_TEST(efl_ui_test_popup_alert)
187{ 199{
188 Eo *win, *popup; 200 Eo *win, *popup;
189 char buf[PATH_MAX];
190 Eina_Size2D layout_sz_min; 201 Eina_Size2D layout_sz_min;
191 int called; 202 int called;
192 203
@@ -196,12 +207,9 @@ EFL_START_TEST(efl_ui_test_popup_alert)
196 popup = efl_add(EFL_UI_ALERT_POPUP_CLASS, win); 207 popup = efl_add(EFL_UI_ALERT_POPUP_CLASS, win);
197 efl_text_set(efl_part(popup, "title"), "title"); 208 efl_text_set(efl_part(popup, "title"), "title");
198 209
199 efl_gfx_entity_size_set(popup, EINA_SIZE2D(160, 160)); 210 efl_gfx_entity_size_set(popup, EINA_SIZE2D(POPUP_SIZE, POPUP_SIZE));
200 211
201 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, popup); 212 Eo *layout = _popup_layout_create(popup);
202 snprintf(buf, sizeof(buf), "%s/objects/test.edj", ELM_TEST_DATA_DIR);
203 ck_assert(efl_file_simple_load(layout, buf, "efl_ui_popup_scroll_content"));
204 efl_canvas_group_calculate(layout);
205 213
206 layout_sz_min = efl_gfx_hint_size_combined_min_get(layout); 214 layout_sz_min = efl_gfx_hint_size_combined_min_get(layout);
207 215
@@ -242,6 +250,55 @@ EFL_START_TEST(efl_ui_test_popup_alert)
242} 250}
243EFL_END_TEST 251EFL_END_TEST
244 252
253EFL_START_TEST(efl_ui_test_popup_scroll_alert)
254{
255 Eo *win, *popup;
256 Eina_Size2D layout_sz_min;
257 Eina_Size2D popup_sz_min;
258
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));
277 get_me_to_those_events(popup);
278
279 /* base popup size without content */
280 popup_sz_min = efl_gfx_hint_size_combined_min_get(popup);
281 {
282 /* the layout should currently be the size of its calculated (edje) min size */
283 Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
284 ck_assert_int_eq(layout_sz.w, layout_sz_min.w);
285 ck_assert_int_eq(layout_sz.h, layout_sz_min.h);
286 }
287
288 {
289 /* the popup should currently be the specified size...
290 * except that it's not because popup_size_set is just a fucking wrapper for
291 * efl_gfx_entity_size_set
292 */
293 Eina_Size2D popup_sz = efl_gfx_entity_size_get(popup);
294 //ck_assert_int_eq(popup_sz.w, POPUP_SIZE);
295 //ck_assert_int_eq(popup_sz.h, POPUP_SIZE);
296 ck_assert_int_eq(popup_sz.w, MAX(POPUP_SIZE, popup_sz_min.w));
297 ck_assert_int_eq(popup_sz.h, MAX(POPUP_SIZE, popup_sz_min.h));
298 }
299}
300EFL_END_TEST
301
245void efl_ui_test_popup(TCase *tc) 302void efl_ui_test_popup(TCase *tc)
246{ 303{
247 tcase_add_test(tc, efl_ui_test_popup_events); 304 tcase_add_test(tc, efl_ui_test_popup_events);
@@ -249,4 +306,5 @@ void efl_ui_test_popup(TCase *tc)
249 tcase_add_test(tc, efl_ui_test_popup_basic_align); 306 tcase_add_test(tc, efl_ui_test_popup_basic_align);
250 tcase_add_test(tc, efl_ui_test_popup_backwall_img); 307 tcase_add_test(tc, efl_ui_test_popup_backwall_img);
251 tcase_add_test(tc, efl_ui_test_popup_alert); 308 tcase_add_test(tc, efl_ui_test_popup_alert);
309 tcase_add_test(tc, efl_ui_test_popup_scroll_alert);
252} 310}