summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel@osg.samsung.com>2018-04-10 16:51:26 +0200
committerMarcel Hollerbach <marcel@osg.samsung.com>2018-04-11 10:31:53 +0200
commitba7e4d2168f8f32fa03d0f494f69df32cbdfbef7 (patch)
tree8df6cb5d1b7cea4d5dcb0070bef726d27e2acc7a
parent86c855bdd356550513bf2b316961eceace107291 (diff)
elm_suite: a new testcase for checking focus chains with redirects
-rw-r--r--src/tests/elementary/elm_test_focus.c123
1 files changed, 123 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_focus.c b/src/tests/elementary/elm_test_focus.c
index d733cea18b..4da5daf9df 100644
--- a/src/tests/elementary/elm_test_focus.c
+++ b/src/tests/elementary/elm_test_focus.c
@@ -277,6 +277,127 @@ EFL_START_TEST(logical_chain)
277} 277}
278EFL_END_TEST 278EFL_END_TEST
279 279
280static Efl_Ui_Focus_Manager*
281_upper_manager(Efl_Ui_Focus_Manager *m)
282{
283 Efl_Ui_Focus_Manager *manager = m;
284
285 while (efl_ui_focus_manager_redirect_get(manager))
286 manager = efl_ui_focus_manager_redirect_get(manager);
287
288 return manager;
289}
290
291static void
292_check_chain(Efl_Ui_Focus_Manager *m, Efl_Ui_Focus_Object *objects[])
293{
294 int i;
295 for (i = 0; objects[i]; ++i)
296 {
297 Efl_Ui_Focus_Object *next;
298
299 if (i > 0)
300 efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT);
301 else
302 {
303 Eo *root = efl_ui_focus_manager_root_get(m);
304 efl_ui_focus_manager_reset_history(m);
305 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_NEXT, root);
306 }
307 next = efl_ui_focus_manager_focus_get(_upper_manager(m));
308
309 ck_assert_ptr_eq(next, objects[i]);
310 }
311
312 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT), NULL);
313
314 for (; i > 0; i--)
315 {
316 Efl_Ui_Focus_Object *prev;
317
318 if (!!objects[i])
319 efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS);
320 else
321 {
322 Eo *root = efl_ui_focus_manager_root_get(m);
323 efl_ui_focus_manager_reset_history(m);
324 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, root);
325 }
326
327 prev = efl_ui_focus_manager_focus_get(_upper_manager(m));
328 ck_assert_ptr_eq(prev, objects[i - 1]);
329 }
330 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS), NULL);
331}
332
333EFL_START_TEST(logical_chain_multi_redirect)
334{
335 Efl_Ui_Focus_Manager *m, *m2, *m3, *m4;
336 Efl_Ui_Focus_Object *root,*root2, *root3, *root4, *c1_1, *c1_2, *c1_3, *c2, *c3, *c4;
337
338 m = elm_focus_test_manager_new(&root);
339 m2 = elm_focus_test_manager_new(&root2);
340 m3 = elm_focus_test_manager_new(&root3);
341 m4 = elm_focus_test_manager_new(&root4);
342 c1_1 = elm_focus_test_object_new("child1", 0, 0, 20, 20);
343 c1_2 = elm_focus_test_object_new("child2", 0, 0, 20, 20);
344 c1_3 = elm_focus_test_object_new("child3", 0, 0, 20, 20);
345 focus_test_manager_set(c1_1, m2);
346 focus_test_manager_set(c1_2, m3);
347 focus_test_manager_set(c1_3, m4);
348 c2 = elm_focus_test_object_new("child1", 0, 0, 20, 20);
349 c3 = elm_focus_test_object_new("child2", 0, 0, 20, 20);
350 c4 = elm_focus_test_object_new("child3", 0, 0, 20, 20);
351
352 Efl_Ui_Focus_Object *objects[] = {c2, c3, c4, NULL};
353
354 efl_ui_focus_manager_calc_register(m, c1_1, root, m2);
355 efl_ui_focus_manager_calc_register(m, c1_2, root, m3);
356 efl_ui_focus_manager_calc_register(m, c1_3, root, m4);
357
358 efl_ui_focus_manager_calc_register(m2, c2, root2, NULL);
359 efl_ui_focus_manager_calc_register(m3, c3, root3, NULL);
360 efl_ui_focus_manager_calc_register(m4, c4, root4, NULL);
361
362 _check_chain(m, objects);
363
364 efl_del(m2);
365 efl_del(m);
366}
367EFL_END_TEST
368
369EFL_START_TEST(logical_chain_single_redirect)
370{
371 Efl_Ui_Focus_Manager *m, *m2;
372 Efl_Ui_Focus_Object *root,*root2, *c1_1, *c1_2, *c1_3, *c2_1, *c2_2, *c2_3;
373
374 m = elm_focus_test_manager_new(&root);
375 m2 = elm_focus_test_manager_new(&root2);
376 c1_1 = elm_focus_test_object_new("child1", 0, 0, 20, 20);
377 c1_2 = elm_focus_test_object_new("child2", 0, 0, 20, 20);
378 focus_test_manager_set(c1_2, m2);
379 c1_3 = elm_focus_test_object_new("child3", 0, 0, 20, 20);
380 c2_1 = elm_focus_test_object_new("child1", 0, 0, 20, 20);
381 c2_2 = elm_focus_test_object_new("child2", 0, 0, 20, 20);
382 c2_3 = elm_focus_test_object_new("child3", 0, 0, 20, 20);
383
384 Efl_Ui_Focus_Object *objects[] = {c1_1, c2_1, c2_2, c2_3, c1_3, NULL};
385
386 efl_ui_focus_manager_calc_register(m, c1_1, root, NULL);
387 efl_ui_focus_manager_calc_register(m, c1_2, root, m2);
388 efl_ui_focus_manager_calc_register(m, c1_3, root, NULL);
389
390 efl_ui_focus_manager_calc_register(m2, c2_1, root2, NULL);
391 efl_ui_focus_manager_calc_register(m2, c2_2, root2, NULL);
392 efl_ui_focus_manager_calc_register(m2, c2_3, root2, NULL);
393
394 _check_chain(m, objects);
395
396 efl_del(m2);
397 efl_del(m);
398}
399EFL_END_TEST
400
280EFL_START_TEST(finalize_check) 401EFL_START_TEST(finalize_check)
281{ 402{
282 Efl_Ui_Focus_Manager *m; 403 Efl_Ui_Focus_Manager *m;
@@ -779,6 +900,8 @@ void elm_test_focus(TCase *tc)
779 tcase_add_test(tc, border_check); 900 tcase_add_test(tc, border_check);
780 tcase_add_test(tc, finalize_check); 901 tcase_add_test(tc, finalize_check);
781 tcase_add_test(tc, logical_chain); 902 tcase_add_test(tc, logical_chain);
903 tcase_add_test(tc, logical_chain_multi_redirect);
904 tcase_add_test(tc, logical_chain_single_redirect);
782 tcase_add_test(tc, redirect_param); 905 tcase_add_test(tc, redirect_param);
783 tcase_add_test(tc, invalid_args_check); 906 tcase_add_test(tc, invalid_args_check);
784 tcase_add_test(tc, order_check); 907 tcase_add_test(tc, order_check);