summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-11-27 12:52:06 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-11-27 12:52:06 -0500
commit69d1112f5b757a67b3e499d470bfff1305192207 (patch)
treeb3415166a371f472ddcaa8a6b7ee509fbb53e508
parent2ceaf9b657bda60fa94d8c42e1289d0f2469520e (diff)
Revert "tests/genlist: add behavior testing for nearly all genlist events"devs/zmike/123citest
This reverts commit 9d259115b806edcb3250f181dd47f9d5bb893092. this is incompatible with the current state of genlist
-rw-r--r--src/tests/elementary/elm_test_genlist.c187
1 files changed, 0 insertions, 187 deletions
diff --git a/src/tests/elementary/elm_test_genlist.c b/src/tests/elementary/elm_test_genlist.c
index 81eca40d81..3d6474af45 100644
--- a/src/tests/elementary/elm_test_genlist.c
+++ b/src/tests/elementary/elm_test_genlist.c
@@ -134,15 +134,6 @@ _item_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part EIN
134 return ic; 134 return ic;
135} 135}
136 136
137static char *
138_item_text_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part)
139{
140 char buf[128];
141 /* just some random-ish (not really) text */
142 snprintf(buf, sizeof(buf), "%p", part);
143 return strdup(buf);
144}
145
146EFL_START_TEST(elm_genlist_test_item_content) 137EFL_START_TEST(elm_genlist_test_item_content)
147{ 138{
148 Elm_Genlist_Item_Class *gtc; 139 Elm_Genlist_Item_Class *gtc;
@@ -572,182 +563,6 @@ EFL_START_TEST(elm_genlist_test_focus_state)
572} 563}
573EFL_END_TEST 564EFL_END_TEST
574 565
575/* keep in sync with elm_genlist.c value */
576#define MAX_ITEMS_PER_BLOCK 32
577
578EFL_START_TEST(elm_genlist_test_events)
579{
580 unsigned int i, called[10] = {0};
581 Eina_Bool norender = EINA_FALSE;
582 /* need focus for item focus tests */
583 win = win_add_focused(NULL, "genlist", ELM_WIN_BASIC);
584
585 itc.func.text_get = _item_text_get;
586
587 genlist = elm_genlist_add(win);
588 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
589
590 for (i = 0; i < 2 * MAX_ITEMS_PER_BLOCK; i++)
591 elm_genlist_item_append(genlist, &itc,
592 NULL/* item data */, NULL/* parent */,
593 0, NULL/* func */,
594 NULL/* func data */);
595
596 /* show 10ish items */
597 evas_object_resize(genlist, 200, 10 + GL_ITEM_SIZE_ISH * 10);
598 evas_object_show(genlist);
599 evas_object_show(win);
600 evas_object_resize(win, 200, 10 + GL_ITEM_SIZE_ISH * 10);
601 get_me_to_those_events(genlist);
602
603/* add callbacks only for the name array passed,
604 * verify that each callback is triggered based on event callback type
605 * remove callbacks so they don't break successive testing
606 * note: order is not tested or useful
607 */
608#define CB_TEST(namearray, ev_func, ...) \
609 do { \
610 const char **names = namearray; \
611 memset(called, 0, sizeof(called)); \
612 norender = EINA_FALSE; \
613 for (i = 0; *names; i++, names++) \
614 evas_object_smart_callback_add(genlist, *names, ev_func, &(called[i])); \
615 __VA_ARGS__ \
616 if (!norender) \
617 get_me_to_those_events(genlist); \
618 for (i = 0, names = namearray; *names; i++, names++) \
619 { \
620 evas_object_smart_callback_del_full(genlist, *names, ev_func, &(called[i])); \
621 if (!called[i]) fprintf(stderr, "GENLIST EVENT TEST ERROR: \"%s\" failed to trigger as expected!\n", namearray[i]); \
622 if (ev_func == event_callback_that_increments_an_int_when_called) \
623 ck_assert_int_ge(called[i], 1); \
624 else \
625 ck_assert_int_eq(called[i], 1); \
626 } \
627 } while (0)
628#define NAMEARRAY(...) \
629 (const char*[]){__VA_ARGS__, NULL}
630
631 /* first item: double click ->
632 * "activated" + "clicked,double" + "selected" + "highlighted" */
633 CB_TEST(NAMEARRAY("activated", "clicked,double", "selected", "highlighted"),
634 event_callback_single_call_int_data,
635 click_object_at_flags(genlist, 5, 5, EVAS_BUTTON_DOUBLE_CLICK);
636 );
637
638 /* first item: right click ->
639 * "clicked,right" */
640 CB_TEST(
641 NAMEARRAY("clicked,right"),
642 event_callback_single_call_int_data,
643 Evas *e = evas_object_evas_get(genlist);
644 norender = EINA_TRUE;
645 evas_event_feed_mouse_move(e, 5, 5, 0, NULL);
646 /* no util function for this since we never use right click */
647 evas_event_feed_mouse_down(e, 3, 0, 0, NULL);
648 evas_event_feed_mouse_up(e, 3, 0, 0, NULL);
649 );
650 /* some other item:
651 * click ->
652 * "unselected" + "unhighlighted" + "item,unfocused" on first item
653 * "pressed" + "released" + "item,focused" on other item */
654 CB_TEST(
655 NAMEARRAY("unselected", "unhighlighted", "pressed", "released", "item,focused", "item,unfocused"),
656 event_callback_single_call_int_data,
657 /* click on some other random item to trigger different selection/highlight */
658 click_object_at(genlist, 5, 50);
659 );
660
661 /* wheel ->
662 * "realized" on unrealized items
663 * "unrealized" on first item */
664 CB_TEST(
665 NAMEARRAY("realized", "unrealized"),
666 event_callback_that_increments_an_int_when_called,
667 /* disable animations to avoid having to wait an indeterminate amount of time for scrolling */
668 elm_config_scroll_animation_disabled_set(EINA_TRUE);
669 /* wheel to trigger realize/unrealize */
670 wheel_object_at(genlist, 50, 50, 0, 1);
671 /* re-enable animations before failure to avoid triggering cascading test failures */
672 elm_config_scroll_animation_disabled_set(EINA_FALSE);
673 );
674
675 /* filter_set ->
676 * "filter,done"
677 */
678 CB_TEST(
679 NAMEARRAY("filter,done"),
680 event_callback_single_call_int_data,
681 elm_genlist_filter_set(genlist, "2");
682 );
683 elm_genlist_filter_set(genlist, NULL);
684
685 /* simple drag ->
686 * "swipe" + "drag,start,right" + "drag,stop"
687 * also multiple "drag" events
688 */
689 evas_object_smart_callback_add(genlist, "drag", event_callback_that_increments_an_int_when_called, &called[5]);
690 CB_TEST(
691 NAMEARRAY("swipe", "drag,start,right", "drag,stop"),
692 event_callback_single_call_int_data,
693 click_object_at(genlist, 5, 50);
694 drag_object(genlist, 5, 50, 150, 0, EINA_FALSE);
695 );
696 evas_object_smart_callback_del_full(genlist, "drag", event_callback_that_increments_an_int_when_called, &called[5]);
697 /* there should be DRAG_OBJECT_NUM_MOVES - 1 "drag" events */
698 ck_assert_int_eq(called[5], DRAG_OBJECT_NUM_MOVES - 1);
699
700 /* continuous simple drags ->
701 * "drag,start,left", "drag,start,up", "drag,start,down"
702 */
703 evas_object_smart_callback_add(genlist, "drag,stop", event_callback_that_increments_an_int_when_called, &called[3]);
704 CB_TEST(
705 NAMEARRAY("drag,start,left", "drag,start,up", "drag,start,down"),
706 event_callback_single_call_int_data,
707 /* left */
708 click_object_at(genlist, 155, 50);
709 drag_object(genlist, 155, 50, -150, 0, EINA_FALSE);
710 /* down */
711 click_object_at(genlist, 5, 50);
712 drag_object(genlist, 5, 50, 0, 100, EINA_FALSE);
713 /* up */
714 click_object_at(genlist, 5, 150);
715 drag_object(genlist, 5, 150, 0, -100, EINA_FALSE);
716 );
717 evas_object_smart_callback_del_full(genlist, "drag", event_callback_that_increments_an_int_when_called, &called[3]);
718 ck_assert_int_eq(called[3], DRAG_OBJECT_NUM_MOVES - 1);
719
720 /* intensive drag down ->
721 * "longpressed" + "moved" + ("moved,after" || "moved,before")
722 * also "index,update" on all affected items
723 */
724 evas_object_smart_callback_add(genlist, "index,update", event_callback_that_increments_an_int_when_called, &called[3]);
725 /* exactly one of these will be called */
726 evas_object_smart_callback_add(genlist, "moved,before", event_callback_single_call_int_data, &called[2]);
727 evas_object_smart_callback_add(genlist, "moved,after", event_callback_single_call_int_data, &called[2]);
728 CB_TEST(
729 /* "moved,before" can only be triggered on the first item and is a bit finnicky/unreliable
730 * to trigger in unit tests so it's being ignored for now
731 */
732 NAMEARRAY("longpressed", "moved"),
733 event_callback_single_call_int_data,
734 double lp = elm_genlist_longpress_timeout_get(genlist);
735 elm_genlist_reorder_mode_set(genlist, EINA_TRUE);
736 elm_genlist_longpress_timeout_set(genlist, 0);
737 click_object_at(genlist, 5, 5);
738 drag_object(genlist, 5, 5, 0, 90, EINA_TRUE);
739 elm_genlist_reorder_mode_set(genlist, EINA_FALSE);
740 elm_genlist_longpress_timeout_set(genlist, lp);
741 );
742 evas_object_smart_callback_del_full(genlist, "moved,before", event_callback_single_call_int_data, &called[2]);
743 evas_object_smart_callback_del_full(genlist, "moved,after", event_callback_single_call_int_data, &called[2]);
744 ck_assert_int_eq(called[2], 1);
745 evas_object_smart_callback_del_full(genlist, "index,update", event_callback_that_increments_an_int_when_called, &called[3]);
746 /* at minimum, 2 items should have been changed */
747 ck_assert_int_ge(called[3], 2);
748}
749EFL_END_TEST
750
751void elm_test_genlist(TCase *tc) 566void elm_test_genlist(TCase *tc)
752{ 567{
753 tcase_add_test(tc, elm_genlist_test_legacy_type_check); 568 tcase_add_test(tc, elm_genlist_test_legacy_type_check);
@@ -763,6 +578,4 @@ void elm_test_genlist(TCase *tc)
763 578
764 tcase_add_test(tc, elm_genlist_test_focus_state); 579 tcase_add_test(tc, elm_genlist_test_focus_state);
765 tcase_add_test(tc, elm_genlist_test_tree_expand); 580 tcase_add_test(tc, elm_genlist_test_tree_expand);
766
767 tcase_add_test(tc, elm_genlist_test_events);
768} 581}