summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-12 14:38:30 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-16 14:48:50 +0200
commit1d90b113e0b1b5dd4fa7476168b6a8ff8dc06cc3 (patch)
tree96ce79b90ca030dae6a85a55b47bfc8450164c1f
parent62059763c6dfcda808781e20de94358d76bb301e (diff)
tests/actionslider: add more actionslider unit tests
verify actionslider callbacks and various basic functionalities Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9322
-rw-r--r--src/tests/elementary/elm_test_actionslider.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_actionslider.c b/src/tests/elementary/elm_test_actionslider.c
index b679b6017c..4350791df2 100644
--- a/src/tests/elementary/elm_test_actionslider.c
+++ b/src/tests/elementary/elm_test_actionslider.c
@@ -41,8 +41,107 @@ EFL_START_TEST(elm_atspi_role_get)
41} 41}
42EFL_END_TEST 42EFL_END_TEST
43 43
44static const char *test_val;
45
46static void
47test_pos_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
48{
49 int *called = data;
50
51 (*called)++;
52}
53
54static void
55test_selected_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
56{
57 /* if the test crashes with a crazy stack trace, this assert failed */
58 ck_assert_str_eq(event_info, test_val);
59 ecore_main_loop_quit();
60}
61
62EFL_START_TEST(elm_actionslider_test_callbacks)
63{
64 Evas_Object *win, *as;
65 int called = 0;
66
67 win = win_add(NULL, "as", ELM_WIN_BASIC);
68
69 as = elm_actionslider_add(win);
70 evas_object_resize(as, 200, 200);
71 evas_object_resize(win, 200, 200);
72
73 evas_object_show(win);
74 evas_object_show(as);
75 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
76 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
77 elm_object_part_text_set(as, "left", "test1");
78 elm_object_part_text_set(as, "center", "test2");
79 elm_object_part_text_set(as, "right", "test3");
80 elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
81 ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT);
82 evas_object_smart_callback_add(as, "pos_changed",
83 test_pos_changed_cb, &called);
84 evas_object_smart_callback_add(as, "selected", test_selected_cb, &called);
85
86 get_me_to_those_events(as);
87
88 test_val = "test2";
89 called = 0;
90 click_part(as, "elm.text.left");
91 edje_object_message_signal_process(as);
92 ecore_main_loop_begin();
93 ck_assert_int_eq(called, 1);
94
95 test_val = "test1";
96 called = 0;
97 click_part(as, "elm.text.left");
98 edje_object_message_signal_process(as);
99 ecore_main_loop_begin();
100 ck_assert_int_eq(called, 1);
101
102 test_val = "test2";
103 called = 0;
104 click_part(as, "elm.text.center");
105 edje_object_message_signal_process(as);
106 ecore_main_loop_begin();
107 ck_assert_int_eq(called, 1);
108
109 test_val = "test3";
110 called = 0;
111 click_part(as, "elm.text.right");
112 edje_object_message_signal_process(as);
113 ecore_main_loop_begin();
114 ck_assert_int_eq(called, 1);
115}
116EFL_END_TEST
117
118EFL_START_TEST(elm_actionslider_test_parts)
119{
120 Evas_Object *win, *as;
121
122 win = win_add(NULL, "as", ELM_WIN_BASIC);
123
124 as = elm_actionslider_add(win);
125
126 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
127 ck_assert_int_eq(elm_actionslider_indicator_pos_get(as), ELM_ACTIONSLIDER_RIGHT);
128 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
129 ck_assert_int_eq(elm_actionslider_magnet_pos_get(as), ELM_ACTIONSLIDER_RIGHT);
130 elm_object_part_text_set(as, "left", "Snooze");
131 ck_assert_str_eq(elm_object_part_text_get(as, "left"), "Snooze");
132 elm_object_part_text_set(as, "center", NULL);
133 ck_assert_ptr_eq(elm_object_part_text_get(as, "center"), NULL);
134 elm_object_part_text_set(as, "right", "Stop");
135 ck_assert_str_eq(elm_object_part_text_get(as, "right"), "Stop");
136 elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT);
137 ck_assert_int_eq(elm_actionslider_enabled_pos_get(as), ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT);
138}
139EFL_END_TEST
140
44void elm_test_actionslider(TCase *tc) 141void elm_test_actionslider(TCase *tc)
45{ 142{
46 tcase_add_test(tc, elm_actionslider_legacy_type_check); 143 tcase_add_test(tc, elm_actionslider_legacy_type_check);
47 tcase_add_test(tc, elm_atspi_role_get); 144 tcase_add_test(tc, elm_atspi_role_get);
145 tcase_add_test(tc, elm_actionslider_test_callbacks);
146 tcase_add_test(tc, elm_actionslider_test_parts);
48} 147}