summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_focus.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-01-29 13:50:40 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-30 13:32:04 +0100
commitdc8e46a92614a803d2291839564c704c4e3fa801 (patch)
tree3ce73924c2ba0b54aa30251e9ca5231f124783d7 /src/tests/elementary/efl_ui_test_focus.c
parent08875e5e4299e1f9a3e4fd615660c411ede126e2 (diff)
tests: move efl_ui focus tests into efl_ui_suite
ref T6815 Differential Revision: https://phab.enlightenment.org/D7827
Diffstat (limited to 'src/tests/elementary/efl_ui_test_focus.c')
-rw-r--r--src/tests/elementary/efl_ui_test_focus.c1143
1 files changed, 1143 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_focus.c b/src/tests/elementary/efl_ui_test_focus.c
new file mode 100644
index 0000000..13791a2
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_focus.c
@@ -0,0 +1,1143 @@
1#include "efl_ui_test_focus_common.h"
2
3EFL_START_TEST(focus_unregister_twice)
4{
5 Efl_Ui_Focus_Object *r1 = efl_add_ref(FOCUS_TEST_CLASS, NULL);
6 Efl_Ui_Focus_Object *r2 = efl_add_ref(FOCUS_TEST_CLASS, NULL);
7
8 Efl_Ui_Focus_Manager *m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
9 efl_ui_focus_manager_root_set(efl_added, r1)
10 );
11
12 fail_if(!efl_ui_focus_manager_calc_register(m, r2, r1, NULL));
13
14 efl_ui_focus_manager_calc_unregister(m, r1);
15 efl_ui_focus_manager_calc_unregister(m, r1);
16 efl_ui_focus_manager_calc_unregister(m, r1);
17
18 efl_unref(r2);
19 efl_unref(r1);
20 efl_unref(m);
21
22}
23EFL_END_TEST
24
25EFL_START_TEST(focus_register_twice)
26{
27 Efl_Ui_Focus_Object *r1 = focus_test_object_new("r1", 0, 0, 10, 10);
28 Efl_Ui_Focus_Object *r2 = focus_test_object_new("r2", 0, 10, 10, 10);
29
30 Efl_Ui_Focus_Manager *m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
31 efl_ui_focus_manager_root_set(efl_added, r1)
32 );
33
34 fail_if(!efl_ui_focus_manager_calc_register(m, r2, r1, NULL));
35 //same confguration don't error out
36 fail_if(!efl_ui_focus_manager_calc_register(m, r2, r1, NULL));
37 //different confidurations error out
38 fail_if(efl_ui_focus_manager_calc_register(m, r2, r1, r1));
39
40 efl_unref(r1);
41 efl_unref(m);
42
43}
44EFL_END_TEST
45
46EFL_START_TEST(pos_check)
47{
48 Efl_Ui_Focus_Manager *m;
49 Efl_Ui_Focus_Object *middle, *east, *west, *north, *south, *root;
50
51 focus_test_setup_cross(&middle, &south, &north, &east, &west);
52
53 m = focus_test_manager_new(&root);
54 efl_ui_focus_manager_calc_register(m, middle, root, NULL);
55 efl_ui_focus_manager_calc_register(m, north, root, NULL);
56 efl_ui_focus_manager_calc_register(m, south, root, NULL);
57 efl_ui_focus_manager_calc_register(m, west, root, NULL);
58 efl_ui_focus_manager_calc_register(m, east, root, NULL);
59
60#define CHECK(obj, r,l,u,d) \
61 efl_ui_focus_manager_focus_set(m, obj); \
62 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_RIGHT), r); \
63 efl_ui_focus_manager_focus_set(m, obj); \
64 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_LEFT), l); \
65 efl_ui_focus_manager_focus_set(m, obj); \
66 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_UP), u); \
67 efl_ui_focus_manager_focus_set(m, obj); \
68 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_DOWN), d); \
69 efl_ui_focus_manager_focus_set(m, obj);
70
71 CHECK(middle, east, west, north, south)
72 CHECK(east, NULL, middle, north, south)
73 CHECK(west, middle, NULL, north, south)
74 CHECK(north, east, west, NULL, middle)
75 CHECK(south, east, west, middle, NULL)
76
77 efl_unref(middle);
78 efl_unref(south);
79 efl_unref(north);
80 efl_unref(east);
81 efl_unref(west);
82 efl_unref(m);
83}
84EFL_END_TEST
85
86static Eina_Bool
87_equal_set(Eina_List *elems, Efl_Ui_Focus_Object *lst[])
88{
89 unsigned int i = 0;
90
91 for (i = 0; lst[i]; ++i)
92 {
93 Eina_Bool found = EINA_FALSE;
94 Eina_List *n;
95 Efl_Ui_Focus_Object *elem;
96
97 EINA_LIST_FOREACH(elems, n, elem)
98 {
99 if (lst[i] != elem) continue;
100
101 found = EINA_TRUE;
102 break;
103 }
104
105 if (!found) return EINA_FALSE;
106 }
107
108 if (eina_list_count(elems) != i) return EINA_FALSE;
109 return EINA_TRUE;
110}
111
112EFL_START_TEST(pos_check2)
113{
114 Efl_Ui_Focus_Manager *m;
115 Efl_Ui_Focus_Relations *rel;
116 Efl_Ui_Focus_Object *root, *middle, *north_east, *north_west, *south_east, *south_west;
117
118 middle = focus_test_object_new("middle", 40, 40, 5, 5);
119
120 north_east = focus_test_object_new("north_east", 60, 20, 5, 5);
121 north_west = focus_test_object_new("north_west", 20, 20, 5, 5);
122 south_east = focus_test_object_new("south_east", 60, 60, 5, 5);
123 south_west = focus_test_object_new("south_west", 20, 60, 5, 5);
124
125 m = focus_test_manager_new(&root);
126 efl_ui_focus_manager_calc_register(m, middle, root, NULL);
127 efl_ui_focus_manager_calc_register(m, north_east, root, NULL);
128 efl_ui_focus_manager_calc_register(m, north_west, root, NULL);
129 efl_ui_focus_manager_calc_register(m, south_east, root, NULL);
130 efl_ui_focus_manager_calc_register(m, south_west, root, NULL);
131
132 rel = efl_ui_focus_manager_fetch(m, middle);
133
134#define ck_assert_set_eq(set, ...) \
135 { \
136 Efl_Ui_Focus_Object *tmp[] = { __VA_ARGS__ }; \
137 ck_assert_int_eq(_equal_set(set, tmp), EINA_TRUE); \
138 }
139
140 ck_assert_set_eq(rel->left, north_west, south_west, NULL);
141 ck_assert_set_eq(rel->right, north_east, south_east, NULL);
142 ck_assert_set_eq(rel->top, north_west, north_east, NULL);
143 ck_assert_set_eq(rel->down, south_west, south_east, NULL);
144
145#undef ck_assert_set_eq
146
147 efl_ui_focus_relation_free(rel);
148
149 efl_unref(middle);
150 efl_unref(north_east);
151 efl_unref(north_west);
152 efl_unref(south_east);
153 efl_unref(south_west);
154
155}
156EFL_END_TEST
157EFL_START_TEST(redirect)
158{
159 TEST_OBJ_NEW(root, 0, 0, 20, 20);
160 TEST_OBJ_NEW(root2, 0, 0, 20, 20);
161 TEST_OBJ_NEW(one, 0, 0, 20, 20);
162 TEST_OBJ_NEW(two, 20, 0, 20, 20);
163
164 Efl_Ui_Focus_Manager *m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
165 efl_ui_focus_manager_root_set(efl_added, root)
166 );
167
168 Efl_Ui_Focus_Manager *m2 = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
169 efl_ui_focus_manager_root_set(efl_added, root2)
170 );
171
172 efl_ui_focus_manager_calc_register(m2, one, root2, NULL);
173 efl_ui_focus_manager_calc_register(m2, two, root2, NULL);
174
175 efl_ui_focus_manager_redirect_set(m, m2);
176 efl_ui_focus_manager_focus_set(m2, one);
177
178 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_RIGHT), two);
179
180 efl_unref(m);
181 efl_unref(m2);
182}
183EFL_END_TEST
184
185EFL_START_TEST(border_check)
186{
187 Efl_Ui_Focus_Manager *m;
188 Efl_Ui_Focus_Object *middle, *east, *west, *north, *south, *root;
189 Eina_List *list = NULL;
190 Eina_Iterator *iter;
191 Efl_Ui_Focus_Object *obj;
192
193 focus_test_setup_cross(&middle, &south, &north, &east, &west);
194
195 m = focus_test_manager_new(&root);
196 efl_ui_focus_manager_calc_register(m, middle, root, NULL);
197 efl_ui_focus_manager_calc_register(m, south, root, NULL);
198 efl_ui_focus_manager_calc_register(m, north, root, NULL);
199 efl_ui_focus_manager_calc_register(m, east, root, NULL);
200 efl_ui_focus_manager_calc_register(m, west, root, NULL);
201
202 iter = efl_ui_focus_manager_border_elements_get(m);
203
204 EINA_ITERATOR_FOREACH(iter, obj)
205 {
206 list = eina_list_append(list, obj);
207 }
208
209 eina_iterator_free(iter);
210
211 ck_assert(eina_list_data_find(list, east) == east);
212 ck_assert(eina_list_data_find(list, north) == north);
213 ck_assert(eina_list_data_find(list, west) == west);
214 ck_assert(eina_list_data_find(list, east) == east);
215 ck_assert(eina_list_data_find(list, middle) == NULL);
216 ck_assert(eina_list_count(list) == 4);
217
218}
219EFL_END_TEST
220
221EFL_START_TEST(logical_chain)
222{
223 Efl_Ui_Focus_Manager *m;
224 Efl_Ui_Focus_Object *lroot;
225 int i = 0;
226
227 TEST_OBJ_NEW(root, 0, 0, 20, 20);
228
229 m = focus_test_manager_new(&lroot);
230
231 fail_if(!m);
232
233 i++;
234 TEST_OBJ_NEW(child1, 0, i*20, 20, 20);
235 i++;
236 TEST_OBJ_NEW(child2, 0, i*20, 20, 20);
237 i++;
238 TEST_OBJ_NEW(child3, 0, i*20, 20, 20);
239
240 i++;
241 TEST_OBJ_NEW(subchild11, 0, i*20, 20, 20);
242 i++;
243 TEST_OBJ_NEW(subchild12, 0, i*20, 20, 20);
244 i++;
245 TEST_OBJ_NEW(subchild13, 0, i*20, 20, 20);
246
247 i++;
248 TEST_OBJ_NEW(subchild21, 0, i*20, 20, 20);
249 i++;
250 TEST_OBJ_NEW(subchild22, 0, i*20, 20, 20);
251 i++;
252 TEST_OBJ_NEW(subchild23, 0, i*20, 20, 20);
253
254 //register everything
255 efl_ui_focus_manager_calc_register(m, root, lroot, NULL);
256 efl_ui_focus_manager_calc_register(m, child1, root, NULL);
257 efl_ui_focus_manager_calc_register(m, child2, root, NULL);
258 efl_ui_focus_manager_calc_register_logical(m, child3, root, NULL);
259 efl_ui_focus_manager_calc_register(m, subchild11, child1, NULL);
260 efl_ui_focus_manager_calc_register(m, subchild12, child1, NULL);
261 efl_ui_focus_manager_calc_register(m, subchild13, child1, NULL);
262 efl_ui_focus_manager_calc_register(m, subchild21, child3, NULL);
263 efl_ui_focus_manager_calc_register(m, subchild22, child3, NULL);
264 efl_ui_focus_manager_calc_register(m, subchild23, child3, NULL);
265
266 efl_ui_focus_manager_focus_set(m, root);
267
268 Efl_Object *logical_chain[] = {
269 child1, subchild11, subchild12, subchild13,
270 child2, subchild21, subchild22, subchild23, NULL
271 };
272 for (i = 0; logical_chain[i]; ++i)
273 {
274 ck_assert_ptr_eq(logical_chain[i], efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT));
275 }
276 i-= 2;
277 for (; i > 0; --i)
278 {
279 ck_assert_ptr_eq(logical_chain[i], efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS));
280 }
281}
282EFL_END_TEST
283
284static void
285_check_chain(Efl_Ui_Focus_Manager *m, Efl_Ui_Focus_Object *objects[])
286{
287 int i;
288 for (i = 0; objects[i]; ++i)
289 {
290 Efl_Ui_Focus_Object *next;
291
292 if (i > 0)
293 efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT);
294 else
295 {
296 Eo *root = efl_ui_focus_manager_root_get(m);
297 efl_ui_focus_manager_reset_history(m);
298 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_NEXT, root);
299 }
300 next = efl_ui_focus_manager_focus_get(efl_ui_focus_util_active_manager(EFL_UI_FOCUS_UTIL_CLASS, m));
301
302 ck_assert_ptr_eq(next, objects[i]);
303 }
304
305 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_NEXT), NULL);
306
307 for (; i > 0; i--)
308 {
309 Efl_Ui_Focus_Object *prev;
310
311 if (!!objects[i])
312 efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS);
313 else
314 {
315 Eo *root = efl_ui_focus_manager_root_get(m);
316 efl_ui_focus_manager_reset_history(m);
317 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, root);
318 }
319
320 prev = efl_ui_focus_manager_focus_get(efl_ui_focus_util_active_manager(EFL_UI_FOCUS_UTIL_CLASS, m));
321 ck_assert_ptr_eq(prev, objects[i - 1]);
322 }
323 ck_assert_ptr_eq(efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS), NULL);
324}
325
326EFL_START_TEST(logical_chain_multi_redirect)
327{
328 Efl_Ui_Focus_Manager *m, *m2, *m3, *m4;
329 Efl_Ui_Focus_Object *root,*root2, *root3, *root4, *c1_1, *c1_2, *c1_3, *c2, *c3, *c4;
330
331 m = focus_test_manager_new(&root);
332 m2 = focus_test_manager_new(&root2);
333 m3 = focus_test_manager_new(&root3);
334 m4 = focus_test_manager_new(&root4);
335 c1_1 = focus_test_object_new("child1", 0, 0, 20, 20);
336 c1_2 = focus_test_object_new("child2", 0, 0, 20, 20);
337 c1_3 = focus_test_object_new("child3", 0, 0, 20, 20);
338 focus_test_manager_set(c1_1, m2);
339 focus_test_manager_set(c1_2, m3);
340 focus_test_manager_set(c1_3, m4);
341 c2 = focus_test_object_new("child1", 0, 0, 20, 20);
342 c3 = focus_test_object_new("child2", 0, 0, 20, 20);
343 c4 = focus_test_object_new("child3", 0, 0, 20, 20);
344
345 Efl_Ui_Focus_Object *objects[] = {c2, c3, c4, NULL};
346
347 efl_ui_focus_manager_calc_register(m, c1_1, root, m2);
348 efl_ui_focus_manager_calc_register(m, c1_2, root, m3);
349 efl_ui_focus_manager_calc_register(m, c1_3, root, m4);
350
351 efl_ui_focus_manager_calc_register(m2, c2, root2, NULL);
352 efl_ui_focus_manager_calc_register(m3, c3, root3, NULL);
353 efl_ui_focus_manager_calc_register(m4, c4, root4, NULL);
354
355 _check_chain(m, objects);
356
357 efl_unref(m2);
358 efl_unref(m);
359}
360EFL_END_TEST
361
362EFL_START_TEST(logical_chain_single_redirect)
363{
364 Efl_Ui_Focus_Manager *m, *m2;
365 Efl_Ui_Focus_Object *root,*root2, *c1_1, *c1_2, *c1_3, *c2_1, *c2_2, *c2_3;
366
367 m = focus_test_manager_new(&root);
368 m2 = focus_test_manager_new(&root2);
369 c1_1 = focus_test_object_new("child1", 0, 0, 20, 20);
370 c1_2 = focus_test_object_new("child2", 0, 0, 20, 20);
371 focus_test_manager_set(c1_2, m2);
372 c1_3 = focus_test_object_new("child3", 0, 0, 20, 20);
373 c2_1 = focus_test_object_new("child1", 0, 0, 20, 20);
374 c2_2 = focus_test_object_new("child2", 0, 0, 20, 20);
375 c2_3 = focus_test_object_new("child3", 0, 0, 20, 20);
376
377 Efl_Ui_Focus_Object *objects[] = {c1_1, c2_1, c2_2, c2_3, c1_3, NULL};
378
379 efl_ui_focus_manager_calc_register(m, c1_1, root, NULL);
380 efl_ui_focus_manager_calc_register(m, c1_2, root, m2);
381 efl_ui_focus_manager_calc_register(m, c1_3, root, NULL);
382
383 efl_ui_focus_manager_calc_register(m2, c2_1, root2, NULL);
384 efl_ui_focus_manager_calc_register(m2, c2_2, root2, NULL);
385 efl_ui_focus_manager_calc_register(m2, c2_3, root2, NULL);
386
387 _check_chain(m, objects);
388
389 efl_unref(m2);
390 efl_unref(m);
391}
392EFL_END_TEST
393
394EFL_START_TEST(finalize_check)
395{
396 Efl_Ui_Focus_Manager *m;
397
398 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL);
399 fail_if(m);
400
401 efl_unref(m);
402}
403EFL_END_TEST
404
405EFL_START_TEST(redirect_param)
406{
407 Efl_Ui_Focus_Manager *m, *m2;
408
409 TEST_OBJ_NEW(root, 0, 20, 20, 20);
410 TEST_OBJ_NEW(root2, 0, 20, 20, 20);
411 TEST_OBJ_NEW(child, 0, 20, 20, 20);
412
413 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
414 efl_ui_focus_manager_root_set(efl_added, root)
415 );
416
417 m2 = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
418 efl_ui_focus_manager_root_set(efl_added, root2)
419 );
420
421 efl_ui_focus_manager_calc_register(m, child, root, m2);
422 efl_ui_focus_manager_focus_set(m, child);
423
424 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
425
426 efl_unref(m);
427 efl_unref(m2);
428}
429EFL_END_TEST
430
431EFL_START_TEST(invalid_args_check)
432{
433 Efl_Ui_Focus_Manager *m;
434
435 TEST_OBJ_NEW(root, 0, 20, 20, 20);
436 TEST_OBJ_NEW(child, 0, 20, 20, 20);
437 TEST_OBJ_NEW(child2, 0, 20, 20, 20);
438
439 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
440 efl_ui_focus_manager_root_set(efl_added, root)
441 );
442
443 //no child and no parent
444 ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, NULL, NULL, NULL), 0);
445 ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, child, NULL, NULL), 0);
446 ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, NULL, root, NULL), 0);
447
448 ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, child, root, NULL), 1);
449
450 ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, child, NULL), 0);
451 ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, NULL, NULL), 0);
452 ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, child, child2), 0);
453
454 ck_assert_int_eq(efl_ui_focus_manager_calc_register(m, child2, root, NULL), 1);
455 ck_assert_int_eq(efl_ui_focus_manager_calc_update_parent(m, child, child2), 1);
456
457 efl_unref(m);
458}
459EFL_END_TEST
460
461EFL_START_TEST(order_check)
462{
463 Efl_Ui_Focus_Manager *m;
464 Eina_List *order = NULL;
465
466 TEST_OBJ_NEW(root, 0, 20, 20, 20);
467 TEST_OBJ_NEW(child1, 0, 20, 20, 20);
468 TEST_OBJ_NEW(child2, 0, 20, 20, 20);
469 TEST_OBJ_NEW(child3, 0, 20, 20, 20);
470
471 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
472 efl_ui_focus_manager_root_set(efl_added, root)
473 );
474
475 //no child and no parent
476 efl_ui_focus_manager_calc_register(m, child1, root, NULL);
477 efl_ui_focus_manager_calc_register(m, child2, root, NULL);
478 efl_ui_focus_manager_calc_register(m, child3, root, NULL);
479
480 //positiv check
481 order = eina_list_append(order, child2);
482 order = eina_list_append(order, child3);
483 order = eina_list_append(order, child1);
484 ck_assert_int_eq(efl_ui_focus_manager_calc_update_children(m, root, order), 1);
485
486 order = NULL;
487
488 //negativ check
489 order = eina_list_append(order, child1);
490 order = eina_list_append(order, child2);
491 ck_assert_int_eq(efl_ui_focus_manager_calc_update_children(m, root, order), 0);
492
493 efl_unref(m);
494}
495EFL_END_TEST
496
497EFL_START_TEST(logical_shift)
498{
499 Efl_Ui_Focus_Manager *m;
500
501 TEST_OBJ_NEW(root, 0, 0, 10, 10);
502 TEST_OBJ_NEW(child, 0, 0, 10, 10);
503 TEST_OBJ_NEW(sub, 0, 0, 10, 10);
504 TEST_OBJ_NEW(sub_sub, 0, 0, 10, 10);
505 TEST_OBJ_NEW(sub_child, 0, 0, 10, 10);
506
507 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
508 efl_ui_focus_manager_root_set(efl_added, root)
509 );
510
511 efl_ui_focus_manager_calc_register(m, child, root, NULL);
512 efl_ui_focus_manager_calc_register_logical(m, sub, root, NULL);
513 efl_ui_focus_manager_calc_register_logical(m, sub_sub, sub, NULL);
514 efl_ui_focus_manager_calc_register(m, sub_child, sub, NULL);
515
516 efl_ui_focus_manager_focus_set(m, root);
517 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), child);
518
519 efl_ui_focus_manager_focus_set(m, sub);
520 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), sub_child);
521
522 efl_ui_focus_manager_focus_set(m, sub_sub);
523 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), sub_child);
524
525 efl_unref(m);
526}
527EFL_END_TEST
528
529EFL_START_TEST(root_redirect_chain)
530{
531 Efl_Ui_Focus_Manager *m, *m2;
532
533 TEST_OBJ_NEW(root, 0, 20, 20, 20);
534 TEST_OBJ_NEW(root2, 0, 20, 20, 20);
535 TEST_OBJ_NEW(child, 0, 20, 20, 20);
536
537 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
538 efl_ui_focus_manager_root_set(efl_added, root)
539 );
540
541 focus_test_manager_set(root2, m);
542
543 m2 = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
544 efl_ui_focus_manager_root_set(efl_added, root2)
545 );
546
547 efl_ui_focus_manager_calc_register(m, root2, root, m2);
548 efl_ui_focus_manager_calc_register(m2, child, root2, NULL);
549 efl_ui_focus_manager_focus_set(m2, child);
550
551 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
552
553 efl_unref(m);
554 efl_unref(m2);
555}
556EFL_END_TEST
557
558EFL_START_TEST(root_redirect_chain_unset)
559{
560 Efl_Ui_Focus_Manager *m, *m2, *m3, *m4;
561
562 TEST_OBJ_NEW(root, 0, 20, 20, 20);
563 TEST_OBJ_NEW(root2, 0, 20, 20, 20);
564 TEST_OBJ_NEW(child, 0, 20, 20, 20);
565
566 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
567 efl_ui_focus_manager_root_set(efl_added, root)
568 );
569
570 focus_test_manager_set(root2, m);
571
572 m2 = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
573 efl_ui_focus_manager_root_set(efl_added, root2)
574 );
575
576 m3 = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
577 efl_ui_focus_manager_root_set(efl_added, root2)
578 );
579
580 m4 = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
581 efl_ui_focus_manager_root_set(efl_added, root2)
582 );
583
584 efl_ui_focus_manager_redirect_set(m, m3);
585 efl_ui_focus_manager_redirect_set(m3, m4);
586 efl_ui_focus_manager_redirect_set(m4, m2);
587
588 efl_ui_focus_manager_calc_register(m, root2, root, m2);
589 efl_ui_focus_manager_calc_register(m2, child, root2, NULL);
590 efl_ui_focus_manager_focus_set(m2, child);
591
592 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
593 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m2), NULL);
594 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m3), NULL);
595 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m4), NULL);
596
597 efl_unref(m);
598 efl_unref(m2);
599 efl_unref(m3);
600 efl_unref(m4);
601}
602EFL_END_TEST
603
604static Efl_Ui_Focus_Manager_Calc*
605_recursive_triangle_manager(int recusion_depth, Efl_Ui_Focus_Object **most_right, Efl_Ui_Focus_Object **most_left, Eina_List **managers)
606{
607 Efl_Ui_Focus_Manager *m, *m_child1 = NULL, *m_child3 = NULL;
608 Efl_Ui_Focus_Object *child1, *child3;
609
610 TEST_OBJ_NEW(root, 0, 20, 20, 20);
611 TEST_OBJ_NEW(child2, 0, 20, 20, 20);
612
613 m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
614 efl_ui_focus_manager_root_set(efl_added, root)
615 );
616
617 printf("New manaager %p\n", m);
618
619 if (recusion_depth < 3)
620 {
621 m_child1 = _recursive_triangle_manager(recusion_depth + 1, NULL, most_left, managers);
622 m_child3 = _recursive_triangle_manager(recusion_depth + 1, most_right, NULL, managers);
623 child1 = efl_ui_focus_manager_root_get(m_child1);
624 child3 = efl_ui_focus_manager_root_get(m_child3);
625 focus_test_manager_set(child1, m);
626 focus_test_manager_set(child3, m);
627 }
628 else
629 {
630 TEST_OBJ_NEW(tmp_child1, 0, 20, 20, 20);
631 TEST_OBJ_NEW(tmp_child3, 0, 20, 20, 20);
632
633 child1 = tmp_child1;
634 child3 = tmp_child3;
635
636 if (most_left)
637 {
638 *most_left = child1;
639 printf("SETTING %p\n", child1);
640 }
641
642 if (most_right)
643 {
644 *most_right = child3;
645 printf("SETTING %p\n", child3);
646 }
647 }
648
649 printf("Child 1 %p\n", child1);
650 printf("Child 2 %p\n", child2);
651 printf("Child 3 %p\n", child3);
652
653 efl_ui_focus_manager_calc_register(m, child1, root, m_child1);
654 efl_ui_focus_manager_calc_register(m, child2, root, NULL);
655 efl_ui_focus_manager_calc_register(m, child3, root, m_child3);
656
657 *managers = eina_list_append(*managers , m);
658
659 return m;
660}
661
662static Efl_Ui_Focus_Object*
663_get_highest_redirect(Efl_Ui_Focus_Manager *manager)
664{
665 Efl_Ui_Focus_Manager *tmp = manager;
666
667 do {
668 manager = tmp;
669 tmp = efl_ui_focus_manager_redirect_get(tmp);
670 } while (tmp);
671
672 return manager;
673}
674
675EFL_START_TEST(first_touch_check)
676{
677 Efl_Ui_Focus_Manager *m;
678 Efl_Ui_Focus_Object *most_left, *most_right;
679 Eina_List *managers = NULL;
680
681 m = _recursive_triangle_manager(0, &most_right, &most_left, &managers);
682
683 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_NEXT, efl_ui_focus_manager_root_get(m));
684 printf("%p %p\n", most_left, most_right);
685
686 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(_get_highest_redirect(m)), most_left);
687
688 efl_ui_focus_manager_reset_history(m);
689
690 efl_ui_focus_manager_setup_on_first_touch(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, efl_ui_focus_manager_root_get(m));
691 printf("%s\n", efl_name_get(efl_ui_focus_manager_focus_get(_get_highest_redirect(m))));
692 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(_get_highest_redirect(m)), most_right);
693
694 EINA_LIST_FREE(managers, m)
695 efl_unref(m);
696}
697EFL_END_TEST
698
699EFL_START_TEST(test_request_subchild_empty)
700{
701 Efl_Ui_Focus_Manager *m;
702 Efl_Ui_Focus_Object *root;
703
704 m = focus_test_manager_new(&root);
705
706 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), NULL);
707
708 efl_unref(m);
709}
710EFL_END_TEST
711
712EFL_START_TEST(test_request_subchild_one_element)
713{
714 Efl_Ui_Focus_Manager *m;
715 Efl_Ui_Focus_Object *root, *c1;
716
717 m = focus_test_manager_new(&root);
718 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
719 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
720
721 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c1);
722 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), NULL);
723
724 efl_unref(m);
725}
726EFL_END_TEST
727
728EFL_START_TEST(test_request_subchild_child_alongside)
729{
730 Efl_Ui_Focus_Manager *m;
731 Efl_Ui_Focus_Object *root, *c1, *c2;
732
733 m = focus_test_manager_new(&root);
734 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
735 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
736 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
737 efl_ui_focus_manager_calc_register(m, c2, root, NULL);
738
739 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c1);
740 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), NULL);
741 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c2), NULL);
742
743 efl_unref(m);
744}
745EFL_END_TEST
746
747EFL_START_TEST(test_request_subchild_child_logical_regular)
748{
749 Efl_Ui_Focus_Manager *m;
750 Efl_Ui_Focus_Object *root, *c1, *c2;
751
752 m = focus_test_manager_new(&root);
753 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
754 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
755 efl_ui_focus_manager_calc_register_logical(m, c1, root, NULL);
756 efl_ui_focus_manager_calc_register(m, c2, c1, NULL);
757
758 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c2);
759 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), c2);
760 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c2), NULL);
761
762 efl_unref(m);
763}
764EFL_END_TEST
765
766EFL_START_TEST(test_request_subchild_child_regular_regular)
767{
768 Efl_Ui_Focus_Manager *m;
769 Efl_Ui_Focus_Object *root, *c1, *c2;
770
771 m = focus_test_manager_new(&root);
772 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
773 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
774 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
775 efl_ui_focus_manager_calc_register(m, c2, c1, NULL);
776
777 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, root), c1);
778 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c1), c2);
779 ck_assert_ptr_eq(efl_ui_focus_manager_request_subchild(m, c2), NULL);
780
781 efl_unref(m);
782}
783EFL_END_TEST
784
785EFL_START_TEST(test_unregister_last_focused_no_history)
786{
787 Efl_Ui_Focus_Manager *m;
788 Efl_Ui_Focus_Object *root, *c1, *c2, *c3;
789
790 m = focus_test_manager_new(&root);
791 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
792 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
793 c3 = focus_test_object_new("child3", 0, 0, 20, 20);
794 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
795 efl_ui_focus_manager_calc_register(m, c2, root, NULL);
796 efl_ui_focus_manager_calc_register(m, c3, root, NULL);
797
798 efl_ui_focus_manager_focus_set(m, c2);
799 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
800
801 efl_ui_focus_manager_calc_unregister(m, c2);
802 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
803
804 efl_unref(m);
805}
806EFL_END_TEST
807
808EFL_START_TEST(test_unregister_last_focused)
809{
810 Efl_Ui_Focus_Manager *m;
811 Efl_Ui_Focus_Object *root, *c1, *c2, *c3;
812
813 m = focus_test_manager_new(&root);
814 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
815 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
816 c3 = focus_test_object_new("child3", 0, 0, 20, 20);
817 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
818 efl_ui_focus_manager_calc_register(m, c2, root, NULL);
819 efl_ui_focus_manager_calc_register(m, c3, root, NULL);
820
821 efl_ui_focus_manager_focus_set(m, c2);
822 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
823 efl_ui_focus_manager_focus_set(m, c3);
824 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c3);
825
826 efl_ui_focus_manager_calc_unregister(m, c3);
827 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
828
829 efl_unref(m);
830}
831EFL_END_TEST
832
833EFL_START_TEST(test_unregister_last_focused_no_child)
834{
835 Efl_Ui_Focus_Manager *m;
836 Efl_Ui_Focus_Object *root, *c1;
837
838 m = focus_test_manager_new(&root);
839 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
840 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
841
842 efl_ui_focus_manager_focus_set(m, c1);
843 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
844 efl_ui_focus_manager_calc_unregister(m, c1);
845 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), NULL);
846
847 efl_unref(m);
848}
849EFL_END_TEST
850
851EFL_START_TEST(test_pop_history_element)
852{
853 Efl_Ui_Focus_Manager *m;
854 Efl_Ui_Focus_Object *root, *c1, *c2, *c3;
855
856 m = focus_test_manager_new(&root);
857 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
858 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
859 c3 = focus_test_object_new("child3", 0, 0, 20, 20);
860 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
861 efl_ui_focus_manager_calc_register(m, c2, root, NULL);
862 efl_ui_focus_manager_calc_register(m, c3, root, NULL);
863
864 efl_ui_focus_manager_focus_set(m, c2);
865 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
866 ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_TRUE);
867
868 efl_ui_focus_manager_pop_history_stack(m);
869 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
870 ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_FALSE);
871
872 efl_ui_focus_manager_focus_set(m, c1);
873 efl_ui_focus_manager_focus_set(m, c2);
874 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c2);
875 ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_TRUE);
876 efl_ui_focus_manager_pop_history_stack(m);
877 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
878 ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_FALSE);
879 ck_assert_int_eq(efl_ui_focus_object_focus_get(c1), EINA_TRUE);
880
881 efl_unref(m);
882}
883EFL_END_TEST
884
885static void
886_focus_request_tree_check(Efl_Ui_Focus_Manager *m, Eina_Bool accept_logicals, Efl_Ui_Focus_Object *objs[])
887{
888 int i = 0;
889 for (i = 1; objs[i]; ++i)
890 {
891 ck_assert_ptr_eq(efl_ui_focus_manager_request_move(m, EFL_UI_FOCUS_DIRECTION_NEXT, objs[i], accept_logicals), objs[i + 1]);
892 }
893 i--;
894 for (; i > 0; --i)
895 {
896 ck_assert_ptr_eq(efl_ui_focus_manager_request_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS, objs[i], accept_logicals), objs[i - 1]);
897 }
898}
899
900EFL_START_TEST(test_request_move)
901{
902 Efl_Ui_Focus_Manager *m;
903 Efl_Ui_Focus_Object *root, *c1, *c2, *c3, *c4, *c5, *c6;
904
905 m = focus_test_manager_new(&root);
906 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
907 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
908 c3 = focus_test_object_new("child3", 0, 0, 20, 20);
909 c4 = focus_test_object_new("child4", 0, 0, 20, 20);
910 c5 = focus_test_object_new("child5", 0, 0, 20, 20);
911 c6 = focus_test_object_new("child6", 0, 0, 20, 20);
912
913 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
914 efl_ui_focus_manager_calc_register_logical(m, c2, root, NULL);
915 efl_ui_focus_manager_calc_register(m, c3, c2, NULL);
916 efl_ui_focus_manager_calc_register(m, c4, c2, NULL);
917 efl_ui_focus_manager_calc_register(m, c5, c2, NULL);
918 efl_ui_focus_manager_calc_register(m, c6, root, NULL);
919
920 // c3 c4 c5
921 // \ | /
922 // \ | /
923 // c1 c2 c6
924 // \ | /
925 // rooot
926
927 Efl_Ui_Focus_Object *objs_logical[] = {NULL, root, c1, c2, c3, c4, c5, c6, NULL};
928 _focus_request_tree_check(m, EINA_TRUE, objs_logical);
929
930 Efl_Ui_Focus_Object *objs_regular[] = {NULL, c1, c3, c4, c5, c6, NULL};
931 _focus_request_tree_check(m, EINA_FALSE, objs_regular);
932
933}
934EFL_END_TEST
935
936EFL_START_TEST(redirect_unregister_entrypoint)
937{
938 Efl_Ui_Focus_Manager *m, *m2;
939
940 TEST_OBJ_NEW(root, 0, 20, 20, 20);
941 TEST_OBJ_NEW(root2, 0, 20, 20, 20);
942 TEST_OBJ_NEW(child, 0, 20, 20, 20);
943 TEST_OBJ_NEW(child2, 0, 20, 20, 20);
944 TEST_OBJ_NEW(child3, 0, 20, 20, 20);
945
946 m = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, efl_main_loop_get(),
947 efl_ui_focus_manager_root_set(efl_added, root)
948 );
949
950 m2 = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, efl_main_loop_get(),
951 efl_ui_focus_manager_root_set(efl_added, root2)
952 );
953
954
955 efl_ui_focus_manager_calc_register(m2, child3, root2, m2);
956
957 efl_ui_focus_manager_calc_register(m, child, root, m2);
958 efl_ui_focus_manager_calc_register(m, child2, root, NULL);
959 efl_ui_focus_manager_focus_set(m, child);
960
961 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
962 efl_ui_focus_manager_calc_unregister(m, child);
963 ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
964 ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), NULL);
965
966 efl_del(m);
967 efl_del(m2);
968}
969EFL_END_TEST
970
971static void
972_child_focus_changed(void *data, const Efl_Event *ev)
973{
974 Eina_Bool *flag = data;
975
976 *flag = EINA_TRUE;
977
978 printf("%s\n", efl_class_name_get(ev->object));
979}
980
981EFL_START_TEST(test_events_child_focus)
982{
983 Efl_Ui_Focus_Manager *m;
984 Efl_Ui_Focus_Object *root, *c1, *c2, *c3, *c4, *c5, *c6;
985 Eina_Bool froot = EINA_FALSE, fc1 = EINA_FALSE, fc2 = EINA_FALSE,
986 fc3 = EINA_FALSE, fc4 = EINA_FALSE, fc5 = EINA_FALSE, fc6 = EINA_FALSE;
987
988 m = focus_test_manager_new(&root);
989 c1 = focus_test_object_new("child1", 0, 0, 20, 20);
990 efl_parent_set(c1, root);
991 c2 = focus_test_object_new("child2", 0, 0, 20, 20);
992 efl_parent_set(c2, root);
993 c3 = focus_test_object_new("child3", 0, 0, 20, 20);
994 efl_parent_set(c3, c2);
995 c4 = focus_test_object_new("child4", 0, 0, 20, 20);
996 efl_parent_set(c4, c2);
997 c5 = focus_test_object_new("child5", 0, 0, 20, 20);
998 efl_parent_set(c5, root);
999 c6 = focus_test_object_new("child6", 0, 0, 20, 20);
1000 efl_parent_set(c6, c5);
1001
1002 efl_ui_focus_manager_calc_register(m, c1, root, NULL);
1003 efl_ui_focus_manager_calc_register_logical(m, c2, root, NULL);
1004 efl_ui_focus_manager_calc_register(m, c3, c2, NULL);
1005 efl_ui_focus_manager_calc_register(m, c4, c2, NULL);
1006 efl_ui_focus_manager_calc_register_logical(m, c5, root, NULL);
1007 efl_ui_focus_manager_calc_register(m, c6, c5, NULL);
1008
1009 // c3 c4 c6
1010 // \ | |
1011 // \ | |
1012 // c1 c2 c5
1013 // \ | /
1014 // root
1015
1016 efl_ui_focus_manager_focus_set(m, c4);
1017
1018 ck_assert_int_eq(froot, EINA_FALSE);
1019 ck_assert_int_eq(fc1, EINA_FALSE);
1020 ck_assert_int_eq(fc2, EINA_FALSE);
1021 ck_assert_int_eq(fc3, EINA_FALSE);
1022 ck_assert_int_eq(fc4, EINA_FALSE);
1023 ck_assert_int_eq(fc5, EINA_FALSE);
1024 ck_assert_int_eq(fc6, EINA_FALSE);
1025
1026 efl_event_callback_add(root, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &froot);
1027 efl_event_callback_add(c1, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc1);
1028 efl_event_callback_add(c2, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc2);
1029 efl_event_callback_add(c3, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc3);
1030 efl_event_callback_add(c4, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc4);
1031 efl_event_callback_add(c5, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc5);
1032 efl_event_callback_add(c6, EFL_UI_FOCUS_OBJECT_EVENT_CHILD_FOCUS_CHANGED, _child_focus_changed, &fc6);
1033 efl_ui_focus_manager_focus_set(m, c1);
1034
1035 ck_assert_int_eq(froot, EINA_FALSE);
1036 ck_assert_int_eq(fc1, EINA_FALSE);
1037 ck_assert_int_eq(fc2, EINA_TRUE);
1038 ck_assert_int_eq(fc3, EINA_FALSE);
1039 ck_assert_int_eq(fc4, EINA_FALSE);
1040 ck_assert_int_eq(fc5, EINA_FALSE);
1041 ck_assert_int_eq(fc6, EINA_FALSE);
1042 froot = EINA_FALSE;
1043 fc1 = EINA_FALSE;
1044 fc2 = EINA_FALSE;
1045 fc3 = EINA_FALSE;
1046 fc4 = EINA_FALSE;
1047 fc5 = EINA_FALSE;
1048 fc6 = EINA_FALSE;
1049
1050 efl_ui_focus_manager_focus_set(m, c6);
1051
1052 ck_assert_int_eq(froot, EINA_FALSE);
1053 ck_assert_int_eq(fc1, EINA_FALSE);
1054 ck_assert_int_eq(fc2, EINA_FALSE);
1055 ck_assert_int_eq(fc3, EINA_FALSE);
1056 ck_assert_int_eq(fc4, EINA_FALSE);
1057 ck_assert_int_eq(fc5, EINA_TRUE);
1058 ck_assert_int_eq(fc6, EINA_FALSE);
1059 froot = EINA_FALSE;
1060 fc1 = EINA_FALSE;
1061 fc2 = EINA_FALSE;
1062 fc3 = EINA_FALSE;
1063 fc4 = EINA_FALSE;
1064 fc5 = EINA_FALSE;
1065 fc6 = EINA_FALSE;
1066
1067 efl_ui_focus_manager_focus_set(m, c3);
1068
1069 ck_assert_int_eq(froot, EINA_FALSE);
1070 ck_assert_int_eq(fc1, EINA_FALSE);
1071 ck_assert_int_eq(fc2, EINA_TRUE);
1072 ck_assert_int_eq(fc3, EINA_FALSE);
1073 ck_assert_int_eq(fc4, EINA_FALSE);
1074 ck_assert_int_eq(fc5, EINA_TRUE);
1075 ck_assert_int_eq(fc6, EINA_FALSE);
1076}
1077EFL_END_TEST
1078
1079
1080EFL_START_TEST(viewport_check)
1081{
1082 Efl_Ui_Focus_Manager *m;
1083 Efl_Ui_Focus_Object *middle, *east, *west, *north, *south, *root;
1084 Eina_List *list = NULL;
1085 Eina_Iterator *iter;
1086 Efl_Ui_Focus_Object *obj;
1087
1088 focus_test_setup_cross(&middle, &south, &north, &east, &west);
1089
1090 m = focus_test_manager_new(&root);
1091 efl_ui_focus_manager_calc_register(m, middle, root, NULL);
1092 efl_ui_focus_manager_calc_register(m, south, root, NULL);
1093 efl_ui_focus_manager_calc_register(m, north, root, NULL);
1094 efl_ui_focus_manager_calc_register(m, east, root, NULL);
1095 efl_ui_focus_manager_calc_register(m, west, root, NULL);
1096
1097 iter = efl_ui_focus_manager_viewport_elements_get(m, EINA_RECT(80, 0, 100, 100));
1098
1099 EINA_ITERATOR_FOREACH(iter, obj)
1100 {
1101 list = eina_list_append(list, obj);
1102 }
1103
1104 eina_iterator_free(iter);
1105
1106 ck_assert(eina_list_count(list) == 1);
1107 ck_assert_ptr_eq(eina_list_data_get(list), east);
1108}
1109EFL_END_TEST
1110
1111void efl_ui_test_focus(TCase *tc)
1112{
1113 tcase_add_test(tc, focus_register_twice);
1114 tcase_add_test(tc, focus_unregister_twice);
1115 tcase_add_test(tc, pos_check);
1116 tcase_add_test(tc, pos_check2);
1117 tcase_add_test(tc, redirect);
1118 tcase_add_test(tc, border_check);
1119 tcase_add_test(tc, finalize_check);
1120 tcase_add_test(tc, logical_chain);
1121 tcase_add_test(tc, logical_chain_multi_redirect);
1122 tcase_add_test(tc, logical_chain_single_redirect);
1123 tcase_add_test(tc, redirect_param);
1124 tcase_add_test(tc, invalid_args_check);
1125 tcase_add_test(tc, order_check);
1126 tcase_add_test(tc, logical_shift);
1127 tcase_add_test(tc, root_redirect_chain);
1128 tcase_add_test(tc, root_redirect_chain_unset);
1129 tcase_add_test(tc, first_touch_check);
1130 tcase_add_test(tc, test_request_subchild_empty);
1131 tcase_add_test(tc, test_request_subchild_one_element);
1132 tcase_add_test(tc, test_request_subchild_child_alongside);
1133 tcase_add_test(tc, test_request_subchild_child_logical_regular);
1134 tcase_add_test(tc, test_request_subchild_child_regular_regular);
1135 tcase_add_test(tc, test_unregister_last_focused_no_history);
1136 tcase_add_test(tc, test_unregister_last_focused);
1137 tcase_add_test(tc, test_unregister_last_focused_no_child);
1138 tcase_add_test(tc, test_pop_history_element);
1139 tcase_add_test(tc, test_request_move);
1140 tcase_add_test(tc, redirect_unregister_entrypoint);
1141 tcase_add_test(tc, test_events_child_focus);
1142 tcase_add_test(tc, viewport_check);
1143}