bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=eb12c77a7a09e2d48516fab11ba65f59d0d431b9

commit eb12c77a7a09e2d48516fab11ba65f59d0d431b9
Author: Mike Blumenkrantz <zm...@samsung.com>
Date:   Thu Oct 24 11:37:32 2019 -0400

    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 <cedric.b...@free.fr>
    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 0840f13da7..67aac9ddbc 100644
--- a/src/tests/elementary/suite_helpers.c
+++ b/src/tests/elementary/suite_helpers.c
@@ -573,3 +573,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 <Evas.h>
 
+#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);

-- 


Reply via email to