1 #include "e_test_event.h"
2 #include "e_test_base.h"
5 class etTestInput : public ::etTCBase
12 etWin *tw_shared = NULL;
13 etWin *tw_topposition = NULL;
14 etWin *tw_orexcl = NULL;
15 etWin *tw_excl = NULL;
18 TEST_F(etTestInput, keygrab_nowin_shared)
20 Eina_Bool ret = EINA_FALSE;
21 ret = ecore_wl2_window_keygrab_set(NULL, "XF86Menu", 0, 0, 0, ECORE_WL2_WINDOW_KEYGRAB_SHARED);
24 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
25 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_ECORE_KEY);
28 eina_stringshare_del(etRunner::get().ev.key.name);
29 etRunner::get().ev.key.name = NULL;
31 ret = ecore_wl2_window_keygrab_unset(NULL, "XF86Menu", 0, 0);
35 TEST_F(etTestInput, keygrab_nowin_orexcl)
37 Eina_Bool ret = EINA_FALSE;
38 ret = ecore_wl2_window_keygrab_set(NULL, "XF86Menu", 0, 0, 0, ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE);
41 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
42 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_ECORE_KEY);
45 eina_stringshare_del(etRunner::get().ev.key.name);
46 etRunner::get().ev.key.name = NULL;
48 ret = ecore_wl2_window_keygrab_unset(NULL, "XF86Menu", 0, 0);
52 TEST_F(etTestInput, keygrab_nowin_excl)
54 Eina_Bool ret = EINA_FALSE;
55 ret = ecore_wl2_window_keygrab_set(NULL, "XF86Menu", 0, 0, 0, ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE);
58 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
59 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_ECORE_KEY);
62 eina_stringshare_del(etRunner::get().ev.key.name);
63 etRunner::get().ev.key.name = NULL;
65 ret = ecore_wl2_window_keygrab_unset(NULL, "XF86Menu", 0, 0);
69 TEST_F(etTestInput, keygrab_win_shared)
71 Eina_Bool ret = EINA_FALSE;
73 tw_shared = initNormalWin("TCWin_SharedGrab", EINA_TRUE, EINA_FALSE);
74 ASSERT_TRUE(tw_shared != NULL) << "failed to initiation window";
76 ret = elm_win_keygrab_set(tw_shared->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_SHARED);
78 ret = evas_object_key_grab(tw_shared->elm_win, "XF86Menu", 0, 0, EINA_FALSE);
81 etRunner::get().ev.win = tw_shared->elm_win;
82 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
83 ret = etRunner::get().setWinStack(tw_shared, NULL, EINA_FALSE);
84 etRunner::get().waitEvent(E_TC_EVENT_TYPE_FOCUS_CHANGED);
87 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
90 eina_stringshare_del(etRunner::get().ev.key.name);
91 etRunner::get().ev.key.name = NULL;
92 etRunner::get().ev.win = NULL;
94 evas_object_key_ungrab(tw_shared->elm_win, "XF86Menu", 0, 0);
95 ret = elm_win_keygrab_unset(tw_shared->elm_win, "XF86Menu", 0, 0);
99 TEST_F(etTestInput, keygrab_win_orexcl)
101 Eina_Bool ret = EINA_FALSE;
103 tw_orexcl = initNormalWin("TCWin_OrexclGrab", EINA_TRUE, EINA_FALSE);
104 ASSERT_TRUE(tw_orexcl != NULL) << "failed to initiation window";
106 ret = elm_win_keygrab_set(tw_orexcl->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE);
108 ret = evas_object_key_grab(tw_orexcl->elm_win, "XF86Menu", 0, 0, EINA_TRUE);
111 etRunner::get().ev.win = tw_orexcl->elm_win;
112 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
113 ret = etRunner::get().setWinStack(tw_orexcl, NULL, EINA_FALSE);
114 etRunner::get().waitEvent(E_TC_EVENT_TYPE_FOCUS_CHANGED);
117 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
120 eina_stringshare_del(etRunner::get().ev.key.name);
121 etRunner::get().ev.key.name = NULL;
122 etRunner::get().ev.win = NULL;
124 evas_object_key_ungrab(tw_orexcl->elm_win, "XF86Menu", 0, 0);
125 ret = elm_win_keygrab_unset(tw_orexcl->elm_win, "XF86Menu", 0, 0);
129 TEST_F(etTestInput, keygrab_win_excl)
131 Eina_Bool ret = EINA_FALSE;
133 tw_excl = initNormalWin("TCWin_ExclGrab", EINA_TRUE, EINA_FALSE);
134 ASSERT_TRUE(tw_excl != NULL) << "failed to initiation window";
136 ret = elm_win_keygrab_set(tw_excl->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_EXCLUSIVE);
138 ret = evas_object_key_grab(tw_excl->elm_win, "XF86Menu", 0, 0, EINA_TRUE);
141 etRunner::get().ev.win = tw_excl->elm_win;
142 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
143 ret = etRunner::get().setWinStack(tw_excl, NULL, EINA_FALSE);
144 etRunner::get().waitEvent(E_TC_EVENT_TYPE_FOCUS_CHANGED);
147 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
150 eina_stringshare_del(etRunner::get().ev.key.name);
151 etRunner::get().ev.key.name = NULL;
152 etRunner::get().ev.win = NULL;
154 evas_object_key_ungrab(tw_excl->elm_win, "XF86Menu", 0, 0);
155 ret = elm_win_keygrab_unset(tw_excl->elm_win, "XF86Menu", 0, 0);
159 TEST_F(etTestInput, keygrab_win_topposition)
161 Eina_Bool ret = EINA_FALSE;
163 tw_topposition = initNormalWin("TCWin_ToppositionGrab", EINA_TRUE, EINA_TRUE);
164 ASSERT_TRUE(tw_topposition != NULL) << "failed to initiation window";
166 ecore_evas_focus_skip_set(ecore_evas_ecore_evas_get(evas_object_evas_get(tw_topposition->elm_win)), EINA_TRUE);
168 ret = elm_win_keygrab_set(tw_topposition->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_TOPMOST);
170 ret = evas_object_key_grab(tw_topposition->elm_win, "XF86Menu", 0, 0, EINA_FALSE);
173 etRunner::get().ev.win = tw_topposition->elm_win;
174 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
176 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
179 eina_stringshare_del(etRunner::get().ev.key.name);
180 etRunner::get().ev.key.name = NULL;
181 etRunner::get().ev.win = NULL;
183 evas_object_key_ungrab(tw_topposition->elm_win, "XF86Menu", 0, 0);
184 ret = elm_win_keygrab_unset(tw_topposition->elm_win, "XF86Menu", 0, 0);
188 TEST_F(etTestInput, keygrab_win)
190 Eina_Bool ret = EINA_FALSE;
192 tw_shared = initNormalWin("TCWin_SharedGrab", EINA_TRUE, EINA_FALSE);
193 ASSERT_TRUE(tw_shared != NULL) << "failed to initiation window";
195 tw_orexcl = initNormalWin("TCWin_OrexclGrab", EINA_TRUE, EINA_FALSE);
196 ASSERT_TRUE(tw_orexcl != NULL) << "failed to initiation window";
198 tw_excl = initNormalWin("TCWin_ExclGrab", EINA_TRUE, EINA_FALSE);
199 ASSERT_TRUE(tw_excl != NULL) << "failed to initiation window";
201 tw_topposition = initNormalWin("TCWin_ToppositionGrab", EINA_TRUE, EINA_TRUE);
202 ASSERT_TRUE(tw_topposition != NULL) << "failed to initiation window";
204 ecore_evas_focus_skip_set(ecore_evas_ecore_evas_get(evas_object_evas_get(tw_topposition->elm_win)), EINA_TRUE);
206 ret = elm_win_keygrab_set(tw_excl->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_EXCLUSIVE);
208 ret = evas_object_key_grab(tw_excl->elm_win, "XF86Menu", 0, 0, EINA_TRUE);
211 ret = elm_win_keygrab_set(tw_orexcl->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE);
213 ret = evas_object_key_grab(tw_orexcl->elm_win, "XF86Menu", 0, 0, EINA_TRUE);
216 ret = elm_win_keygrab_set(tw_topposition->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_TOPMOST);
218 ret = evas_object_key_grab(tw_topposition->elm_win, "XF86Menu", 0, 0, EINA_FALSE);
221 ret = elm_win_keygrab_set(tw_shared->elm_win, "XF86Menu", 0, 0, 0, ELM_WIN_KEYGRAB_SHARED);
223 ret = evas_object_key_grab(tw_shared->elm_win, "XF86Menu", 0, 0, EINA_FALSE);
226 ret = etRunner::get().setWinStack(tw_excl, NULL, EINA_FALSE);
227 etRunner::get().waitEvent(E_TC_EVENT_TYPE_FOCUS_CHANGED);
230 ret = etRunner::get().setWinStack(tw_orexcl, NULL, EINA_FALSE);
231 etRunner::get().waitEvent(E_TC_EVENT_TYPE_FOCUS_CHANGED);
234 ret = etRunner::get().setWinStack(tw_shared, NULL, EINA_FALSE);
235 etRunner::get().waitEvent(E_TC_EVENT_TYPE_FOCUS_CHANGED);
238 // test exclusive grab
239 etRunner::get().ev.win = tw_excl->elm_win;
240 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
242 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
245 eina_stringshare_del(etRunner::get().ev.key.name);
247 evas_object_key_ungrab(tw_excl->elm_win, "XF86Menu", 0, 0);
248 ret = elm_win_keygrab_unset(tw_excl->elm_win, "XF86Menu", 0, 0);
251 // test override exclusive grab
252 etRunner::get().ev.win = tw_orexcl->elm_win;
253 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
255 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
258 eina_stringshare_del(etRunner::get().ev.key.name);
260 evas_object_key_ungrab(tw_orexcl->elm_win, "XF86Menu", 0, 0);
261 ret = elm_win_keygrab_unset(tw_orexcl->elm_win, "XF86Menu", 0, 0);
264 // test top position grab
265 etRunner::get().ev.win = tw_topposition->elm_win;
266 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
268 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
271 eina_stringshare_del(etRunner::get().ev.key.name);
273 evas_object_key_ungrab(tw_topposition->elm_win, "XF86Menu", 0, 0);
274 ret = elm_win_keygrab_unset(tw_topposition->elm_win, "XF86Menu", 0, 0);
278 etRunner::get().ev.win = tw_shared->elm_win;
279 etRunner::get().ev.key.name = eina_stringshare_add("XF86Menu");
281 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_INPUT_EVAS_KEY);
284 eina_stringshare_del(etRunner::get().ev.key.name);
286 evas_object_key_ungrab(tw_shared->elm_win, "XF86Menu", 0, 0);
287 ret = elm_win_keygrab_unset(tw_shared->elm_win, "XF86Menu", 0, 0);
290 etRunner::get().ev.key.name = NULL;
291 etRunner::get().ev.win = NULL;
294 TEST_F(etTestInput, gesture_tap22)
296 int ret = EFL_UTIL_ERROR_NONE;
297 efl_util_gesture_h gesture_h;
298 efl_util_gesture_data tap_d;
300 gesture_h = efl_util_gesture_initialize();
301 ASSERT_TRUE(gesture_h != NULL) << "failed to initiation gesture system";
303 tap_d = efl_util_gesture_tap_new(gesture_h, 2, 2);
304 ASSERT_TRUE(tap_d != NULL) << "failed to generate tap grab data";
306 ret = efl_util_gesture_grab(gesture_h, tap_d);
307 ASSERT_TRUE(ret == EFL_UTIL_ERROR_NONE) << "failed to grab tap gesture: (ret: "
308 << EFL_UTIL_RETURN_TO_STRING(ret) << ")";
310 etRunner::get().ev.gesture.tap.fingers = 2;
311 etRunner::get().ev.gesture.tap.repeats = 2;
313 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_GESTURE_TAP);
316 etRunner::get().ev.gesture.tap.fingers = 0;
317 etRunner::get().ev.gesture.tap.repeats = 0;
319 ret = efl_util_gesture_ungrab(gesture_h, tap_d);
320 ASSERT_TRUE(ret == EFL_UTIL_ERROR_NONE) << "failed to ungrab tap gesture: (ret: "
321 << EFL_UTIL_RETURN_TO_STRING(ret) << ")";
323 efl_util_gesture_tap_free(gesture_h, tap_d);
324 ASSERT_TRUE(ret == EFL_UTIL_ERROR_NONE) << "failed to free tap grab data: (ret: "
325 << EFL_UTIL_RETURN_TO_STRING(ret) << ")";
328 TEST_F(etTestInput, gesture_tap23)
330 int ret = EFL_UTIL_ERROR_NONE;
331 efl_util_gesture_h gesture_h;
332 efl_util_gesture_data tap_d;
334 gesture_h = efl_util_gesture_initialize();
335 ASSERT_TRUE(gesture_h != NULL) << "failed to initiation gesture system";
337 tap_d = efl_util_gesture_tap_new(gesture_h, 2, 3);
338 ASSERT_TRUE(tap_d != NULL) << "failed to generate tap grab data";
340 ret = efl_util_gesture_grab(gesture_h, tap_d);
341 ASSERT_TRUE(ret == EFL_UTIL_ERROR_NONE) << "failed to grab tap gesture: (ret: "
342 << EFL_UTIL_RETURN_TO_STRING(ret) << ")";
344 etRunner::get().ev.gesture.tap.fingers = 2;
345 etRunner::get().ev.gesture.tap.repeats = 3;
347 ret = etRunner::get().waitEvent(E_TC_EVENT_TYPE_GESTURE_TAP);
350 etRunner::get().ev.gesture.tap.fingers = 0;
351 etRunner::get().ev.gesture.tap.repeats = 0;
353 ret = efl_util_gesture_ungrab(gesture_h, tap_d);
354 ASSERT_TRUE(ret == EFL_UTIL_ERROR_NONE) << "failed to ungrab tap gesture: (ret: "
355 << EFL_UTIL_RETURN_TO_STRING(ret) << ")";
357 efl_util_gesture_tap_free(gesture_h, tap_d);
358 ASSERT_TRUE(ret == EFL_UTIL_ERROR_NONE) << "failed to free tap grab data: (ret: "
359 << EFL_UTIL_RETURN_TO_STRING(ret) << ")";