forked from enlightenment/efl
tests/gesture: add custom recognizer test
adds a very small implementation of a custom recognizer, registers it, verifies events are processing as they should, then removes it Differential Revision: https://phab.enlightenment.org/D11224
This commit is contained in:
parent
ca2cc5915d
commit
6cc4fee1a4
|
@ -0,0 +1,44 @@
|
|||
#include <Efl_Ui.h>
|
||||
#include "custom_recognizer.eo.h"
|
||||
#define MY_CLASS CUSTOM_RECOGNIZER_CLASS
|
||||
|
||||
typedef struct Custom_Recognizer_Data
|
||||
{
|
||||
|
||||
} Custom_Recognizer_Data;
|
||||
|
||||
EOLIAN static Eo *
|
||||
_custom_recognizer_efl_object_finalize(Eo *obj, Custom_Recognizer_Data *pd EINA_UNUSED)
|
||||
{
|
||||
efl_gesture_recognizer_custom_gesture_name_set(obj, "custom_gesture");
|
||||
return efl_finalize(efl_super(obj, MY_CLASS));
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Canvas_Gesture *
|
||||
_custom_recognizer_efl_canvas_gesture_recognizer_add(Eo *obj, Custom_Recognizer_Data *pd EINA_UNUSED, Efl_Object *target EINA_UNUSED)
|
||||
{
|
||||
return efl_add(EFL_CANVAS_GESTURE_CUSTOM_CLASS, obj);
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
|
||||
_custom_recognizer_efl_canvas_gesture_recognizer_recognize(Eo *obj EINA_UNUSED, Custom_Recognizer_Data *pd EINA_UNUSED,
|
||||
Efl_Canvas_Gesture *gesture EINA_UNUSED, Efl_Object *watched EINA_UNUSED,
|
||||
Efl_Canvas_Gesture_Touch *event)
|
||||
{
|
||||
switch (efl_gesture_touch_state_get(event))
|
||||
{
|
||||
case EFL_GESTURE_TOUCH_STATE_BEGIN:
|
||||
return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
|
||||
case EFL_GESTURE_TOUCH_STATE_UPDATE:
|
||||
return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
|
||||
case EFL_GESTURE_TOUCH_STATE_END:
|
||||
return EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
||||
}
|
||||
|
||||
#include "custom_recognizer.eo.c"
|
|
@ -0,0 +1,11 @@
|
|||
class @beta Custom_Recognizer extends Efl.Canvas.Gesture_Recognizer_Custom
|
||||
{
|
||||
[[Custom gesture recognizer test class.
|
||||
]]
|
||||
c_prefix: custom_recognizer;
|
||||
implements {
|
||||
Efl.Object.finalize;
|
||||
Efl.Canvas.Gesture_Recognizer.add;
|
||||
Efl.Canvas.Gesture_Recognizer.recognize;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,8 @@
|
|||
#include <Evas_Legacy.h>
|
||||
#include <evas_canvas_eo.h>
|
||||
|
||||
#include "custom_recognizer.eo.h"
|
||||
|
||||
/*
|
||||
typedef enum
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ enum
|
|||
MOMENTUM,
|
||||
FLICK,
|
||||
ZOOM,
|
||||
CUSTOM,
|
||||
LAST
|
||||
};
|
||||
|
||||
|
@ -506,10 +509,37 @@ EFL_START_TEST(test_efl_ui_gesture_zoom)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static void
|
||||
custom_cb(void *data EINA_UNUSED , const Efl_Event *ev)
|
||||
{
|
||||
Efl_Canvas_Gesture *g = ev->info;
|
||||
|
||||
ck_assert_str_eq(efl_gesture_custom_gesture_name_get(g), "custom_gesture");
|
||||
int *count = data;
|
||||
/* increment counter for event state which has been processed */
|
||||
count[efl_gesture_state_get(g) - 1]++;
|
||||
}
|
||||
|
||||
EFL_START_TEST(test_efl_ui_gesture_custom)
|
||||
{
|
||||
Eo *rect = setup();
|
||||
Eo *manager = efl_provider_find(rect, EFL_CANVAS_GESTURE_MANAGER_CLASS);
|
||||
Eo *recognizer = efl_add(CUSTOM_RECOGNIZER_CLASS, manager);
|
||||
efl_gesture_manager_recognizer_register(manager, recognizer);
|
||||
|
||||
efl_event_callback_add(rect, EFL_EVENT_GESTURE_CUSTOM, custom_cb, &count[CUSTOM]);
|
||||
click_object(rect);
|
||||
CHECK_ALL(CUSTOM, 1, 0, 1, 0);
|
||||
efl_event_callback_del(rect, EFL_EVENT_GESTURE_CUSTOM, custom_cb, &count[CUSTOM]);
|
||||
efl_gesture_manager_recognizer_unregister(manager, recognizer);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void efl_ui_test_gesture(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, test_efl_ui_gesture_taps);
|
||||
tcase_add_test(tc, test_efl_ui_gesture_long_tap);
|
||||
tcase_add_test(tc, test_efl_ui_gesture_flick);
|
||||
tcase_add_test(tc, test_efl_ui_gesture_zoom);
|
||||
tcase_add_test(tc, test_efl_ui_gesture_custom);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
priv_eo_files = [
|
||||
'custom_recognizer.eo',
|
||||
'focus_test.eo',
|
||||
'focus_test_sub_main.eo',
|
||||
'focus_manager_test.eo'
|
||||
|
@ -162,6 +163,7 @@ efl_ui_suite_src = [
|
|||
'efl_ui_test_group_item.c',
|
||||
'efl_ui_test_text.c',
|
||||
'efl_ui_test_vg_animation.c',
|
||||
'custom_recognizer.c',
|
||||
]
|
||||
|
||||
efl_ui_suite = executable('efl_ui_suite',
|
||||
|
|
Loading…
Reference in New Issue