From db5fcd13db38115506ef1adcc4f795c14ee0d338 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 20 Feb 2020 13:24:52 -0500 Subject: [PATCH] tests/elm: add util function for doing a multi-press drag around same as existing function, but takes a finger id Differential Revision: https://phab.enlightenment.org/D11389 --- src/tests/elementary/suite_helpers.c | 26 ++++++++++++++++++++++++++ src/tests/elementary/suite_helpers.h | 1 + 2 files changed, 27 insertions(+) diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c index ea8164a642..e31e302c9f 100644 --- a/src/tests/elementary/suite_helpers.c +++ b/src/tests/elementary/suite_helpers.c @@ -754,6 +754,32 @@ drag_object_around(Eo *obj, int cx, int cy, int radius, int degrees) return num; } +int +multi_drag_object_around(Eo *obj, int touch_point, 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(abs(degrees), DRAG_OBJECT_AROUND_NUM_MOVES); + int last_x = round(cx + radius); + int last_y = round(cy); + /* start at 0 degrees */ + evas_event_feed_multi_down(e, touch_point, last_x, last_y, 1, 1, 1, 1, 0, last_x, last_y, 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_multi_move(e, touch_point, ax, ay, 1, 1, 1, 1, 0, ax, ay, ts++, NULL); + last_x = ax, last_y = ay; + } + evas_event_feed_multi_up(e, touch_point, last_x, last_y, 1, 1, 1, 1, 0, last_x, last_y, 0, ts++, NULL); + /* only count arc motion: subtract initial move, mouse down, mouse up */ + return num; +} int pinch_object(Eo *obj, int x, int y, int x2, int y2, int dx, int dy, int dx2, int dy2) diff --git a/src/tests/elementary/suite_helpers.h b/src/tests/elementary/suite_helpers.h index 1a028e5683..2a8e1d23e0 100644 --- a/src/tests/elementary/suite_helpers.h +++ b/src/tests/elementary/suite_helpers.h @@ -34,6 +34,7 @@ void multi_click_object(Eo *obj, int ids); void multi_press_object(Eo *obj, int ids); void multi_click_object_at(Eo *obj, int x, int y, int ids); void multi_press_object_at(Eo *obj, int x, int y, int ids); +int multi_drag_object_around(Eo *obj, int touch_point, int cx, int cy, int radius, int degrees); 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); int pinch_object(Eo *obj, int x, int y, int x2, int y2, int dx, int dy, int dx2, int dy2);