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)
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,
3462 ev->compose = compose; 3462 ev->compose = compose;
3463 ev->timestamp = timestamp; 3463 ev->timestamp = timestamp;
3464 ev->keycode = keycode; 3464 ev->keycode = keycode;
3465 ev->pressed = down;
3465 ev->no_stringshare = EINA_TRUE; 3466 ev->no_stringshare = EINA_TRUE;
3466 ev->device = efl_ref(_evas_event_legacy_device_get(e->evas, EINA_FALSE)); 3467 ev->device = efl_ref(_evas_event_legacy_device_get(e->evas, EINA_FALSE));
3467 3468
3469
3468 if (down) 3470 if (down)
3469 _canvas_event_feed_key_down_internal(e, ev); 3471 _canvas_event_feed_key_down_internal(e, ev);
3470 else 3472 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)
126} 126}
127EFL_END_TEST 127EFL_END_TEST
128 128
129#define TIMESTAMP 1337
130
131static void
132_check_key_event(void *data, const Efl_Event *ev)
133{
134 Eina_Bool *pressed = data;
135
136 ck_assert_int_eq(efl_input_timestamp_get(ev->info), TIMESTAMP);
137 ck_assert_str_eq(efl_input_key_name_get(ev->info), "odiaeresis");
138 ck_assert_str_eq(efl_input_key_get(ev->info), "ö");
139 ck_assert_str_eq(efl_input_key_string_get(ev->info), "Ö");
140 ck_assert_str_eq(efl_input_key_compose_string_get(ev->info), "Ö");
141 ck_assert_int_eq(efl_input_key_code_get(ev->info), 0xffe1);
142 *pressed = efl_input_key_pressed_get(ev->info);
143}
144
145EFL_START_TEST(efl_ui_win_test_efl_input_interface_key_down)
146{
147 Efl_Ui_Win *win;
148 Eina_Bool pressed = EINA_FALSE;
149 Efl_Canvas_Object *rect;
150 create_environment(&win, &rect);
151
152 efl_event_callback_add(rect, EFL_EVENT_KEY_DOWN , _check_key_event, &pressed);
153 efl_event_callback_add(rect, EFL_EVENT_KEY_UP, _check_key_event, &pressed);
154
155 evas_event_feed_key_down_with_keycode(evas_object_evas_get(win), "odiaeresis", "ö", "Ö", "Ö", TIMESTAMP, NULL, 0xffe1);
156 ck_assert_int_eq(pressed, EINA_TRUE);
157
158 evas_event_feed_key_up_with_keycode(evas_object_evas_get(win), "odiaeresis", "ö", "Ö", "Ö", TIMESTAMP, NULL, 0xffe1);
159 ck_assert_int_eq(pressed, EINA_FALSE);
160}
161EFL_END_TEST
162
129void 163void
130efl_ui_test_win(TCase *tc) 164efl_ui_test_win(TCase *tc)
131{ 165{
@@ -133,4 +167,5 @@ efl_ui_test_win(TCase *tc)
133 tcase_add_test(tc, efl_ui_win_test_object_focus); 167 tcase_add_test(tc, efl_ui_win_test_object_focus);
134 tcase_add_test(tc, efl_ui_win_test_object_focus); 168 tcase_add_test(tc, efl_ui_win_test_object_focus);
135 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_focus); 169 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_focus);
170 tcase_add_test(tc, efl_ui_win_test_efl_input_interface_key_down);
136} 171}