summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-24 16:12:47 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-25 10:02:04 +0200
commit473661e613b068774347781bc1b5c6e6d2b62e71 (patch)
treea4210a595beb82780eb80e9d4c899d5df8f3e695
parent9b1d01fed101c558c9aebd3090266ed3a01ac85c (diff)
downloadefl-473661e613b068774347781bc1b5c6e6d2b62e71.tar.gz
efl_input_interface: test key down / key up structure
this verifies that EFL_EVENT_KEY_DOWN / EFL_EVENT_KEY_UP are emitted and passed with the correct event types, and fields on the event object.
-rw-r--r--src/lib/evas/canvas/evas_events.c2
-rw-r--r--src/tests/elementary/efl_ui_test_win.c35
2 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/evas/canvas/evas_events.c b/src/lib/evas/canvas/evas_events.c
index 8ab6bf4cd4..9d40007709 100644
--- a/src/lib/evas/canvas/evas_events.c
+++ b/src/lib/evas/canvas/evas_events.c
@@ -3462,9 +3462,11 @@ _canvas_event_feed_key_legacy(Eo *eo_e, Evas_Public_Data *e,
ev->compose = compose;
ev->timestamp = timestamp;
ev->keycode = keycode;
+ ev->pressed = down;
ev->no_stringshare = EINA_TRUE;
ev->device = efl_ref(_evas_event_legacy_device_get(e->evas, EINA_FALSE));
+
if (down)
_canvas_event_feed_key_down_internal(e, ev);
else
diff --git a/src/tests/elementary/efl_ui_test_win.c b/src/tests/elementary/efl_ui_test_win.c
index a0cc374969..67df0b21b5 100644
--- a/src/tests/elementary/efl_ui_test_win.c
+++ b/src/tests/elementary/efl_ui_test_win.c
@@ -126,6 +126,40 @@ EFL_START_TEST(efl_ui_win_test_efl_input_interface_focus)
}
EFL_END_TEST
+#define TIMESTAMP 1337
+
+static void
+_check_key_event(void *data, const Efl_Event *ev)
+{
+ Eina_Bool *pressed = data;
+
+ ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
+ ck_assert_str_eq(efl_input_key_name_get(ev->info), "odiaeresis");
+ ck_assert_str_eq(efl_input_key_get(ev->info), "ö");
+ ck_assert_str_eq(efl_input_key_string_get(ev->info), "Ö");
+ ck_assert_str_eq(efl_input_key_compose_string_get(ev->info), "Ö");
+ ck_assert_int_eq(efl_input_key_code_get(ev->info), 0xffe1);
+ *pressed = efl_input_key_pressed_get(ev->info);
+}
+
+EFL_START_TEST(efl_ui_win_test_efl_input_interface_key_down)
+{
+ Efl_Ui_Win *win;
+ Eina_Bool pressed = EINA_FALSE;
+ Efl_Canvas_Object *rect;
+ create_environment(&win, &rect);
+
+ efl_event_callback_add(rect, EFL_EVENT_KEY_DOWN , _check_key_event, &pressed);
+ efl_event_callback_add(rect, EFL_EVENT_KEY_UP, _check_key_event, &pressed);
+
+ evas_event_feed_key_down_with_keycode(evas_object_evas_get(win), "odiaeresis", "ö", "Ö", "Ö", TIMESTAMP, NULL, 0xffe1);
+ ck_assert_int_eq(pressed, EINA_TRUE);
+
+ evas_event_feed_key_up_with_keycode(evas_object_evas_get(win), "odiaeresis", "ö", "Ö", "Ö", TIMESTAMP, NULL, 0xffe1);
+ ck_assert_int_eq(pressed, EINA_FALSE);
+}
+EFL_END_TEST
+
void
efl_ui_test_win(TCase *tc)
{
@@ -133,4 +167,5 @@ efl_ui_test_win(TCase *tc)
tcase_add_test(tc, efl_ui_win_test_object_focus);
tcase_add_test(tc, efl_ui_win_test_object_focus);
tcase_add_test(tc, efl_ui_win_test_efl_input_interface_focus);
+ tcase_add_test(tc, efl_ui_win_test_efl_input_interface_key_down);
}