summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel@osg.samsung.com>2017-12-06 15:58:35 +0100
committerMarcel Hollerbach <marcel@osg.samsung.com>2017-12-06 16:10:18 +0100
commiteee6fbad780abf36029ae2a064d645d4853c27ae (patch)
treedd97252e13e04952449231fc77799e1f0bfb9438 /src
parentc1c58cfb6957996eee2e352a4e5563db8b3cf8e1 (diff)
focus: more testcases!
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_calc.c2
-rw-r--r--src/tests/elementary/elm_test_focus.c94
2 files changed, 95 insertions, 1 deletions
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c
index 0a6d86a8e6..4da783a61e 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.c
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.c
@@ -1462,7 +1462,7 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_setup_on_first_touch(Eo *obj, Ef
1462 1462
1463 rec_manager = efl_ui_focus_manager_redirect_get(rec_manager); 1463 rec_manager = efl_ui_focus_manager_redirect_get(rec_manager);
1464 } 1464 }
1465 while (!last.is_regular_end || rec_manager); 1465 while (rec_manager);
1466 } 1466 }
1467 else if (DIRECTION_IS_2D(direction) && entry) 1467 else if (DIRECTION_IS_2D(direction) && entry)
1468 efl_ui_focus_manager_focus_set(obj, entry); 1468 efl_ui_focus_manager_focus_set(obj, entry);
diff --git a/src/tests/elementary/elm_test_focus.c b/src/tests/elementary/elm_test_focus.c
index 385b8fbcc0..e5c45c668e 100644
--- a/src/tests/elementary/elm_test_focus.c
+++ b/src/tests/elementary/elm_test_focus.c
@@ -441,6 +441,99 @@ START_TEST(root_redirect_chain_unset)
441} 441}
442END_TEST 442END_TEST
443 443
444static Efl_Ui_Focus_Manager_Calc*
445_recursive_triangle_manager(int recusion_depth, Efl_Ui_Focus_Object **most_right, Efl_Ui_Focus_Object **most_left)
446{
447 Efl_Ui_Focus_Manager *m, *m_child1 = NULL, *m_child3 = NULL;
448 Efl_Ui_Focus_Object *child1, *child3;
449
450 TEST_OBJ_NEW(root, 0, 20, 20, 20);
451 TEST_OBJ_NEW(child2, 0, 20, 20, 20);
452
453 m = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
454 efl_ui_focus_manager_root_set(efl_added, root)
455 );
456
457 printf("New manaager %p\n", m);
458
459 if (recusion_depth < 3)
460 {
461 m_child1 = _recursive_triangle_manager(recusion_depth + 1, NULL, most_left);
462 m_child3 = _recursive_triangle_manager(recusion_depth + 1, most_right, NULL);
463 child1 = efl_ui_focus_manager_root_get(m_child1);
464 child3 = efl_ui_focus_manager_root_get(m_child3);
465 focus_test_manager_set(child1, m);
466 focus_test_manager_set(child3, m);
467 }
468 else
469 {
470 TEST_OBJ_NEW(tmp_child1, 0, 20, 20, 20);
471 TEST_OBJ_NEW(tmp_child3, 0, 20, 20, 20);
472
473 child1 = tmp_child1;
474 child3 = tmp_child3;
475
476 if (most_left)
477 {
478 *most_left = child1;
479 printf("SETTING %p\n", child1);
480 }
481
482 if (most_right)
483 {
484 *most_right = child3;
485 printf("SETTING %p\n", child3);
486 }
487 }
488
489 printf("Child 1 %p\n", child1);
490 printf("Child 2 %p\n", child2);
491 printf("Child 3 %p\n", child3);
492
493 efl_ui_focus_manager_calc_register(m, child1, root, m_child1);
494 efl_ui_focus_manager_calc_register(m, child2, root, NULL);
495 efl_ui_focus_manager_calc_register(m, child3, root, m_child3);
496
497 return m;
498}
499
500static Efl_Ui_Focus_Object*
501_get_highest_redirect(Efl_Ui_Focus_Manager *manager)
502{
503 Efl_Ui_Focus_Manager *tmp = manager;
504
505 do {
506 manager = tmp;
507 tmp = efl_ui_focus_manager_redirect_get(tmp);
508 } while (tmp);
509
510 return manager;
511}
512
513START_TEST(first_touch_check)
514{
515 Efl_Ui_Focus_Manager *m;
516 Efl_Ui_Focus_Object *most_left, *most_right;
517
518 elm_init(1, NULL);
519
520 m = _recursive_triangle_manager(0, &most_right, &most_left);
521
522 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_NEXT, efl_ui_focus_manager_root_get(m));
523 printf("%p %p\n", most_left, most_right);
524
525 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(_get_highest_redirect(m)), most_left);
526
527 efl_ui_focus_manager_reset_history(m);
528
529 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, efl_ui_focus_manager_root_get(m));
530 printf("%s\n", efl_name_get(efl_ui_focus_manager_focus_get(_get_highest_redirect(m))));
531 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(_get_highest_redirect(m)), most_right);
532
533 elm_shutdown();
534}
535END_TEST
536
444void elm_test_focus(TCase *tc) 537void elm_test_focus(TCase *tc)
445{ 538{
446 tcase_add_test(tc, focus_register_twice); 539 tcase_add_test(tc, focus_register_twice);
@@ -456,4 +549,5 @@ void elm_test_focus(TCase *tc)
456 tcase_add_test(tc, logical_shift); 549 tcase_add_test(tc, logical_shift);
457 tcase_add_test(tc, root_redirect_chain); 550 tcase_add_test(tc, root_redirect_chain);
458 tcase_add_test(tc, root_redirect_chain_unset); 551 tcase_add_test(tc, root_redirect_chain_unset);
552 tcase_add_test(tc, first_touch_check);
459} 553}