summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-04-02 13:59:28 -0400
committerStefan Schmidt <s.schmidt@samsung.com>2020-04-16 14:34:07 +0200
commit034d42855b08c2d43c3593587c7d7aaeb54351d5 (patch)
tree5965b88466025b9d175cdff2d71925d514b04112
parent272c3d9a665039711c1045b6fc540b2486139d9c (diff)
tests/elm: add hoversel behavior tests
this verifies all smart callbacks for a hoversel to ensure they're triggered as expected Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D11644
-rw-r--r--src/tests/elementary/elm_test_hoversel.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_hoversel.c b/src/tests/elementary/elm_test_hoversel.c
index 91de6afee0..0ccc5834da 100644
--- a/src/tests/elementary/elm_test_hoversel.c
+++ b/src/tests/elementary/elm_test_hoversel.c
@@ -6,6 +6,9 @@
6#include <Elementary.h> 6#include <Elementary.h>
7#include "elm_suite.h" 7#include "elm_suite.h"
8 8
9#include "elm_priv.h"
10#include "elm_widget_hoversel.h"
11
9EFL_START_TEST(elm_hoversel_legacy_type_check) 12EFL_START_TEST(elm_hoversel_legacy_type_check)
10{ 13{
11 Evas_Object *win, *hoversel; 14 Evas_Object *win, *hoversel;
@@ -41,8 +44,73 @@ EFL_START_TEST(elm_atspi_role_get)
41} 44}
42EFL_END_TEST 45EFL_END_TEST
43 46
47EFL_START_TEST(elm_test_hoversel_behavior)
48{
49 Eo *hoversel, *win = win_add();
50 unsigned int i;
51 const char *callbacks[] =
52 {
53 "expanded",
54 "clicked",
55 "selected",
56 "item,focused",
57 "item,unfocused",
58 "dismissed",
59 };
60 int count[EINA_C_ARRAY_LENGTH(callbacks)] = {0};
61
62 evas_object_resize(win, 500, 500);
63 hoversel = elm_hoversel_add(win);
64 evas_object_geometry_set(hoversel, 25, 25, 50, 50);
65 elm_hoversel_hover_parent_set(hoversel, win);
66 elm_object_text_set(hoversel, "Vertical");
67 elm_hoversel_item_add(hoversel, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL);
68 elm_hoversel_item_add(hoversel, "Item 2", NULL, ELM_ICON_NONE, NULL, NULL);
69 elm_hoversel_item_add(hoversel, "Item 3", NULL, ELM_ICON_NONE, NULL, NULL);
70 elm_hoversel_item_add(hoversel, "Item 4 - Long Label Here", "close", ELM_ICON_STANDARD, NULL, NULL);
71
72 evas_object_show(win);
73 evas_object_show(hoversel);
74 elm_object_focus_set(hoversel, EINA_TRUE);
75 for (i = 0; i < EINA_C_ARRAY_LENGTH(count); i++)
76 {
77 evas_object_smart_callback_add(hoversel, callbacks[i],
78 (void*)event_callback_single_call_int_data, &count[i]);
79 }
80 evas_object_smart_callback_add(hoversel, "dismissed",
81 (void*)event_callback_that_quits_the_main_loop_when_called, NULL);
82 get_me_to_those_events(win);
83 assert_object_size_eq(hoversel, 50, 50);
84 click_object(hoversel);
85 get_me_to_those_events(win);
86
87 /* expanded */
88 ck_assert_int_eq(count[0], 1);
89 wait_timer(0.6); // from default theme
90 ecore_main_loop_iterate();
91
92 ELM_HOVERSEL_DATA_GET(hoversel, sd);
93 click_object(eina_list_data_get(elm_box_children_get(sd->bx)));
94 get_me_to_those_events(win);
95
96 /* clicked */
97 ck_assert_int_eq(count[1], 1);
98 /* selected */
99 ck_assert_int_eq(count[2], 1);
100 /* item,focused */
101 ck_assert_int_eq(count[3], 1);
102 /* item,focused */
103 ck_assert_int_eq(count[4], 1);
104 ecore_main_loop_begin();
105
106 /* dismissed */
107 ck_assert_int_eq(count[5], 1);
108}
109EFL_END_TEST
110
44void elm_test_hoversel(TCase *tc) 111void elm_test_hoversel(TCase *tc)
45{ 112{
46 tcase_add_test(tc, elm_hoversel_legacy_type_check); 113 tcase_add_test(tc, elm_hoversel_legacy_type_check);
47 tcase_add_test(tc, elm_atspi_role_get); 114 tcase_add_test(tc, elm_atspi_role_get);
115 tcase_add_test(tc, elm_test_hoversel_behavior);
48} 116}