summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-24 17:47:31 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-25 10:02:38 +0200
commit946fde3acf6350e4534d388fdb337eaa9abbb1b8 (patch)
tree3ac6bf80d1e67294af4e483dfea41cb2bb7db294
parent473661e613b068774347781bc1b5c6e6d2b62e71 (diff)
efl_input_interface: test pointer move down up
this verifies that EFL_EVENT_POINTER_MOVE / EFL_EVENT_POINTER_DOWN / EFL_EVENT_POINTER_UP are emitted and passed with the correct event types, and fields on the event object.
-rw-r--r--src/tests/elementary/efl_ui_test_win.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_win.c b/src/tests/elementary/efl_ui_test_win.c
index 67df0b21b5..fb4728222f 100644
--- a/src/tests/elementary/efl_ui_test_win.c
+++ b/src/tests/elementary/efl_ui_test_win.c
@@ -94,12 +94,24 @@ EFL_START_TEST(efl_ui_win_test_object_focus)
94} 94}
95EFL_END_TEST 95EFL_END_TEST
96 96
97
98static void
99prepare_window_norendered(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED)
100{
101 efl_task_end(efl_app_main_get());
102 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, prepare_window_norendered);
103}
104
97static void 105static void
98create_environment(Eo **win, Eo **rect) 106create_environment(Eo **win, Eo **rect)
99{ 107{
100 *win = efl_new(EFL_UI_WIN_CLASS); 108 *win = efl_new(EFL_UI_WIN_CLASS);
101 *rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(*win)); 109 *rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(*win));
102 efl_canvas_object_seat_focus_add(*rect, NULL); 110 efl_canvas_object_seat_focus_add(*rect, NULL);
111 efl_gfx_entity_geometry_set(*win, EINA_RECT(0, 0, 200, 200));
112 efl_gfx_entity_geometry_set(*rect, EINA_RECT(0, 0, 200, 200));
113 evas_event_callback_add(evas_object_evas_get(*win), EVAS_CALLBACK_RENDER_POST, prepare_window_norendered, NULL);
114 efl_loop_begin(efl_main_loop_get());
103} 115}
104 116
105EFL_START_TEST(efl_ui_win_test_efl_input_interface_focus) 117EFL_START_TEST(efl_ui_win_test_efl_input_interface_focus)
@@ -160,6 +172,108 @@ EFL_START_TEST(efl_ui_win_test_efl_input_interface_key_down)
160} 172}
161EFL_END_TEST 173EFL_END_TEST
162 174
175static void
176position_eq(Eina_Position2D a, Eina_Position2D b)
177{
178 ck_assert_int_eq(a.x, b.x);
179 ck_assert_int_eq(a.y, b.y);
180}
181
182static void
183_check_ptr_move_event(void *data, const Efl_Event *ev)
184{
185 Eina_Bool *called = data;
186 ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
187 ck_assert_int_eq(efl_input_pointer_wheel_delta_get(ev->info), 0);
188 ck_assert_int_eq(efl_input_pointer_wheel_horizontal_get(ev->info), 0);
189 ck_assert_int_eq(efl_input_pointer_double_click_get(ev->info), 0);
190 ck_assert_int_eq(efl_input_pointer_triple_click_get(ev->info), 0);
191 ck_assert_int_eq(efl_input_pointer_button_flags_get(ev->info), 0);
192 ck_assert_int_eq(efl_input_pointer_touch_id_get(ev->info), 0);
193 position_eq(efl_input_pointer_previous_position_get(ev->info), EINA_POSITION2D(20, 20));
194 position_eq(efl_input_pointer_position_get(ev->info), EINA_POSITION2D(25, 25));
195 ck_assert_int_eq(efl_input_pointer_button_get(ev->info), 0);
196 ck_assert_int_eq(efl_input_pointer_action_get(ev->info), EFL_POINTER_ACTION_MOVE);
197 *called = EINA_TRUE;
198}
199
200EFL_START_TEST(efl_ui_win_test_efl_input_interface_pointer_move)
201{
202 Efl_Ui_Win *win;
203 Eina_Bool called = EINA_FALSE;
204 Efl_Canvas_Object *rect;
205 create_environment(&win, &rect);
206
207 evas_event_feed_mouse_move(evas_object_evas_get(win), 20, 20, TIMESTAMP - 1, NULL);
208 efl_event_callback_add(rect, EFL_EVENT_POINTER_MOVE , _check_ptr_move_event, &called);
209 evas_event_feed_mouse_move(evas_object_evas_get(win), 25, 25, TIMESTAMP, NULL);
210 ck_assert_int_eq(called, EINA_TRUE);
211}
212EFL_END_TEST
213
214static void
215_check_ptr_down_event(void *data, const Efl_Event *ev)
216{
217 Eina_Bool *called = data;
218 ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
219 ck_assert_int_eq(efl_input_pointer_wheel_delta_get(ev->info), 0);
220 ck_assert_int_eq(efl_input_pointer_wheel_horizontal_get(ev->info), 0);
221 ck_assert_int_eq(efl_input_pointer_double_click_get(ev->info), 0);
222 ck_assert_int_eq(efl_input_pointer_triple_click_get(ev->info), EINA_TRUE);
223 ck_assert_int_eq(efl_input_pointer_button_flags_get(ev->info), EVAS_BUTTON_TRIPLE_CLICK);
224 ck_assert_int_eq(efl_input_pointer_touch_id_get(ev->info), 0);
225 position_eq(efl_input_pointer_position_get(ev->info), EINA_POSITION2D(20, 20));
226 ck_assert_int_eq(efl_input_pointer_button_get(ev->info), 1);
227 ck_assert_int_eq(efl_input_pointer_action_get(ev->info), EFL_POINTER_ACTION_DOWN);
228 *called = EINA_TRUE;
229}
230
231EFL_START_TEST(efl_ui_win_test_efl_input_interface_pointer_down)
232{
233 Efl_Ui_Win *win;
234 Eina_Bool called = EINA_FALSE;
235 Efl_Canvas_Object *rect;
236 create_environment(&win, &rect);
237
238 evas_event_feed_mouse_move(evas_object_evas_get(win), 20, 20, TIMESTAMP - 1, NULL);
239 efl_event_callback_add(rect, EFL_EVENT_POINTER_DOWN , _check_ptr_down_event, &called);
240 evas_event_feed_mouse_down(evas_object_evas_get(win), 1, EVAS_BUTTON_TRIPLE_CLICK, TIMESTAMP, NULL);
241 ck_assert_int_eq(called, EINA_TRUE);
242}
243EFL_END_TEST
244
245static void
246_check_ptr_up_event(void *data, const Efl_Event *ev)
247{
248 Eina_Bool *called = data;
249 ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
250 ck_assert_int_eq(efl_input_pointer_wheel_delta_get(ev->info), 0);
251 ck_assert_int_eq(efl_input_pointer_wheel_horizontal_get(ev->info), 0);
252 ck_assert_int_eq(efl_input_pointer_double_click_get(ev->info), 0);
253 ck_assert_int_eq(efl_input_pointer_triple_click_get(ev->info), EINA_TRUE);
254 ck_assert_int_eq(efl_input_pointer_button_flags_get(ev->info), EVAS_BUTTON_TRIPLE_CLICK);
255 ck_assert_int_eq(efl_input_pointer_touch_id_get(ev->info), 0);
256 position_eq(efl_input_pointer_position_get(ev->info), EINA_POSITION2D(20, 20));
257 ck_assert_int_eq(efl_input_pointer_button_get(ev->info), 1);
258 ck_assert_int_eq(efl_input_pointer_action_get(ev->info), EFL_POINTER_ACTION_UP);
259 *called = EINA_TRUE;
260}
261
262EFL_START_TEST(efl_ui_win_test_efl_input_interface_pointer_up)
263{
264 Efl_Ui_Win *win;
265 Eina_Bool called = EINA_FALSE;
266 Efl_Canvas_Object *rect;
267 create_environment(&win, &rect);
268
269 evas_event_feed_mouse_move(evas_object_evas_get(win), 20, 20, TIMESTAMP - 1, NULL);
270 evas_event_feed_mouse_down(evas_object_evas_get(win), 1, EVAS_BUTTON_TRIPLE_CLICK, TIMESTAMP, NULL);
271 efl_event_callback_add(rect, EFL_EVENT_POINTER_UP , _check_ptr_up_event, &called);
272 evas_event_feed_mouse_up(evas_object_evas_get(win), 1, EVAS_BUTTON_TRIPLE_CLICK, TIMESTAMP, NULL);
273 ck_assert_int_eq(called, EINA_TRUE);
274}
275EFL_END_TEST
276
163void 277void
164efl_ui_test_win(TCase *tc) 278efl_ui_test_win(TCase *tc)
165{ 279{
@@ -168,4 +282,7 @@ efl_ui_test_win(TCase *tc)
168 tcase_add_test(tc, efl_ui_win_test_object_focus); 282 tcase_add_test(tc, efl_ui_win_test_object_focus);
169 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_focus); 283 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_focus);
170 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_key_down); 284 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_key_down);
285 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_pointer_move);
286 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_pointer_down);
287 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_pointer_up);
171} 288}