2019-01-29 10:50:40 -08:00
|
|
|
#include "efl_ui_test_focus_common.h"
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(focus_unregister_twice)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *r1, *r2;
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Manager *m = focus_test_manager_new(&r1, EINA_TRUE);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
r2 = efl_add_ref(FOCUS_TEST_CLASS, NULL);
|
2017-07-05 03:48:52 -07:00
|
|
|
fail_if(!efl_ui_focus_manager_calc_register(m, r2, r1, NULL));
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2017-07-05 03:48:52 -07:00
|
|
|
efl_ui_focus_manager_calc_unregister(m, r1);
|
|
|
|
efl_ui_focus_manager_calc_unregister(m, r1);
|
|
|
|
efl_ui_focus_manager_calc_unregister(m, r1);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(r2);
|
|
|
|
efl_unref(m);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(focus_register_twice)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *r1, *r2, *r3;
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Manager *m = focus_test_manager_new(&r1, EINA_TRUE);
|
|
|
|
Efl_Ui_Focus_Manager *m2 = focus_test_manager_new(&r3, EINA_TRUE);
|
|
|
|
|
|
|
|
r2 = efl_add_ref(FOCUS_TEST_CLASS, NULL);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2017-07-05 03:48:52 -07:00
|
|
|
fail_if(!efl_ui_focus_manager_calc_register(m, r2, r1, NULL));
|
2018-07-13 07:06:58 -07:00
|
|
|
//same confguration don't error out
|
|
|
|
fail_if(!efl_ui_focus_manager_calc_register(m, r2, r1, NULL));
|
2019-05-28 09:01:50 -07:00
|
|
|
|
|
|
|
EXPECT_ERROR_START;
|
2018-07-13 07:06:58 -07:00
|
|
|
//different confidurations error out
|
2019-05-28 09:01:50 -07:00
|
|
|
fail_if(efl_ui_focus_manager_calc_register(m, r2, r1, m2));
|
|
|
|
EXPECT_ERROR_END;
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(pos_check)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
2016-12-17 10:51:35 -08:00
|
|
|
Efl_Ui_Focus_Object *middle, *east, *west, *north, *south, *root;
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2019-01-29 10:50:40 -08:00
|
|
|
focus_test_setup_cross(&middle, &south, &north, &east, &west);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2017-07-05 03:48:52 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, middle, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, north, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, south, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, west, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, east, root, NULL);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
#define CHECK(obj, r,l,u,d) \
|
2017-07-18 03:40:17 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m, obj); \
|
2016-10-20 13:59:05 -07:00
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_RIGHT), r); \
|
2017-07-18 03:40:17 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m, obj); \
|
2016-10-20 13:59:05 -07:00
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_LEFT), l); \
|
2017-07-18 03:40:17 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m, obj); \
|
2016-10-20 13:59:05 -07:00
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_UP), u); \
|
2017-07-18 03:40:17 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m, obj); \
|
2016-10-20 13:59:05 -07:00
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_DOWN), d); \
|
2017-07-18 03:40:17 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m, obj);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
CHECK(middle, east, west, north, south)
|
2017-12-08 01:43:49 -08:00
|
|
|
CHECK(east, NULL, middle, north, south)
|
|
|
|
CHECK(west, middle, NULL, north, south)
|
|
|
|
CHECK(north, east, west, NULL, middle)
|
|
|
|
CHECK(south, east, west, middle, NULL)
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(middle);
|
|
|
|
efl_unref(south);
|
|
|
|
efl_unref(north);
|
|
|
|
efl_unref(east);
|
|
|
|
efl_unref(west);
|
|
|
|
efl_unref(m);
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2017-12-08 01:43:49 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_equal_set(Eina_List *elems, Efl_Ui_Focus_Object *lst[])
|
|
|
|
{
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
for (i = 0; lst[i]; ++i)
|
|
|
|
{
|
|
|
|
Eina_Bool found = EINA_FALSE;
|
|
|
|
Eina_List *n;
|
|
|
|
Efl_Ui_Focus_Object *elem;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(elems, n, elem)
|
|
|
|
{
|
|
|
|
if (lst[i] != elem) continue;
|
|
|
|
|
|
|
|
found = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eina_list_count(elems) != i) return EINA_FALSE;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(pos_check2)
|
2017-12-08 01:43:49 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Relations *rel;
|
|
|
|
Efl_Ui_Focus_Object *root, *middle, *north_east, *north_west, *south_east, *south_west;
|
|
|
|
|
2019-01-29 10:50:40 -08:00
|
|
|
middle = focus_test_object_new("middle", 40, 40, 5, 5);
|
2017-12-08 01:43:49 -08:00
|
|
|
|
2019-01-29 10:50:40 -08:00
|
|
|
north_east = focus_test_object_new("north_east", 60, 20, 5, 5);
|
|
|
|
north_west = focus_test_object_new("north_west", 20, 20, 5, 5);
|
|
|
|
south_east = focus_test_object_new("south_east", 60, 60, 5, 5);
|
|
|
|
south_west = focus_test_object_new("south_west", 20, 60, 5, 5);
|
2017-12-08 01:43:49 -08:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2017-12-08 01:43:49 -08:00
|
|
|
efl_ui_focus_manager_calc_register(m, middle, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, north_east, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, north_west, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, south_east, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, south_west, root, NULL);
|
|
|
|
|
|
|
|
rel = efl_ui_focus_manager_fetch(m, middle);
|
|
|
|
|
|
|
|
#define ck_assert_set_eq(set, ...) \
|
|
|
|
{ \
|
|
|
|
Efl_Ui_Focus_Object *tmp[] = { __VA_ARGS__ }; \
|
|
|
|
ck_assert_int_eq(_equal_set(set, tmp), EINA_TRUE); \
|
|
|
|
}
|
|
|
|
|
|
|
|
ck_assert_set_eq(rel->left, north_west, south_west, NULL);
|
|
|
|
ck_assert_set_eq(rel->right, north_east, south_east, NULL);
|
|
|
|
ck_assert_set_eq(rel->top, north_west, north_east, NULL);
|
|
|
|
ck_assert_set_eq(rel->down, south_west, south_east, NULL);
|
|
|
|
|
|
|
|
#undef ck_assert_set_eq
|
|
|
|
|
2019-01-14 11:28:45 -08:00
|
|
|
efl_ui_focus_relation_free(rel);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(middle);
|
|
|
|
efl_unref(north_east);
|
|
|
|
efl_unref(north_west);
|
|
|
|
efl_unref(south_east);
|
|
|
|
efl_unref(south_west);
|
2017-12-08 01:43:49 -08:00
|
|
|
|
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
|
|
|
EFL_START_TEST(redirect)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root, *root2;
|
2016-10-20 13:59:05 -07:00
|
|
|
TEST_OBJ_NEW(one, 0, 0, 20, 20);
|
|
|
|
TEST_OBJ_NEW(two, 20, 0, 20, 20);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Manager *m = focus_test_manager_new(&root, EINA_TRUE);
|
|
|
|
Efl_Ui_Focus_Manager *m2 = focus_test_manager_new(&root2, EINA_TRUE);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2017-07-05 03:48:52 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m2, one, root2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m2, two, root2, NULL);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
efl_ui_focus_manager_redirect_set(m, m2);
|
2017-07-18 03:40:17 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m2, one);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_RIGHT), two);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
|
|
|
efl_unref(m2);
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(border_check)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
2016-12-17 10:51:35 -08:00
|
|
|
Efl_Ui_Focus_Object *middle, *east, *west, *north, *south, *root;
|
2016-10-20 13:59:05 -07:00
|
|
|
Eina_List *list = NULL;
|
|
|
|
Eina_Iterator *iter;
|
|
|
|
Efl_Ui_Focus_Object *obj;
|
|
|
|
|
2019-01-29 10:50:40 -08:00
|
|
|
focus_test_setup_cross(&middle, &south, &north, &east, &west);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2017-07-05 03:48:52 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, middle, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, south, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, north, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, east, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, west, root, NULL);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
iter = efl_ui_focus_manager_border_elements_get(m);
|
|
|
|
|
|
|
|
EINA_ITERATOR_FOREACH(iter, obj)
|
|
|
|
{
|
|
|
|
list = eina_list_append(list, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_iterator_free(iter);
|
|
|
|
|
|
|
|
ck_assert(eina_list_data_find(list, east) == east);
|
|
|
|
ck_assert(eina_list_data_find(list, north) == north);
|
|
|
|
ck_assert(eina_list_data_find(list, west) == west);
|
|
|
|
ck_assert(eina_list_data_find(list, east) == east);
|
|
|
|
ck_assert(eina_list_data_find(list, middle) == NULL);
|
|
|
|
ck_assert(eina_list_count(list) == 4);
|
|
|
|
|
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(logical_chain)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
2016-12-17 10:51:35 -08:00
|
|
|
Efl_Ui_Focus_Object *lroot;
|
2016-10-20 13:59:05 -07:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
TEST_OBJ_NEW(root, 0, 0, 20, 20);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&lroot, EINA_TRUE);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2016-12-17 10:51:35 -08:00
|
|
|
fail_if(!m);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(child1, 0, i*20, 20, 20);
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(child2, 0, i*20, 20, 20);
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(child3, 0, i*20, 20, 20);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(subchild11, 0, i*20, 20, 20);
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(subchild12, 0, i*20, 20, 20);
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(subchild13, 0, i*20, 20, 20);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(subchild21, 0, i*20, 20, 20);
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(subchild22, 0, i*20, 20, 20);
|
|
|
|
i++;
|
|
|
|
TEST_OBJ_NEW(subchild23, 0, i*20, 20, 20);
|
|
|
|
|
|
|
|
//register everything
|
2017-07-05 03:48:52 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, root, lroot, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, child1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, child2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, child3, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, subchild11, child1, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, subchild12, child1, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, subchild13, child1, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, subchild21, child3, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, subchild22, child3, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, subchild23, child3, NULL);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2017-07-18 03:40:17 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m, root);
|
2016-12-17 10:51:35 -08:00
|
|
|
|
2016-10-20 13:59:05 -07:00
|
|
|
Efl_Object *logical_chain[] = {
|
|
|
|
child1, subchild11, subchild12, subchild13,
|
2016-12-23 11:11:12 -08:00
|
|
|
child2, subchild21, subchild22, subchild23, NULL
|
2016-10-20 13:59:05 -07:00
|
|
|
};
|
|
|
|
for (i = 0; logical_chain[i]; ++i)
|
|
|
|
{
|
|
|
|
ck_assert_ptr_eq(logical_chain[i], efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT));
|
|
|
|
}
|
|
|
|
i-= 2;
|
|
|
|
for (; i > 0; --i)
|
|
|
|
{
|
2017-08-16 06:56:57 -07:00
|
|
|
ck_assert_ptr_eq(logical_chain[i], efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS));
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-04-10 07:51:26 -07:00
|
|
|
static void
|
|
|
|
_check_chain(Efl_Ui_Focus_Manager *m, Efl_Ui_Focus_Object *objects[])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; objects[i]; ++i)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Object *next;
|
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eo *root = efl_ui_focus_manager_root_get(m);
|
|
|
|
efl_ui_focus_manager_reset_history(m);
|
|
|
|
efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_NEXT, root);
|
|
|
|
}
|
2019-02-09 09:45:27 -08:00
|
|
|
next = efl_ui_focus_manager_focus_get(efl_ui_focus_util_active_manager(m));
|
2018-04-10 07:51:26 -07:00
|
|
|
|
|
|
|
ck_assert_ptr_eq(next, objects[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT), NULL);
|
|
|
|
|
|
|
|
for (; i > 0; i--)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Object *prev;
|
|
|
|
|
|
|
|
if (!!objects[i])
|
|
|
|
efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eo *root = efl_ui_focus_manager_root_get(m);
|
|
|
|
efl_ui_focus_manager_reset_history(m);
|
|
|
|
efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, root);
|
|
|
|
}
|
|
|
|
|
2019-02-09 09:45:27 -08:00
|
|
|
prev = efl_ui_focus_manager_focus_get(efl_ui_focus_util_active_manager(m));
|
2018-04-10 07:51:26 -07:00
|
|
|
ck_assert_ptr_eq(prev, objects[i - 1]);
|
|
|
|
}
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
EFL_START_TEST(logical_chain_multi_redirect)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m, *m2, *m3, *m4;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root,*root2, *root3, *root4, *c2, *c3, *c4;
|
2018-04-10 07:51:26 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2018-04-10 07:51:26 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
//Create 3 linked focus managers
|
|
|
|
m2 = focus_test_manager_new(&root2, EINA_FALSE);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, root2, root, m2);
|
|
|
|
focus_test_manager_set(root2, m);
|
|
|
|
|
|
|
|
m3 = focus_test_manager_new(&root3, EINA_FALSE);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, root3, root, m3);
|
|
|
|
focus_test_manager_set(root3, m);
|
2018-04-10 07:51:26 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m4 = focus_test_manager_new(&root4, EINA_FALSE);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, root4, root, m4);
|
|
|
|
focus_test_manager_set(root4, m);
|
2018-04-10 07:51:26 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
c2 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c3 = focus_test_object_new("child2", 0, 0, 20, 20);
|
|
|
|
c4 = focus_test_object_new("child3", 0, 0, 20, 20);
|
2018-04-10 07:51:26 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m2, c2, root2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m3, c3, root3, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m4, c4, root4, NULL);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *objects[] = {c2, c3, c4, NULL};
|
2018-04-10 07:51:26 -07:00
|
|
|
_check_chain(m, objects);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m2);
|
|
|
|
efl_unref(m);
|
2018-04-10 07:51:26 -07:00
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
|
|
|
EFL_START_TEST(logical_chain_single_redirect)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m, *m2;
|
|
|
|
Efl_Ui_Focus_Object *root,*root2, *c1_1, *c1_2, *c1_3, *c2_1, *c2_2, *c2_3;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
|
|
|
m2 = focus_test_manager_new(&root2, EINA_FALSE);
|
|
|
|
focus_test_manager_set(root2, m);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1_1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
2019-05-28 09:01:50 -07:00
|
|
|
c1_2 = root2;
|
2019-01-29 10:50:40 -08:00
|
|
|
c1_3 = focus_test_object_new("child3", 0, 0, 20, 20);
|
|
|
|
c2_1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2_2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
|
|
|
c2_3 = focus_test_object_new("child3", 0, 0, 20, 20);
|
2018-04-10 07:51:26 -07:00
|
|
|
|
|
|
|
Efl_Ui_Focus_Object *objects[] = {c1_1, c2_1, c2_2, c2_3, c1_3, NULL};
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m, c1_1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c1_2, root, m2);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c1_3, root, NULL);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m2, c2_1, root2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m2, c2_2, root2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m2, c2_3, root2, NULL);
|
|
|
|
|
|
|
|
_check_chain(m, objects);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m2);
|
|
|
|
efl_unref(m);
|
2018-04-10 07:51:26 -07:00
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(finalize_check)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_START;
|
2018-04-11 10:38:21 -07:00
|
|
|
m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
2016-10-20 13:59:05 -07:00
|
|
|
fail_if(m);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(redirect_param)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m, *m2;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root,*root2;
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child, 0, 20, 20, 20);
|
2019-05-28 09:01:50 -07:00
|
|
|
TEST_OBJ_NEW(child2, 0, 20, 20, 20);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
|
|
|
m2 = focus_test_manager_new(&root2, EINA_FALSE);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, root2, root, m2);
|
|
|
|
focus_test_manager_set(root2, m);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2017-07-05 03:48:52 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, child, root, m2);
|
2019-05-28 09:01:50 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m2, child2, root2, NULL);
|
|
|
|
efl_ui_focus_manager_focus_set(m, root2);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
|
|
|
efl_unref(m2);
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(invalid_args_check)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root;
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child, 0, 20, 20, 20);
|
|
|
|
TEST_OBJ_NEW(child2, 0, 20, 20, 20);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
//no child and no parent
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_START;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, NULL, NULL, NULL), 0);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
|
|
|
EXPECT_ERROR_START;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, child, NULL, NULL), 0);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
|
|
|
EXPECT_ERROR_START;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, NULL, root, NULL), 0);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, child, root, NULL), 1);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_START;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, child, NULL), 0);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
|
|
|
EXPECT_ERROR_START;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, NULL, NULL), 0);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
|
|
|
EXPECT_ERROR_START;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, child, child2), 0);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, child2, root, NULL), 1);
|
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, child, child2), 1);
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2016-10-20 13:59:05 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(order_check)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Eina_List *order = NULL;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root;
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child1, 0, 20, 20, 20);
|
|
|
|
TEST_OBJ_NEW(child2, 0, 20, 20, 20);
|
|
|
|
TEST_OBJ_NEW(child3, 0, 20, 20, 20);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
//no child and no parent
|
2017-07-05 03:48:52 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, child1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, child2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, child3, root, NULL);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
//positiv check
|
|
|
|
order = eina_list_append(order, child2);
|
|
|
|
order = eina_list_append(order, child3);
|
|
|
|
order = eina_list_append(order, child1);
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_update_children(m, root, order), 1);
|
2016-10-20 13:59:05 -07:00
|
|
|
|
|
|
|
order = NULL;
|
|
|
|
|
|
|
|
//negativ check
|
|
|
|
order = eina_list_append(order, child1);
|
|
|
|
order = eina_list_append(order, child2);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_START;
|
2017-07-05 03:48:52 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_manager_calc_update_children(m, root, order), 0);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2017-10-09 04:06:47 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(logical_shift)
|
2017-10-09 04:06:47 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root;
|
2017-10-09 04:06:47 -07:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child, 0, 0, 10, 10);
|
|
|
|
TEST_OBJ_NEW(sub, 0, 0, 10, 10);
|
|
|
|
TEST_OBJ_NEW(sub_sub, 0, 0, 10, 10);
|
|
|
|
TEST_OBJ_NEW(sub_child, 0, 0, 10, 10);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2017-10-09 04:06:47 -07:00
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m, child, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, sub, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, sub_sub, sub, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, sub_child, sub, NULL);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, root);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), child);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, sub);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), sub_child);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_START;
|
2017-10-09 04:06:47 -07:00
|
|
|
efl_ui_focus_manager_focus_set(m, sub_sub);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), sub_child);
|
2019-05-28 09:01:50 -07:00
|
|
|
EXPECT_ERROR_END;
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2017-10-09 04:06:47 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2017-10-09 04:06:47 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(root_redirect_chain)
|
2017-11-14 10:46:29 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m, *m2;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root, *root2;
|
2017-11-14 10:46:29 -08:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child, 0, 20, 20, 20);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
|
|
|
m2 = focus_test_manager_new(&root2, EINA_TRUE);
|
2017-11-14 10:46:29 -08:00
|
|
|
focus_test_manager_set(root2, m);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m, root2, root, m2);
|
|
|
|
efl_ui_focus_manager_calc_register(m2, child, root2, NULL);
|
|
|
|
efl_ui_focus_manager_focus_set(m2, child);
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
|
|
|
efl_unref(m2);
|
2017-11-14 10:46:29 -08:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2017-11-14 10:46:29 -08:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(root_redirect_chain_unset)
|
2017-11-15 01:15:34 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m, *m2, *m3, *m4;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root, *root2, *root3, *root4;
|
2017-11-15 01:15:34 -08:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child, 0, 20, 20, 20);
|
2019-05-28 09:01:50 -07:00
|
|
|
TEST_OBJ_NEW(child2, 0, 20, 20, 20);
|
|
|
|
TEST_OBJ_NEW(child3, 0, 20, 20, 20);
|
2017-11-15 01:15:34 -08:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
|
|
|
m2 = focus_test_manager_new(&root2, EINA_FALSE);
|
|
|
|
m3 = focus_test_manager_new(&root3, EINA_FALSE);
|
|
|
|
m4 = focus_test_manager_new(&root4, EINA_FALSE);
|
2017-11-15 01:15:34 -08:00
|
|
|
focus_test_manager_set(root2, m);
|
2019-05-28 09:01:50 -07:00
|
|
|
focus_test_manager_set(root3, m);
|
|
|
|
focus_test_manager_set(root4, m3);
|
2017-11-15 01:15:34 -08:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, root2, root, m2);
|
|
|
|
efl_ui_focus_manager_calc_register(m, root3, root, m3);
|
|
|
|
efl_ui_focus_manager_calc_register(m2, child, root2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m3, child2, root3, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m3, root4, root3, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m4, child3, root4, NULL);
|
2017-11-15 01:15:34 -08:00
|
|
|
|
|
|
|
efl_ui_focus_manager_redirect_set(m, m3);
|
|
|
|
efl_ui_focus_manager_redirect_set(m3, m4);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m2, child);
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m2), NULL);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m3), NULL);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m4), NULL);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
|
|
|
efl_unref(m2);
|
|
|
|
efl_unref(m3);
|
|
|
|
efl_unref(m4);
|
2017-11-15 01:15:34 -08:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2017-11-15 01:15:34 -08:00
|
|
|
|
2017-12-06 06:58:35 -08:00
|
|
|
static Efl_Ui_Focus_Manager_Calc*
|
2018-04-04 01:10:53 -07:00
|
|
|
_recursive_triangle_manager(int recusion_depth, Efl_Ui_Focus_Object **most_right, Efl_Ui_Focus_Object **most_left, Eina_List **managers)
|
2017-12-06 06:58:35 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m, *m_child1 = NULL, *m_child3 = NULL;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *child1, *child3, *root;
|
2017-12-06 06:58:35 -08:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child2, 0, 20, 20, 20);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, recusion_depth == 0);
|
2017-12-06 06:58:35 -08:00
|
|
|
|
|
|
|
if (recusion_depth < 3)
|
|
|
|
{
|
2018-04-04 01:10:53 -07:00
|
|
|
m_child1 = _recursive_triangle_manager(recusion_depth + 1, NULL, most_left, managers);
|
|
|
|
m_child3 = _recursive_triangle_manager(recusion_depth + 1, most_right, NULL, managers);
|
2017-12-06 06:58:35 -08:00
|
|
|
child1 = efl_ui_focus_manager_root_get(m_child1);
|
|
|
|
child3 = efl_ui_focus_manager_root_get(m_child3);
|
|
|
|
focus_test_manager_set(child1, m);
|
|
|
|
focus_test_manager_set(child3, m);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TEST_OBJ_NEW(tmp_child1, 0, 20, 20, 20);
|
|
|
|
TEST_OBJ_NEW(tmp_child3, 0, 20, 20, 20);
|
|
|
|
|
|
|
|
child1 = tmp_child1;
|
|
|
|
child3 = tmp_child3;
|
|
|
|
|
|
|
|
if (most_left)
|
|
|
|
{
|
|
|
|
*most_left = child1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (most_right)
|
|
|
|
{
|
|
|
|
*most_right = child3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m, child1, root, m_child1);
|
|
|
|
efl_ui_focus_manager_calc_register(m, child2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, child3, root, m_child3);
|
|
|
|
|
2018-04-04 01:10:53 -07:00
|
|
|
*managers = eina_list_append(*managers , m);
|
|
|
|
|
2017-12-06 06:58:35 -08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Efl_Ui_Focus_Object*
|
|
|
|
_get_highest_redirect(Efl_Ui_Focus_Manager *manager)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *tmp = manager;
|
|
|
|
|
|
|
|
do {
|
|
|
|
manager = tmp;
|
|
|
|
tmp = efl_ui_focus_manager_redirect_get(tmp);
|
|
|
|
} while (tmp);
|
|
|
|
|
|
|
|
return manager;
|
|
|
|
}
|
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(first_touch_check)
|
2017-12-06 06:58:35 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *most_left, *most_right;
|
2018-04-04 01:10:53 -07:00
|
|
|
Eina_List *managers = NULL;
|
2017-12-06 06:58:35 -08:00
|
|
|
|
2018-04-04 01:10:53 -07:00
|
|
|
m = _recursive_triangle_manager(0, &most_right, &most_left, &managers);
|
2017-12-06 06:58:35 -08:00
|
|
|
|
|
|
|
efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_NEXT, efl_ui_focus_manager_root_get(m));
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(_get_highest_redirect(m)), most_left);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_reset_history(m);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, efl_ui_focus_manager_root_get(m));
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(_get_highest_redirect(m)), most_right);
|
|
|
|
|
2018-04-04 01:10:53 -07:00
|
|
|
EINA_LIST_FREE(managers, m)
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2017-12-06 06:58:35 -08:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2017-12-06 06:58:35 -08:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_request_subchild_empty)
|
2018-04-03 06:32:15 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2018-04-03 06:32:15 -07:00
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), NULL);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-03 06:32:15 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-03 06:32:15 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_request_subchild_one_element)
|
2018-04-03 06:32:15 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
2018-04-03 06:32:15 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c1);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), NULL);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-03 06:32:15 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-03 06:32:15 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_request_subchild_child_alongside)
|
2018-04-03 06:32:15 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
2018-04-03 06:32:15 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c2, root, NULL);
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c1);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), NULL);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c2), NULL);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-03 06:32:15 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-03 06:32:15 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_request_subchild_child_logical_regular)
|
2018-04-03 06:32:15 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
2018-04-03 06:32:15 -07:00
|
|
|
efl_ui_focus_manager_calc_register_logical(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c2, c1, NULL);
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c2), NULL);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-03 06:32:15 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-03 06:32:15 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_request_subchild_child_regular_regular)
|
2018-04-03 06:32:15 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
2018-04-03 06:32:15 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c2, c1, NULL);
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c1);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c2), NULL);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-03 06:32:15 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-03 06:32:15 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_unregister_last_focused_no_history)
|
2018-04-03 13:45:48 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2, *c3;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
|
|
|
c3 = focus_test_object_new("child3", 0, 0, 20, 20);
|
2018-04-03 13:45:48 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c3, root, NULL);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_unregister(m, c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-03 13:45:48 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-03 13:45:48 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_unregister_last_focused)
|
2018-04-03 13:45:48 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2, *c3;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
|
|
|
c3 = focus_test_object_new("child3", 0, 0, 20, 20);
|
2018-04-03 13:45:48 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c3, root, NULL);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
|
|
|
|
efl_ui_focus_manager_focus_set(m, c3);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c3);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_unregister(m, c3);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-03 13:45:48 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-04 01:16:37 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_unregister_last_focused_no_child)
|
2018-04-04 01:16:37 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
2018-04-04 01:16:37 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c1);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
|
|
|
|
efl_ui_focus_manager_calc_unregister(m, c1);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), NULL);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-04 01:16:37 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-04 01:16:37 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_START_TEST(test_pop_history_element)
|
2018-04-04 09:23:18 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2, *c3;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
|
|
|
c3 = focus_test_object_new("child3", 0, 0, 20, 20);
|
2018-04-04 09:23:18 -07:00
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c3, root, NULL);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
|
|
|
|
ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_TRUE);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_pop_history_stack(m);
|
2018-08-09 01:38:27 -07:00
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
|
2018-04-04 09:23:18 -07:00
|
|
|
ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_FALSE);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c1);
|
|
|
|
efl_ui_focus_manager_focus_set(m, c2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
|
|
|
|
ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_TRUE);
|
|
|
|
efl_ui_focus_manager_pop_history_stack(m);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
|
|
|
|
ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_FALSE);
|
|
|
|
ck_assert_int_eq(efl_ui_focus_object_focus_get(c1), EINA_TRUE);
|
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
efl_unref(m);
|
2018-04-04 09:23:18 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2018-04-04 09:23:18 -07:00
|
|
|
|
2018-04-12 08:44:48 -07:00
|
|
|
static void
|
|
|
|
_focus_request_tree_check(Efl_Ui_Focus_Manager *m, Eina_Bool accept_logicals, Efl_Ui_Focus_Object *objs[])
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for (i = 1; objs[i]; ++i)
|
|
|
|
{
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_move(m, EFL_UI_FOCUS_DIRECTION_NEXT, objs[i], accept_logicals), objs[i + 1]);
|
|
|
|
}
|
|
|
|
i--;
|
|
|
|
for (; i > 0; --i)
|
|
|
|
{
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_request_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, objs[i], accept_logicals), objs[i - 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EFL_START_TEST(test_request_move)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2, *c3, *c4, *c5, *c6;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
|
|
|
c3 = focus_test_object_new("child3", 0, 0, 20, 20);
|
|
|
|
c4 = focus_test_object_new("child4", 0, 0, 20, 20);
|
|
|
|
c5 = focus_test_object_new("child5", 0, 0, 20, 20);
|
|
|
|
c6 = focus_test_object_new("child6", 0, 0, 20, 20);
|
2018-04-12 08:44:48 -07:00
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, c2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c3, c2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c4, c2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c5, c2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c6, root, NULL);
|
|
|
|
|
|
|
|
// c3 c4 c5
|
|
|
|
// \ | /
|
|
|
|
// \ | /
|
|
|
|
// c1 c2 c6
|
|
|
|
// \ | /
|
|
|
|
// rooot
|
|
|
|
|
|
|
|
Efl_Ui_Focus_Object *objs_logical[] = {NULL, root, c1, c2, c3, c4, c5, c6, NULL};
|
|
|
|
_focus_request_tree_check(m, EINA_TRUE, objs_logical);
|
|
|
|
|
|
|
|
Efl_Ui_Focus_Object *objs_regular[] = {NULL, c1, c3, c4, c5, c6, NULL};
|
|
|
|
_focus_request_tree_check(m, EINA_FALSE, objs_regular);
|
|
|
|
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2018-05-06 09:14:11 -07:00
|
|
|
EFL_START_TEST(redirect_unregister_entrypoint)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m, *m2;
|
2019-05-28 09:01:50 -07:00
|
|
|
Efl_Ui_Focus_Object *root, *root2;
|
2018-05-06 09:14:11 -07:00
|
|
|
|
|
|
|
TEST_OBJ_NEW(child, 0, 20, 20, 20);
|
|
|
|
TEST_OBJ_NEW(child2, 0, 20, 20, 20);
|
|
|
|
TEST_OBJ_NEW(child3, 0, 20, 20, 20);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
|
|
|
m2 = focus_test_manager_new(&root2, EINA_TRUE);
|
2018-05-06 09:14:11 -07:00
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m2, child3, root2, m2);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m, child, root, m2);
|
|
|
|
efl_ui_focus_manager_calc_register(m, child2, root, NULL);
|
|
|
|
efl_ui_focus_manager_focus_set(m, child);
|
|
|
|
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
|
|
|
|
efl_ui_focus_manager_calc_unregister(m, child);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
|
|
|
|
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), NULL);
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
efl_unref(m);
|
|
|
|
efl_unref(m2);
|
2018-05-06 09:14:11 -07:00
|
|
|
}
|
|
|
|
EFL_END_TEST
|
2018-04-12 08:44:48 -07:00
|
|
|
|
2018-11-12 07:08:40 -08:00
|
|
|
static void
|
2019-05-28 09:01:50 -07:00
|
|
|
_child_focus_changed(void *data, const Efl_Event *ev EINA_UNUSED)
|
2018-11-12 07:08:40 -08:00
|
|
|
{
|
|
|
|
Eina_Bool *flag = data;
|
|
|
|
|
|
|
|
*flag = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFL_START_TEST(test_events_child_focus)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *root, *c1, *c2, *c3, *c4, *c5, *c6;
|
|
|
|
Eina_Bool froot = EINA_FALSE, fc1 = EINA_FALSE, fc2 = EINA_FALSE,
|
|
|
|
fc3 = EINA_FALSE, fc4 = EINA_FALSE, fc5 = EINA_FALSE, fc6 = EINA_FALSE;
|
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2019-01-29 10:50:40 -08:00
|
|
|
c1 = focus_test_object_new("child1", 0, 0, 20, 20);
|
2018-11-12 07:08:40 -08:00
|
|
|
efl_parent_set(c1, root);
|
2019-01-29 10:50:40 -08:00
|
|
|
c2 = focus_test_object_new("child2", 0, 0, 20, 20);
|
2018-11-12 07:08:40 -08:00
|
|
|
efl_parent_set(c2, root);
|
2019-01-29 10:50:40 -08:00
|
|
|
c3 = focus_test_object_new("child3", 0, 0, 20, 20);
|
2018-11-12 07:08:40 -08:00
|
|
|
efl_parent_set(c3, c2);
|
2019-01-29 10:50:40 -08:00
|
|
|
c4 = focus_test_object_new("child4", 0, 0, 20, 20);
|
2018-11-12 07:08:40 -08:00
|
|
|
efl_parent_set(c4, c2);
|
2019-01-29 10:50:40 -08:00
|
|
|
c5 = focus_test_object_new("child5", 0, 0, 20, 20);
|
2018-11-12 07:08:40 -08:00
|
|
|
efl_parent_set(c5, root);
|
2019-01-29 10:50:40 -08:00
|
|
|
c6 = focus_test_object_new("child6", 0, 0, 20, 20);
|
2018-11-12 07:08:40 -08:00
|
|
|
efl_parent_set(c6, c5);
|
|
|
|
|
|
|
|
efl_ui_focus_manager_calc_register(m, c1, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, c2, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c3, c2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c4, c2, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register_logical(m, c5, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, c6, c5, NULL);
|
|
|
|
|
|
|
|
// c3 c4 c6
|
|
|
|
// \ | |
|
|
|
|
// \ | |
|
|
|
|
// c1 c2 c5
|
|
|
|
// \ | /
|
|
|
|
// root
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c4);
|
|
|
|
|
|
|
|
ck_assert_int_eq(froot, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc1, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc2, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc3, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc4, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc5, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc6, EINA_FALSE);
|
|
|
|
|
|
|
|
efl_event_callback_add(root, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &froot);
|
|
|
|
efl_event_callback_add(c1, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc1);
|
|
|
|
efl_event_callback_add(c2, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc2);
|
|
|
|
efl_event_callback_add(c3, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc3);
|
|
|
|
efl_event_callback_add(c4, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc4);
|
|
|
|
efl_event_callback_add(c5, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc5);
|
|
|
|
efl_event_callback_add(c6, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc6);
|
|
|
|
efl_ui_focus_manager_focus_set(m, c1);
|
|
|
|
|
|
|
|
ck_assert_int_eq(froot, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc1, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc2, EINA_TRUE);
|
|
|
|
ck_assert_int_eq(fc3, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc4, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc5, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc6, EINA_FALSE);
|
|
|
|
froot = EINA_FALSE;
|
|
|
|
fc1 = EINA_FALSE;
|
|
|
|
fc2 = EINA_FALSE;
|
|
|
|
fc3 = EINA_FALSE;
|
|
|
|
fc4 = EINA_FALSE;
|
|
|
|
fc5 = EINA_FALSE;
|
|
|
|
fc6 = EINA_FALSE;
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c6);
|
|
|
|
|
|
|
|
ck_assert_int_eq(froot, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc1, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc2, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc3, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc4, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc5, EINA_TRUE);
|
|
|
|
ck_assert_int_eq(fc6, EINA_FALSE);
|
|
|
|
froot = EINA_FALSE;
|
|
|
|
fc1 = EINA_FALSE;
|
|
|
|
fc2 = EINA_FALSE;
|
|
|
|
fc3 = EINA_FALSE;
|
|
|
|
fc4 = EINA_FALSE;
|
|
|
|
fc5 = EINA_FALSE;
|
|
|
|
fc6 = EINA_FALSE;
|
|
|
|
|
|
|
|
efl_ui_focus_manager_focus_set(m, c3);
|
|
|
|
|
|
|
|
ck_assert_int_eq(froot, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc1, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc2, EINA_TRUE);
|
|
|
|
ck_assert_int_eq(fc3, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc4, EINA_FALSE);
|
|
|
|
ck_assert_int_eq(fc5, EINA_TRUE);
|
|
|
|
ck_assert_int_eq(fc6, EINA_FALSE);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2018-11-26 03:40:17 -08:00
|
|
|
|
|
|
|
EFL_START_TEST(viewport_check)
|
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *m;
|
|
|
|
Efl_Ui_Focus_Object *middle, *east, *west, *north, *south, *root;
|
|
|
|
Eina_List *list = NULL;
|
|
|
|
Eina_Iterator *iter;
|
|
|
|
Efl_Ui_Focus_Object *obj;
|
|
|
|
|
2019-01-29 10:50:40 -08:00
|
|
|
focus_test_setup_cross(&middle, &south, &north, &east, &west);
|
2018-11-26 03:40:17 -08:00
|
|
|
|
2019-05-28 09:01:50 -07:00
|
|
|
m = focus_test_manager_new(&root, EINA_TRUE);
|
2018-11-26 03:40:17 -08:00
|
|
|
efl_ui_focus_manager_calc_register(m, middle, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, south, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, north, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, east, root, NULL);
|
|
|
|
efl_ui_focus_manager_calc_register(m, west, root, NULL);
|
|
|
|
|
|
|
|
iter = efl_ui_focus_manager_viewport_elements_get(m, EINA_RECT(80, 0, 100, 100));
|
|
|
|
|
|
|
|
EINA_ITERATOR_FOREACH(iter, obj)
|
|
|
|
{
|
|
|
|
list = eina_list_append(list, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_iterator_free(iter);
|
|
|
|
|
|
|
|
ck_assert(eina_list_count(list) == 1);
|
|
|
|
ck_assert_ptr_eq(eina_list_data_get(list), east);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-01-29 10:50:40 -08:00
|
|
|
void efl_ui_test_focus(TCase *tc)
|
2016-10-20 13:59:05 -07:00
|
|
|
{
|
2019-05-28 09:01:57 -07:00
|
|
|
tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
|
2016-10-20 13:59:05 -07:00
|
|
|
tcase_add_test(tc, focus_register_twice);
|
|
|
|
tcase_add_test(tc, focus_unregister_twice);
|
|
|
|
tcase_add_test(tc, pos_check);
|
2017-12-08 01:43:49 -08:00
|
|
|
tcase_add_test(tc, pos_check2);
|
2016-10-20 13:59:05 -07:00
|
|
|
tcase_add_test(tc, redirect);
|
|
|
|
tcase_add_test(tc, border_check);
|
|
|
|
tcase_add_test(tc, finalize_check);
|
|
|
|
tcase_add_test(tc, logical_chain);
|
2018-04-10 07:51:26 -07:00
|
|
|
tcase_add_test(tc, logical_chain_multi_redirect);
|
|
|
|
tcase_add_test(tc, logical_chain_single_redirect);
|
2016-10-20 13:59:05 -07:00
|
|
|
tcase_add_test(tc, redirect_param);
|
|
|
|
tcase_add_test(tc, invalid_args_check);
|
|
|
|
tcase_add_test(tc, order_check);
|
2017-10-09 04:06:47 -07:00
|
|
|
tcase_add_test(tc, logical_shift);
|
2017-11-14 10:46:29 -08:00
|
|
|
tcase_add_test(tc, root_redirect_chain);
|
2017-11-15 01:15:34 -08:00
|
|
|
tcase_add_test(tc, root_redirect_chain_unset);
|
2017-12-06 06:58:35 -08:00
|
|
|
tcase_add_test(tc, first_touch_check);
|
2018-04-03 06:32:15 -07:00
|
|
|
tcase_add_test(tc, test_request_subchild_empty);
|
|
|
|
tcase_add_test(tc, test_request_subchild_one_element);
|
|
|
|
tcase_add_test(tc, test_request_subchild_child_alongside);
|
|
|
|
tcase_add_test(tc, test_request_subchild_child_logical_regular);
|
|
|
|
tcase_add_test(tc, test_request_subchild_child_regular_regular);
|
2018-04-03 13:45:48 -07:00
|
|
|
tcase_add_test(tc, test_unregister_last_focused_no_history);
|
|
|
|
tcase_add_test(tc, test_unregister_last_focused);
|
2018-04-04 01:16:37 -07:00
|
|
|
tcase_add_test(tc, test_unregister_last_focused_no_child);
|
2018-04-09 16:46:30 -07:00
|
|
|
tcase_add_test(tc, test_pop_history_element);
|
2018-04-12 08:44:48 -07:00
|
|
|
tcase_add_test(tc, test_request_move);
|
2018-05-06 09:14:11 -07:00
|
|
|
tcase_add_test(tc, redirect_unregister_entrypoint);
|
2018-11-12 07:08:40 -08:00
|
|
|
tcase_add_test(tc, test_events_child_focus);
|
2018-11-26 03:40:17 -08:00
|
|
|
tcase_add_test(tc, viewport_check);
|
2016-10-20 13:59:05 -07:00
|
|
|
}
|