From 25ab4dbc1114b76c16e0a2f541426e2419de1c49 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 24 Oct 2019 11:37:32 -0400 Subject: [PATCH] tests/elm: add utility function to trigger a mouse drag a drag may require a lot of internal calculating to successfully trigger the intended test behavior, so this has a flag which allows it to perform loop iterations and canvas calcs in order to be more universal, along with a global #define for determining exactly how many mouse moves were triggered Reviewed-by: Cedric BAIL Differential Revision: https://phab.enlightenment.org/D10512 --- src/tests/elementary/suite_helpers.c | 24 ++++++++++++++++++++++++ src/tests/elementary/suite_helpers.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c index 5c5471a6b8..bbbf2e2043 100644 --- a/src/tests/elementary/suite_helpers.c +++ b/src/tests/elementary/suite_helpers.c @@ -564,3 +564,27 @@ wheel_object_at(Eo *obj, int x, int y, Eina_Bool horiz, Eina_Bool down) evas_event_feed_mouse_move(e, x, y, 0, NULL); evas_event_feed_mouse_wheel(e, horiz, down, 0, NULL); } + +void +drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate) +{ + Evas *e = evas_object_evas_get(obj); + int i; + evas_event_feed_mouse_move(e, x, y, 0, NULL); + evas_event_feed_mouse_down(e, 1, 0, 0, NULL); + if (iterate) + { + /* iterate twice to trigger timers */ + ecore_main_loop_iterate(); + ecore_main_loop_iterate(); + } + /* create DRAG_OBJECT_NUM_MOVES move events distinct from up/down */ + for (i = 0; i < DRAG_OBJECT_NUM_MOVES; i++) + { + evas_event_feed_mouse_move(e, x + (i * dx / DRAG_OBJECT_NUM_MOVES), y + (i * dy / DRAG_OBJECT_NUM_MOVES), 0, NULL); + /* also trigger smart calc if we're iterating just in case that's important */ + evas_smart_objects_calculate(e); + } + evas_event_feed_mouse_move(e, x + dx, y + dy, 0, NULL); + evas_event_feed_mouse_up(e, 1, 0, 0, NULL); +} diff --git a/src/tests/elementary/suite_helpers.h b/src/tests/elementary/suite_helpers.h index e3b1758e37..34660a6424 100644 --- a/src/tests/elementary/suite_helpers.h +++ b/src/tests/elementary/suite_helpers.h @@ -3,6 +3,8 @@ #include +#define DRAG_OBJECT_NUM_MOVES 4 + int suite_setup(Eina_Bool legacy); void _elm2_suite_init(void); void _elm_suite_shutdown(void); @@ -17,6 +19,7 @@ void click_part(Eo *obj, const char *part); void click_part_flags(Eo *obj, const char *part, int flags); void click_object_at(Eo *obj, int x, int y); void click_object_at_flags(Eo *obj, int x, int y, int flags); +void drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate); void wheel_object(Eo *obj, Eina_Bool horiz, Eina_Bool down); void wheel_part(Eo *obj, const char *part, Eina_Bool horiz, Eina_Bool down); void wheel_object_at(Eo *obj, int x, int y, Eina_Bool horiz, Eina_Bool down);