summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-02-14 08:50:13 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-03 10:54:17 +0100
commitd481cbe83c3c57883d32fc96ff3121f07025ab84 (patch)
treecf8221c3c3d6fd26c56ee0b55cd79be09be9d318
parent76cc9488dd13aedf637c01b1bd8adddbe0a17d81 (diff)
tests/gesture: add custom gesture to custom recognizer test
this adds a simple custom gesture implementation with basic motion accumulator properties to verify (and give an example of) the custom gesture capability that can be used by apps alongside custom recognizers Differential Revision: https://phab.enlightenment.org/D11352
-rw-r--r--src/tests/elementary/custom_gesture.c19
-rw-r--r--src/tests/elementary/custom_gesture.eo26
-rw-r--r--src/tests/elementary/custom_gesture.h16
-rw-r--r--src/tests/elementary/custom_recognizer.c20
-rw-r--r--src/tests/elementary/custom_recognizer.eo1
-rw-r--r--src/tests/elementary/efl_ui_test_gesture.c22
-rw-r--r--src/tests/elementary/meson.build2
7 files changed, 105 insertions, 1 deletions
diff --git a/src/tests/elementary/custom_gesture.c b/src/tests/elementary/custom_gesture.c
new file mode 100644
index 0000000000..629f68bcd5
--- /dev/null
+++ b/src/tests/elementary/custom_gesture.c
@@ -0,0 +1,19 @@
1#include <Efl_Ui.h>
2#include "custom_gesture.eo.h"
3#include "custom_gesture.h"
4#define MY_CLASS CUSTOM_GESTURE_CLASS
5
6
7EOLIAN static int
8_custom_gesture_x_delta_get(const Eo *obj EINA_UNUSED, Custom_Gesture_Data *pd)
9{
10 return pd->x_delta;
11}
12
13EOLIAN static int
14_custom_gesture_y_delta_get(const Eo *obj EINA_UNUSED, Custom_Gesture_Data *pd)
15{
16 return pd->y_delta;
17}
18
19#include "custom_gesture.eo.c"
diff --git a/src/tests/elementary/custom_gesture.eo b/src/tests/elementary/custom_gesture.eo
new file mode 100644
index 0000000000..7a6266db93
--- /dev/null
+++ b/src/tests/elementary/custom_gesture.eo
@@ -0,0 +1,26 @@
1import eina_types;
2parse efl_canvas_gesture_recognizer;
3
4class @beta Custom_Gesture extends Efl.Canvas.Gesture_Custom
5{
6 [[This is a test class for custom gesture implementations.
7 ]]
8 methods {
9 @property x_delta {
10 [[This is the total change in the X coordinate.]]
11 get {
12 }
13 values {
14 val: int; [[The change since the start of the gesture.]]
15 }
16 }
17 @property y_delta {
18 [[This is the total change in the Y coordinate.]]
19 get {
20 }
21 values {
22 val: int; [[The change since the start of the gesture.]]
23 }
24 }
25 }
26}
diff --git a/src/tests/elementary/custom_gesture.h b/src/tests/elementary/custom_gesture.h
new file mode 100644
index 0000000000..fa12b68593
--- /dev/null
+++ b/src/tests/elementary/custom_gesture.h
@@ -0,0 +1,16 @@
1#ifndef CUSTOM_GESTURE_H
2# define CUSTOM_GESTURE_H
3
4
5typedef struct Custom_Gesture_Data
6{
7 int x_delta;
8 int y_delta;
9} Custom_Gesture_Data;
10
11
12
13
14
15
16#endif
diff --git a/src/tests/elementary/custom_recognizer.c b/src/tests/elementary/custom_recognizer.c
index 5e4c89c791..4797b9530e 100644
--- a/src/tests/elementary/custom_recognizer.c
+++ b/src/tests/elementary/custom_recognizer.c
@@ -1,5 +1,8 @@
1#include <Efl_Ui.h> 1#include <Efl_Ui.h>
2#include "custom_recognizer.eo.h" 2#include "custom_recognizer.eo.h"
3#include "custom_gesture.eo.h"
4#include "custom_gesture.h"
5
3#define MY_CLASS CUSTOM_RECOGNIZER_CLASS 6#define MY_CLASS CUSTOM_RECOGNIZER_CLASS
4 7
5typedef struct Custom_Recognizer_Data 8typedef struct Custom_Recognizer_Data
@@ -7,6 +10,12 @@ typedef struct Custom_Recognizer_Data
7 10
8} Custom_Recognizer_Data; 11} Custom_Recognizer_Data;
9 12
13EOLIAN static const Efl_Class *
14_custom_recognizer_efl_canvas_gesture_recognizer_type_get(const Eo *obj EINA_UNUSED, Custom_Recognizer_Data *pd EINA_UNUSED)
15{
16 return CUSTOM_GESTURE_CLASS;
17}
18
10EOLIAN static Eo * 19EOLIAN static Eo *
11_custom_recognizer_efl_object_finalize(Eo *obj, Custom_Recognizer_Data *pd EINA_UNUSED) 20_custom_recognizer_efl_object_finalize(Eo *obj, Custom_Recognizer_Data *pd EINA_UNUSED)
12{ 21{
@@ -16,14 +25,23 @@ _custom_recognizer_efl_object_finalize(Eo *obj, Custom_Recognizer_Data *pd EINA_
16 25
17EOLIAN static Efl_Canvas_Gesture_Recognizer_Result 26EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
18_custom_recognizer_efl_canvas_gesture_recognizer_recognize(Eo *obj EINA_UNUSED, Custom_Recognizer_Data *pd EINA_UNUSED, 27_custom_recognizer_efl_canvas_gesture_recognizer_recognize(Eo *obj EINA_UNUSED, Custom_Recognizer_Data *pd EINA_UNUSED,
19 Efl_Canvas_Gesture *gesture EINA_UNUSED, Efl_Object *watched EINA_UNUSED, 28 Efl_Canvas_Gesture *gesture, Efl_Object *watched EINA_UNUSED,
20 Efl_Canvas_Gesture_Touch *event) 29 Efl_Canvas_Gesture_Touch *event)
21{ 30{
31 const Efl_Gesture_Touch_Point_Data *data = efl_gesture_touch_current_data_get(event);
32 Custom_Gesture_Data *gd;
33
34 /* ignore multi-touch */
35 if (data->id) return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
36
22 switch (efl_gesture_touch_state_get(event)) 37 switch (efl_gesture_touch_state_get(event))
23 { 38 {
24 case EFL_GESTURE_TOUCH_STATE_BEGIN: 39 case EFL_GESTURE_TOUCH_STATE_BEGIN:
25 return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER; 40 return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
26 case EFL_GESTURE_TOUCH_STATE_UPDATE: 41 case EFL_GESTURE_TOUCH_STATE_UPDATE:
42 gd = efl_data_scope_get(gesture, CUSTOM_GESTURE_CLASS);
43 gd->x_delta += data->cur.pos.x - data->prev.pos.x;
44 gd->y_delta += data->cur.pos.y - data->prev.pos.y;
27 return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER; 45 return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
28 case EFL_GESTURE_TOUCH_STATE_END: 46 case EFL_GESTURE_TOUCH_STATE_END:
29 return EFL_GESTURE_RECOGNIZER_RESULT_FINISH; 47 return EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
diff --git a/src/tests/elementary/custom_recognizer.eo b/src/tests/elementary/custom_recognizer.eo
index 7c6ab18d41..bbe4c0cfc6 100644
--- a/src/tests/elementary/custom_recognizer.eo
+++ b/src/tests/elementary/custom_recognizer.eo
@@ -6,5 +6,6 @@ class @beta Custom_Recognizer extends Efl.Canvas.Gesture_Recognizer_Custom
6 implements { 6 implements {
7 Efl.Object.finalize; 7 Efl.Object.finalize;
8 Efl.Canvas.Gesture_Recognizer.recognize; 8 Efl.Canvas.Gesture_Recognizer.recognize;
9 Efl.Canvas.Gesture_Recognizer.type { get; }
9 } 10 }
10} 11}
diff --git a/src/tests/elementary/efl_ui_test_gesture.c b/src/tests/elementary/efl_ui_test_gesture.c
index f47e4f3977..0f7d270853 100644
--- a/src/tests/elementary/efl_ui_test_gesture.c
+++ b/src/tests/elementary/efl_ui_test_gesture.c
@@ -8,6 +8,7 @@
8#include <Evas_Legacy.h> 8#include <Evas_Legacy.h>
9#include <evas_canvas_eo.h> 9#include <evas_canvas_eo.h>
10 10
11#include "custom_gesture.eo.h"
11#include "custom_recognizer.eo.h" 12#include "custom_recognizer.eo.h"
12#include "custom_recognizer2.eo.h" 13#include "custom_recognizer2.eo.h"
13 14
@@ -549,12 +550,24 @@ custom_cb2(void *data EINA_UNUSED , const Efl_Event *ev)
549 count[efl_gesture_state_get(g) - 1]++; 550 count[efl_gesture_state_get(g) - 1]++;
550} 551}
551 552
553static void
554custom_gesture_cb(void *data EINA_UNUSED , const Efl_Event *ev)
555{
556 Efl_Canvas_Gesture *g = ev->info;
557
558 Eina_Position2D *delta = data;
559 if (!eina_streq(efl_gesture_custom_gesture_name_get(g), "custom_gesture")) return;
560 delta->x = custom_gesture_x_delta_get(g);
561 delta->y = custom_gesture_y_delta_get(g);
562}
563
552EFL_START_TEST(test_efl_ui_gesture_custom) 564EFL_START_TEST(test_efl_ui_gesture_custom)
553{ 565{
554 Eo *rect = setup(); 566 Eo *rect = setup();
555 Eo *manager = efl_provider_find(rect, EFL_CANVAS_GESTURE_MANAGER_CLASS); 567 Eo *manager = efl_provider_find(rect, EFL_CANVAS_GESTURE_MANAGER_CLASS);
556 Eo *recognizer = efl_add(CUSTOM_RECOGNIZER_CLASS, manager); 568 Eo *recognizer = efl_add(CUSTOM_RECOGNIZER_CLASS, manager);
557 Eo *recognizer2 = efl_add(CUSTOM_RECOGNIZER2_CLASS, manager); 569 Eo *recognizer2 = efl_add(CUSTOM_RECOGNIZER2_CLASS, manager);
570 Eina_Position2D delta = {0};
558 571
559 efl_gesture_manager_recognizer_register(manager, recognizer); 572 efl_gesture_manager_recognizer_register(manager, recognizer);
560 efl_gesture_manager_recognizer_register(manager, recognizer2); 573 efl_gesture_manager_recognizer_register(manager, recognizer2);
@@ -568,6 +581,15 @@ EFL_START_TEST(test_efl_ui_gesture_custom)
568 581
569 RESET; 582 RESET;
570 583
584 /* verify gesture properties */
585 efl_event_callback_add(rect, EFL_EVENT_GESTURE_CUSTOM, custom_gesture_cb, &delta);
586 drag_object(rect, 0, 0, 75, 30, EINA_FALSE);
587 ck_assert_int_eq(delta.x, 75);
588 ck_assert_int_eq(delta.y, 30);
589 efl_event_callback_del(rect, EFL_EVENT_GESTURE_CUSTOM, custom_gesture_cb, &delta);
590
591 RESET;
592
571 /* verify that we aren't still processing */ 593 /* verify that we aren't still processing */
572 efl_gesture_manager_recognizer_unregister(manager, recognizer); 594 efl_gesture_manager_recognizer_unregister(manager, recognizer);
573 efl_gesture_manager_recognizer_unregister(manager, recognizer2); 595 efl_gesture_manager_recognizer_unregister(manager, recognizer2);
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index 10534277b4..7f5fd03733 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -1,4 +1,5 @@
1priv_eo_files = [ 1priv_eo_files = [
2 'custom_gesture.eo',
2 'custom_recognizer.eo', 3 'custom_recognizer.eo',
3 'custom_recognizer2.eo', 4 'custom_recognizer2.eo',
4 'focus_test.eo', 5 'focus_test.eo',
@@ -164,6 +165,7 @@ efl_ui_suite_src = [
164 'efl_ui_test_group_item.c', 165 'efl_ui_test_group_item.c',
165 'efl_ui_test_text.c', 166 'efl_ui_test_text.c',
166 'efl_ui_test_vg_animation.c', 167 'efl_ui_test_vg_animation.c',
168 'custom_gesture.c',
167 'custom_recognizer.c', 169 'custom_recognizer.c',
168 'custom_recognizer2.c', 170 'custom_recognizer2.c',
169] 171]