summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-04-13 12:43:21 -0400
committerStefan Schmidt <s.schmidt@samsung.com>2020-04-16 14:34:07 +0200
commit276c9ed26de31853b26a517ed8564cc47b29447c (patch)
tree2b44dfdc4ae72b05923fa091659470caba85ca4d
parent03164bfacf22f43d0dd37400a9fe8f777586419e (diff)
tests/elm: add callback tests for elm_list
basic tests to verify behavior for triggering callbacks when selecting items Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D11703
-rw-r--r--src/tests/elementary/elm_test_list.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_list.c b/src/tests/elementary/elm_test_list.c
index d15fb249f7..063384b235 100644
--- a/src/tests/elementary/elm_test_list.c
+++ b/src/tests/elementary/elm_test_list.c
@@ -242,6 +242,55 @@ EFL_START_TEST(elm_atspi_children_parent)
242} 242}
243EFL_END_TEST 243EFL_END_TEST
244 244
245#define NUM_ITEMS 10
246EFL_START_TEST(elm_list_test_callbacks)
247{
248 Evas_Object *win, *list;
249 unsigned int i;
250 int count[NUM_ITEMS] = {0};
251 Elm_Object_Item *it;
252 int selected = 0, unselected = 0;
253 int highlighted = 0, unhighlighted = 0;
254
255 win = win_add(NULL, "list", ELM_WIN_BASIC);
256 evas_object_resize(win, 100, 100);
257
258 list = elm_list_add(win);
259 evas_object_smart_callback_add(list, "selected", (void*)event_callback_that_increments_an_int_when_called, &selected);
260 evas_object_smart_callback_add(list, "unselected", (void*)event_callback_that_increments_an_int_when_called, &unselected);
261 evas_object_smart_callback_add(list, "highlighted", (void*)event_callback_that_increments_an_int_when_called, &highlighted);
262 evas_object_smart_callback_add(list, "unhighlighted", (void*)event_callback_that_increments_an_int_when_called, &unhighlighted);
263 evas_object_resize(list, 100, 100);
264 for (i = 0; i < NUM_ITEMS; i++)
265 elm_list_item_append(list, "item", NULL, NULL, (void*)event_callback_single_call_int_data, &(count[i]));
266
267 elm_list_go(list);
268 evas_object_show(list);
269 evas_object_show(win);
270 get_me_to_those_events(win);
271
272 for (i = 0, it = elm_list_first_item_get(list); i < NUM_ITEMS; i++, it = elm_list_item_next(it))
273 {
274 elm_list_item_selected_set(it, EINA_TRUE);
275 ck_assert_int_eq(count[i], 1);
276
277 ck_assert_int_eq(selected, i + 1);
278 ck_assert_int_eq(unselected, i);
279
280 ck_assert_int_eq(highlighted, i + 1);
281 ck_assert_int_eq(unhighlighted, i);
282 }
283 ck_assert_int_eq(selected, 10);
284 ck_assert_int_eq(unselected, 9);
285
286 ck_assert_int_eq(highlighted, 10);
287 ck_assert_int_eq(unhighlighted, 9);
288
289 /* weird SIGILL in shutdown if the list isn't deleted here */
290 evas_object_del(list);
291}
292EFL_END_TEST
293
245void elm_test_list(TCase *tc) 294void elm_test_list(TCase *tc)
246{ 295{
247 tcase_add_test(tc, elm_list_legacy_type_check); 296 tcase_add_test(tc, elm_list_legacy_type_check);
@@ -256,4 +305,5 @@ void elm_test_list(TCase *tc)
256 tcase_add_test(tc, elm_list_atspi_selection_child_deselect); 305 tcase_add_test(tc, elm_list_atspi_selection_child_deselect);
257#endif 306#endif
258 tcase_add_test(tc, elm_atspi_children_parent); 307 tcase_add_test(tc, elm_atspi_children_parent);
308 tcase_add_test(tc, elm_list_test_callbacks);
259} 309}