summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-06-21 14:07:44 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-24 18:31:50 +0200
commit0a0f3d5bfe167d1cb31127f066e1e4af3ef0a563 (patch)
tree830ef2d048caf3166d48a0545f3b92c734dd9746
parent06024475ccb0a314ae5a10c5b3785e6aff9f81e7 (diff)
tests/slider: verify emission of changed and delay,changed events
this simulates clicking and dragging a slider to avoid regressions with these events Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9152
-rw-r--r--src/tests/elementary/elm_test_slider.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_slider.c b/src/tests/elementary/elm_test_slider.c
index c5038207d9..e4ef256ea6 100644
--- a/src/tests/elementary/elm_test_slider.c
+++ b/src/tests/elementary/elm_test_slider.c
@@ -104,9 +104,64 @@ EFL_START_TEST(elm_slider_in_scroller)
104} 104}
105EFL_END_TEST 105EFL_END_TEST
106 106
107static unsigned int event_counter;
108
109static void
110slider_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
111{
112 event_counter++;
113 if (event_counter == 2) ecore_main_loop_quit();
114 else evas_object_smart_callback_del(obj, "changed", slider_changed);
115}
116
117static void
118slider_change(void *data)
119{
120 int x, y, w, h;
121 int sx, sy, sw, sh;
122 Evas *e = evas_object_evas_get(data);
123
124 evas_object_geometry_get(elm_object_part_content_get(data, "elm.swallow.bar"), &x, &y, &w, &h);
125 evas_object_geometry_get(data, &sx, &sy, &sw, &sh);
126 evas_event_feed_mouse_in(e, 0, NULL);
127 evas_event_feed_mouse_move(e, x + (w / 2), y + (h / 2), 0, NULL);
128 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
129 evas_event_feed_mouse_move(e, sx + (sw / 2), sy + (sh / 2), 0, NULL);
130 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
131}
132
133static void
134events_norendered(void *data, Evas *e, void *event_info EINA_UNUSED)
135{
136 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, norendered);
137 ecore_job_add(slider_change, data);
138}
139
140EFL_START_TEST(elm_slider_events)
141{
142 Evas_Object *win, *slider;
143
144 win = win_add(NULL, "slider", ELM_WIN_BASIC);
145
146 slider = elm_slider_add(win);
147 evas_object_smart_callback_add(slider, "changed", slider_changed, NULL);
148 evas_object_smart_callback_add(slider, "delay,changed", slider_changed, NULL);
149 evas_object_show(slider);
150 evas_object_show(win);
151 evas_object_resize(slider, 400, 100);
152 evas_object_resize(win, 400, 100);
153 edje_object_message_signal_process(elm_layout_edje_get(slider));
154 evas_smart_objects_calculate(evas_object_evas_get(win));
155 evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, events_norendered, slider);
156 ecore_main_loop_begin();
157 ck_assert_int_eq(event_counter, 2);
158}
159EFL_END_TEST
160
107void elm_test_slider(TCase *tc) 161void elm_test_slider(TCase *tc)
108{ 162{
109 tcase_add_test(tc, elm_slider_legacy_type_check); 163 tcase_add_test(tc, elm_slider_legacy_type_check);
110 tcase_add_test(tc, elm_slider_in_scroller); 164 tcase_add_test(tc, elm_slider_in_scroller);
165 tcase_add_test(tc, elm_slider_events);
111 tcase_add_test(tc, elm_atspi_role_get); 166 tcase_add_test(tc, elm_atspi_role_get);
112} 167}