bu5hm4n pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=6e685e61c7ee30e13af2a2ae42bf68dfb325ab33
commit 6e685e61c7ee30e13af2a2ae42bf68dfb325ab33 Author: Mike Blumenkrantz <[email protected]> Date: Wed Jan 8 14:40:18 2020 -0500 tests/elm: add util function for dragging the pointer in an arc useful for throwing in non-linear drags Reviewed-by: Cedric BAIL <[email protected]> Differential Revision: https://phab.enlightenment.org/D11054 --- src/tests/elementary/suite_helpers.c | 28 ++++++++++++++++++++++++++++ src/tests/elementary/suite_helpers.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c index 36a4b1ae3d..49d611be1b 100644 --- a/src/tests/elementary/suite_helpers.c +++ b/src/tests/elementary/suite_helpers.c @@ -620,3 +620,31 @@ drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate) evas_event_feed_mouse_move(e, x + dx, y + dy, ts++, NULL); evas_event_feed_mouse_up(e, 1, 0, ts++, NULL); } + +int +drag_object_around(Eo *obj, int cx, int cy, int radius, int degrees) +{ + Evas *e = evas_object_evas_get(obj); + /* clamp num mouse moves to a vaguely sane value */ + int i, num = MIN(degrees, DRAG_OBJECT_AROUND_NUM_MOVES); + int last_x = round(cx + radius); + int last_y = round(cy); + /* start at 0 degrees */ + evas_event_feed_mouse_move(e, last_x, last_y, ts++, NULL); + evas_event_feed_mouse_down(e, 1, 0, ts++, NULL); + for (i = 1; i < num; i++) + { + /* x = cx + r * cos(a), y = cy + r * sin(a) */ + int ax, ay; + /* each iteration is 1 degree */ + double angle = (i * (degrees / DRAG_OBJECT_AROUND_NUM_MOVES)) * M_PI / 180.0; + ax = round(cx + radius * cos(angle)); + ay = round(cy + radius * sin(angle)); + if ((ax == last_x) && (ay == last_y)) continue; + evas_event_feed_mouse_move(e, ax, ay, ts++, NULL); + last_x = ax, last_y = ay; + } + evas_event_feed_mouse_up(e, 1, 0, ts++, NULL); + /* only count arc motion: subtract initial move, mouse down, mouse up */ + return num; +} diff --git a/src/tests/elementary/suite_helpers.h b/src/tests/elementary/suite_helpers.h index 40c8dec12b..7c9c9bbc3d 100644 --- a/src/tests/elementary/suite_helpers.h +++ b/src/tests/elementary/suite_helpers.h @@ -4,6 +4,7 @@ #include <Evas.h> #define DRAG_OBJECT_NUM_MOVES 4 +#define DRAG_OBJECT_AROUND_NUM_MOVES 60 int suite_setup(Eina_Bool legacy); void _elm2_suite_init(void); @@ -23,6 +24,7 @@ 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); +int drag_object_around(Eo *obj, int cx, int cy, int radius, int degrees); 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); --
