summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-06 10:03:45 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-06 17:18:37 +0200
commit4410f8b080060acc97a841e2a2fb74acb0d61621 (patch)
tree66685ad417fd3a602c6b89d2180a6c9db77cf0e0
parent9baa96c35271153d2b017fe072ee3e485b7f2c2b (diff)
tests/popup: add unit tests for alert_popup
this covers all cases from the elm_test example Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9512
-rw-r--r--src/tests/elementary/efl_ui_test_popup.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_popup.c b/src/tests/elementary/efl_ui_test_popup.c
index 45231674e4..c7e2913761 100644
--- a/src/tests/elementary/efl_ui_test_popup.c
+++ b/src/tests/elementary/efl_ui_test_popup.c
@@ -174,10 +174,79 @@ EFL_START_TEST(efl_ui_test_popup_backwall_img)
174} 174}
175EFL_END_TEST 175EFL_END_TEST
176 176
177static void
178_popup_button_click(void *data, const Efl_Event *ev)
179{
180 Efl_Ui_Alert_Popup_Button_Clicked_Event *event = ev->info;
181 int *called = data;
182
183 *called = event->button_type;
184}
185
186EFL_START_TEST(efl_ui_test_popup_alert)
187{
188 Eo *win, *popup;
189 char buf[PATH_MAX];
190 Eina_Size2D layout_sz_min;
191 int called;
192
193 win = win_add();
194 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
195
196 popup = efl_add(EFL_UI_ALERT_POPUP_CLASS, win);
197 efl_text_set(efl_part(popup, "title"), "title");
198
199 efl_gfx_entity_size_set(popup, EINA_SIZE2D(160, 160));
200
201 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, 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
206 layout_sz_min = efl_gfx_hint_size_combined_min_get(layout);
207
208 efl_content_set(popup, layout);
209 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_POSITIVE, "Yes", NULL);
210 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_NEGATIVE, "No", NULL);
211 efl_ui_alert_popup_button_set(popup, EFL_UI_ALERT_POPUP_BUTTON_USER, "Cancel", NULL);
212
213 efl_event_callback_add(popup, EFL_UI_ALERT_POPUP_EVENT_BUTTON_CLICKED, _popup_button_click, &called);
214
215 get_me_to_those_events(popup);
216 {
217 /* the layout should currently be the size of its calculated (edje) min size */
218 Eina_Size2D layout_sz = efl_gfx_entity_size_get(layout);
219 ck_assert_int_eq(layout_sz.w, layout_sz_min.w);
220 ck_assert_int_eq(layout_sz.h, layout_sz_min.h);
221 }
222
223 Eo *btn_layout = efl_content_get(efl_part(popup, "efl.buttons"));
224 /* verify button events work as expected using the layout set above:
225
226 Cancel | Yes | No
227 */
228 called = -1;
229 click_part(btn_layout, "efl.button1");
230 ecore_main_loop_iterate();
231 ck_assert_int_eq(called, EFL_UI_ALERT_POPUP_BUTTON_USER);
232
233 called = -1;
234 click_part(btn_layout, "efl.button2");
235 ecore_main_loop_iterate();
236 ck_assert_int_eq(called, EFL_UI_ALERT_POPUP_BUTTON_POSITIVE);
237
238 called = -1;
239 click_part(btn_layout, "efl.button3");
240 ecore_main_loop_iterate();
241 ck_assert_int_eq(called, EFL_UI_ALERT_POPUP_BUTTON_NEGATIVE);
242}
243EFL_END_TEST
244
177void efl_ui_test_popup(TCase *tc) 245void efl_ui_test_popup(TCase *tc)
178{ 246{
179 tcase_add_test(tc, efl_ui_test_popup_events); 247 tcase_add_test(tc, efl_ui_test_popup_events);
180 tcase_add_test(tc, efl_ui_test_popup_basic_sizing); 248 tcase_add_test(tc, efl_ui_test_popup_basic_sizing);
181 tcase_add_test(tc, efl_ui_test_popup_basic_align); 249 tcase_add_test(tc, efl_ui_test_popup_basic_align);
182 tcase_add_test(tc, efl_ui_test_popup_backwall_img); 250 tcase_add_test(tc, efl_ui_test_popup_backwall_img);
251 tcase_add_test(tc, efl_ui_test_popup_alert);
183} 252}