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)
downloadefl-946fde3acf6350e4534d388fdb337eaa9abbb1b8.tar.gz
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)
}
EFL_END_TEST
+
+static void
+prepare_window_norendered(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED)
+{
+ efl_task_end(efl_app_main_get());
+ evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, prepare_window_norendered);
+}
+
static void
create_environment(Eo **win, Eo **rect)
{
*win = efl_new(EFL_UI_WIN_CLASS);
*rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(*win));
efl_canvas_object_seat_focus_add(*rect, NULL);
+ efl_gfx_entity_geometry_set(*win, EINA_RECT(0, 0, 200, 200));
+ efl_gfx_entity_geometry_set(*rect, EINA_RECT(0, 0, 200, 200));
+ evas_event_callback_add(evas_object_evas_get(*win), EVAS_CALLBACK_RENDER_POST, prepare_window_norendered, NULL);
+ efl_loop_begin(efl_main_loop_get());
}
EFL_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)
}
EFL_END_TEST
+static void
+position_eq(Eina_Position2D a, Eina_Position2D b)
+{
+ ck_assert_int_eq(a.x, b.x);
+ ck_assert_int_eq(a.y, b.y);
+}
+
+static void
+_check_ptr_move_event(void *data, const Efl_Event *ev)
+{
+ Eina_Bool *called = data;
+ ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
+ ck_assert_int_eq(efl_input_pointer_wheel_delta_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_wheel_horizontal_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_double_click_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_triple_click_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_button_flags_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_touch_id_get(ev->info), 0);
+ position_eq(efl_input_pointer_previous_position_get(ev->info), EINA_POSITION2D(20, 20));
+ position_eq(efl_input_pointer_position_get(ev->info), EINA_POSITION2D(25, 25));
+ ck_assert_int_eq(efl_input_pointer_button_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_action_get(ev->info), EFL_POINTER_ACTION_MOVE);
+ *called = EINA_TRUE;
+}
+
+EFL_START_TEST(efl_ui_win_test_efl_input_interface_pointer_move)
+{
+ Efl_Ui_Win *win;
+ Eina_Bool called = EINA_FALSE;
+ Efl_Canvas_Object *rect;
+ create_environment(&win, &rect);
+
+ evas_event_feed_mouse_move(evas_object_evas_get(win), 20, 20, TIMESTAMP - 1, NULL);
+ efl_event_callback_add(rect, EFL_EVENT_POINTER_MOVE , _check_ptr_move_event, &called);
+ evas_event_feed_mouse_move(evas_object_evas_get(win), 25, 25, TIMESTAMP, NULL);
+ ck_assert_int_eq(called, EINA_TRUE);
+}
+EFL_END_TEST
+
+static void
+_check_ptr_down_event(void *data, const Efl_Event *ev)
+{
+ Eina_Bool *called = data;
+ ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
+ ck_assert_int_eq(efl_input_pointer_wheel_delta_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_wheel_horizontal_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_double_click_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_triple_click_get(ev->info), EINA_TRUE);
+ ck_assert_int_eq(efl_input_pointer_button_flags_get(ev->info), EVAS_BUTTON_TRIPLE_CLICK);
+ ck_assert_int_eq(efl_input_pointer_touch_id_get(ev->info), 0);
+ position_eq(efl_input_pointer_position_get(ev->info), EINA_POSITION2D(20, 20));
+ ck_assert_int_eq(efl_input_pointer_button_get(ev->info), 1);
+ ck_assert_int_eq(efl_input_pointer_action_get(ev->info), EFL_POINTER_ACTION_DOWN);
+ *called = EINA_TRUE;
+}
+
+EFL_START_TEST(efl_ui_win_test_efl_input_interface_pointer_down)
+{
+ Efl_Ui_Win *win;
+ Eina_Bool called = EINA_FALSE;
+ Efl_Canvas_Object *rect;
+ create_environment(&win, &rect);
+
+ evas_event_feed_mouse_move(evas_object_evas_get(win), 20, 20, TIMESTAMP - 1, NULL);
+ efl_event_callback_add(rect, EFL_EVENT_POINTER_DOWN , _check_ptr_down_event, &called);
+ evas_event_feed_mouse_down(evas_object_evas_get(win), 1, EVAS_BUTTON_TRIPLE_CLICK, TIMESTAMP, NULL);
+ ck_assert_int_eq(called, EINA_TRUE);
+}
+EFL_END_TEST
+
+static void
+_check_ptr_up_event(void *data, const Efl_Event *ev)
+{
+ Eina_Bool *called = data;
+ ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
+ ck_assert_int_eq(efl_input_pointer_wheel_delta_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_wheel_horizontal_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_double_click_get(ev->info), 0);
+ ck_assert_int_eq(efl_input_pointer_triple_click_get(ev->info), EINA_TRUE);
+ ck_assert_int_eq(efl_input_pointer_button_flags_get(ev->info), EVAS_BUTTON_TRIPLE_CLICK);
+ ck_assert_int_eq(efl_input_pointer_touch_id_get(ev->info), 0);
+ position_eq(efl_input_pointer_position_get(ev->info), EINA_POSITION2D(20, 20));
+ ck_assert_int_eq(efl_input_pointer_button_get(ev->info), 1);
+ ck_assert_int_eq(efl_input_pointer_action_get(ev->info), EFL_POINTER_ACTION_UP);
+ *called = EINA_TRUE;
+}
+
+EFL_START_TEST(efl_ui_win_test_efl_input_interface_pointer_up)
+{
+ Efl_Ui_Win *win;
+ Eina_Bool called = EINA_FALSE;
+ Efl_Canvas_Object *rect;
+ create_environment(&win, &rect);
+
+ evas_event_feed_mouse_move(evas_object_evas_get(win), 20, 20, TIMESTAMP - 1, NULL);
+ evas_event_feed_mouse_down(evas_object_evas_get(win), 1, EVAS_BUTTON_TRIPLE_CLICK, TIMESTAMP, NULL);
+ efl_event_callback_add(rect, EFL_EVENT_POINTER_UP , _check_ptr_up_event, &called);
+ evas_event_feed_mouse_up(evas_object_evas_get(win), 1, EVAS_BUTTON_TRIPLE_CLICK, TIMESTAMP, NULL);
+ ck_assert_int_eq(called, EINA_TRUE);
+}
+EFL_END_TEST
+
void
efl_ui_test_win(TCase *tc)
{
@@ -168,4 +282,7 @@ efl_ui_test_win(TCase *tc)
tcase_add_test(tc, efl_ui_win_test_object_focus);
tcase_add_test(tc, efl_ui_win_test_efl_input_interface_focus);
tcase_add_test(tc, efl_ui_win_test_efl_input_interface_key_down);
+ tcase_add_test(tc, efl_ui_win_test_efl_input_interface_pointer_move);
+ tcase_add_test(tc, efl_ui_win_test_efl_input_interface_pointer_down);
+ tcase_add_test(tc, efl_ui_win_test_efl_input_interface_pointer_up);
}