summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-02 10:26:40 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-06 16:10:40 +0200
commit588745e9956ba622aadc9fe6f11988a372687d39 (patch)
treea9fd09013d9ae94db44582ddb8cc3f674d94eea4 /src/tests
parentb36e159d313bae4a6dd4e0c60deae0aef2309b50 (diff)
efl_ui_spotlight: migrate from active_index to active_element
after playing arround with the widget, we found out that it feels quite weird to have a index, where most of the time you work with widgets. We might want to add syntax suger in the future to make it easier to just jump to the next element, or to the previous, but that still is to be decided. The event and the communication to the spotlight manager are still left to be used with the index, reason for this is, that we might need to fill there an invalid pointer, if a deletion is triggering an animation, which seems quite weird. That needs further discussing. Docx have been updated, the sitemarks about the shifting of the active_index can be removed, as the element is not subject of change during content adds/deletes. ref T7991 Reviewed-by: Jaehyun Cho <jae_hyun.cho@samsung.com> Differential Revision: https://phab.enlightenment.org/D9813
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/elementary/efl_ui_test_spotlight.c77
1 files changed, 43 insertions, 34 deletions
diff --git a/src/tests/elementary/efl_ui_test_spotlight.c b/src/tests/elementary/efl_ui_test_spotlight.c
index 0bad5c362f..9749258273 100644
--- a/src/tests/elementary/efl_ui_test_spotlight.c
+++ b/src/tests/elementary/efl_ui_test_spotlight.c
@@ -21,13 +21,13 @@ typedef struct {
21 int called; 21 int called;
22 Efl_Gfx_Entity *subobj; 22 Efl_Gfx_Entity *subobj;
23 int index; 23 int index;
24 int current_page_at_call; 24 Efl_Ui_Widget *current_page_at_call;
25 } content_del; 25 } content_del;
26 struct { 26 struct {
27 int called; 27 int called;
28 Efl_Gfx_Entity *subobj; 28 Efl_Gfx_Entity *subobj;
29 int index; 29 int index;
30 int current_page_at_call; 30 Efl_Ui_Widget *current_page_at_call;
31 } content_add; 31 } content_add;
32 struct { 32 struct {
33 int called; 33 int called;
@@ -43,7 +43,7 @@ _indicator_content_del(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Gfx_Entity
43 indicator_calls.content_del.called ++; 43 indicator_calls.content_del.called ++;
44 indicator_calls.content_del.subobj = subobj; 44 indicator_calls.content_del.subobj = subobj;
45 indicator_calls.content_del.index = index; 45 indicator_calls.content_del.index = index;
46 indicator_calls.content_del.current_page_at_call = efl_ui_spotlight_active_index_get(container); 46 indicator_calls.content_del.current_page_at_call = efl_ui_spotlight_active_element_get(container);
47} 47}
48 48
49static void 49static void
@@ -52,7 +52,7 @@ _indicator_content_add(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Gfx_Entity
52 indicator_calls.content_add.called ++; 52 indicator_calls.content_add.called ++;
53 indicator_calls.content_add.subobj = subobj; 53 indicator_calls.content_add.subobj = subobj;
54 indicator_calls.content_add.index = index; 54 indicator_calls.content_add.index = index;
55 indicator_calls.content_add.current_page_at_call = efl_ui_spotlight_active_index_get(container); 55 indicator_calls.content_add.current_page_at_call = efl_ui_spotlight_active_element_get(container);
56} 56}
57 57
58static void 58static void
@@ -92,13 +92,13 @@ typedef struct {
92 int called; 92 int called;
93 Efl_Gfx_Entity *subobj; 93 Efl_Gfx_Entity *subobj;
94 int index; 94 int index;
95 int current_page_at_call; 95 Efl_Ui_Widget *current_page_at_call;
96 } content_del; 96 } content_del;
97 struct { 97 struct {
98 int called; 98 int called;
99 Efl_Gfx_Entity *subobj; 99 Efl_Gfx_Entity *subobj;
100 int index; 100 int index;
101 int current_page_at_call; 101 Efl_Ui_Widget *current_page_at_call;
102 } content_add; 102 } content_add;
103 struct { 103 struct {
104 int called; 104 int called;
@@ -125,7 +125,9 @@ Transition_Calls transition_calls = { 0 };
125static void 125static void
126_emit_pos(Eo *obj, double d) 126_emit_pos(Eo *obj, double d)
127{ 127{
128 printf("EMITTING %f %f\n", d, transition_calls.last_position);
128 if (d == transition_calls.last_position) return; 129 if (d == transition_calls.last_position) return;
130
129 efl_event_callback_call(obj, EFL_UI_SPOTLIGHT_MANAGER_EVENT_POS_UPDATE, &d); 131 efl_event_callback_call(obj, EFL_UI_SPOTLIGHT_MANAGER_EVENT_POS_UPDATE, &d);
130 transition_calls.last_position = d; 132 transition_calls.last_position = d;
131} 133}
@@ -136,9 +138,9 @@ _transition_content_add(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Gfx_Entit
136 transition_calls.content_add.called ++; 138 transition_calls.content_add.called ++;
137 transition_calls.content_add.subobj = subobj; 139 transition_calls.content_add.subobj = subobj;
138 transition_calls.content_add.index = index; 140 transition_calls.content_add.index = index;
139 transition_calls.content_add.current_page_at_call = efl_ui_spotlight_active_index_get(container); 141 transition_calls.content_add.current_page_at_call = efl_ui_spotlight_active_element_get(container);
140 142
141 int i = efl_ui_spotlight_active_index_get(container); 143 int i = efl_pack_index_get(container, efl_ui_spotlight_active_element_get(container));
142 if (i != -1) 144 if (i != -1)
143 _emit_pos(obj, i); 145 _emit_pos(obj, i);
144} 146}
@@ -149,9 +151,9 @@ _transition_content_del(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Gfx_Entit
149 transition_calls.content_del.called ++; 151 transition_calls.content_del.called ++;
150 transition_calls.content_del.subobj = subobj; 152 transition_calls.content_del.subobj = subobj;
151 transition_calls.content_del.index = index; 153 transition_calls.content_del.index = index;
152 transition_calls.content_del.current_page_at_call = efl_ui_spotlight_active_index_get(container); 154 transition_calls.content_del.current_page_at_call = efl_ui_spotlight_active_element_get(container);
153 155
154 int i = efl_ui_spotlight_active_index_get(container); 156 int i = efl_pack_index_get(container, efl_ui_spotlight_active_element_get(container));
155 if (i != -1) 157 if (i != -1)
156 _emit_pos(obj, i); 158 _emit_pos(obj, i);
157} 159}
@@ -224,7 +226,7 @@ EFL_START_TEST (efl_ui_spotlight_init)
224 Eina_Size2D s = efl_ui_spotlight_size_get(container); 226 Eina_Size2D s = efl_ui_spotlight_size_get(container);
225 ck_assert_int_eq(s.w, 0); //FIXME 227 ck_assert_int_eq(s.w, 0); //FIXME
226 ck_assert_int_eq(s.h, 0); //FIXME 228 ck_assert_int_eq(s.h, 0); //FIXME
227 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), -1); 229 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), NULL);
228} 230}
229EFL_END_TEST 231EFL_END_TEST
230 232
@@ -232,17 +234,23 @@ EFL_START_TEST (efl_ui_spotlight_active_index)
232{ 234{
233 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win); 235 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
234 efl_pack(container, w); 236 efl_pack(container, w);
235 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), 0);
236 237
237 for (int i = -20; i < 20; ++i) 238 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), w);
238 { 239 EXPECT_ERROR_START;
239 if (i == 0) continue; 240 efl_ui_spotlight_active_element_set(container, 0x0);
240 EXPECT_ERROR_START; 241 EXPECT_ERROR_END;
241 efl_ui_spotlight_active_index_set(container, i); 242 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), w);
242 EXPECT_ERROR_END; 243 EXPECT_ERROR_START;
243 } 244 efl_ui_spotlight_active_element_set(container, (void*)0xAFFE);
245 EXPECT_ERROR_END;
246 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), w);
247 EXPECT_ERROR_START;
248 efl_ui_spotlight_active_element_set(container, efl_main_loop_get());
249 EXPECT_ERROR_END;
250 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), w);
251
244 efl_del(w); 252 efl_del(w);
245 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), -1); 253 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), NULL);
246} 254}
247EFL_END_TEST 255EFL_END_TEST
248 256
@@ -280,7 +288,7 @@ EFL_START_TEST (efl_ui_smart_transition_calls)
280 ck_assert_int_eq(transition_calls.content_add.called, 1); 288 ck_assert_int_eq(transition_calls.content_add.called, 1);
281 ck_assert_int_eq(transition_calls.content_add.index, 0); 289 ck_assert_int_eq(transition_calls.content_add.index, 0);
282 ck_assert_ptr_eq(transition_calls.content_add.subobj, w); 290 ck_assert_ptr_eq(transition_calls.content_add.subobj, w);
283 ck_assert_int_eq(transition_calls.content_add.current_page_at_call, -1); 291 ck_assert_ptr_eq(transition_calls.content_add.current_page_at_call, NULL);
284 ck_assert_int_eq(transition_calls.content_del.called, 0); 292 ck_assert_int_eq(transition_calls.content_del.called, 0);
285 transition_calls.content_add.called = 0; 293 transition_calls.content_add.called = 0;
286 transition_calls.request_switch.called = 0; 294 transition_calls.request_switch.called = 0;
@@ -293,11 +301,11 @@ EFL_START_TEST (efl_ui_smart_transition_calls)
293 ck_assert_int_eq(transition_calls.content_add.called, 1); 301 ck_assert_int_eq(transition_calls.content_add.called, 1);
294 ck_assert_int_eq(transition_calls.content_add.index, 0); 302 ck_assert_int_eq(transition_calls.content_add.index, 0);
295 ck_assert_ptr_eq(transition_calls.content_add.subobj, w1); 303 ck_assert_ptr_eq(transition_calls.content_add.subobj, w1);
296 ck_assert_int_eq(transition_calls.content_add.current_page_at_call, 1); 304 ck_assert_ptr_eq(transition_calls.content_add.current_page_at_call, w);
297 ck_assert_int_eq(transition_calls.content_del.called, 0); 305 ck_assert_int_eq(transition_calls.content_del.called, 0);
298 transition_calls.content_add.called = 0; 306 transition_calls.content_add.called = 0;
299 transition_calls.request_switch.called = 0; 307 transition_calls.request_switch.called = 0;
300 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), 1); 308 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), w);
301 309
302 //new object, must update the content and a not update current page 310 //new object, must update the content and a not update current page
303 efl_pack_end(container, w2); 311 efl_pack_end(container, w2);
@@ -307,13 +315,13 @@ EFL_START_TEST (efl_ui_smart_transition_calls)
307 ck_assert_int_eq(transition_calls.content_add.called, 1); 315 ck_assert_int_eq(transition_calls.content_add.called, 1);
308 ck_assert_int_eq(transition_calls.content_add.index, 2); 316 ck_assert_int_eq(transition_calls.content_add.index, 2);
309 ck_assert_ptr_eq(transition_calls.content_add.subobj, w2); 317 ck_assert_ptr_eq(transition_calls.content_add.subobj, w2);
310 ck_assert_int_eq(transition_calls.content_add.current_page_at_call, 1); 318 ck_assert_ptr_eq(transition_calls.content_add.current_page_at_call, w);
311 ck_assert_int_eq(transition_calls.content_del.called, 0); 319 ck_assert_int_eq(transition_calls.content_del.called, 0);
312 transition_calls.content_add.called = 0; 320 transition_calls.content_add.called = 0;
313 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), 1); 321 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), w);
314 322
315 //page change must result in a call to request a switch 323 //page change must result in a call to request a switch
316 efl_ui_spotlight_active_index_set(container, 2); 324 efl_ui_spotlight_active_element_set(container, w2);
317 ck_assert_int_eq(transition_calls.spotlight.called, 0); 325 ck_assert_int_eq(transition_calls.spotlight.called, 0);
318 ck_assert_int_eq(transition_calls.page_size.called, 0); 326 ck_assert_int_eq(transition_calls.page_size.called, 0);
319 ck_assert_int_eq(transition_calls.request_switch.called, 1); 327 ck_assert_int_eq(transition_calls.request_switch.called, 1);
@@ -332,7 +340,7 @@ EFL_START_TEST (efl_ui_smart_transition_calls)
332 ck_assert_int_eq(transition_calls.content_del.called, 1); 340 ck_assert_int_eq(transition_calls.content_del.called, 1);
333 ck_assert_int_eq(transition_calls.content_del.index, 1); 341 ck_assert_int_eq(transition_calls.content_del.index, 1);
334 ck_assert_ptr_eq(transition_calls.content_del.subobj, w); 342 ck_assert_ptr_eq(transition_calls.content_del.subobj, w);
335 ck_assert_int_eq(transition_calls.content_del.current_page_at_call, 1); 343 ck_assert_ptr_eq(transition_calls.content_del.current_page_at_call, w2);
336 transition_calls.content_del.called = 0; 344 transition_calls.content_del.called = 0;
337} 345}
338EFL_END_TEST 346EFL_END_TEST
@@ -486,7 +494,7 @@ _verify_transition_start_end_events(void)
486 ck_assert_int_eq(end.from, -8); 494 ck_assert_int_eq(end.from, -8);
487 495
488 EV_RESET 496 EV_RESET
489 efl_ui_spotlight_active_index_set(container, 2); 497 efl_ui_spotlight_active_element_set(container, w2);
490 ck_assert_int_eq(start.to, 2); 498 ck_assert_int_eq(start.to, 2);
491 ck_assert_int_eq(end.to, 2); 499 ck_assert_int_eq(end.to, 2);
492 ck_assert_int_eq(start.from, 1); 500 ck_assert_int_eq(start.from, 1);
@@ -511,7 +519,7 @@ EFL_START_TEST (efl_ui_spotlight_test_push1)
511 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win); 519 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
512 efl_ui_spotlight_push(container, w); 520 efl_ui_spotlight_push(container, w);
513 ck_assert_int_eq(efl_pack_index_get(container, w), 0); 521 ck_assert_int_eq(efl_pack_index_get(container, w), 0);
514 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), 0); 522 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), efl_pack_content_get(container, 0));
515} 523}
516EFL_END_TEST 524EFL_END_TEST
517 525
@@ -521,13 +529,13 @@ EFL_START_TEST (efl_ui_spotlight_test_push2)
521 { 529 {
522 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win); 530 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
523 efl_pack_end(container, w); 531 efl_pack_end(container, w);
532 if (i == 3)
533 efl_ui_spotlight_active_element_set(container, w);
524 } 534 }
525 efl_ui_spotlight_active_index_set(container, 3);
526
527 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win); 535 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
528 efl_ui_spotlight_push(container, w); 536 efl_ui_spotlight_push(container, w);
529 ck_assert_int_eq(efl_pack_index_get(container, w), 3); 537 ck_assert_int_eq(efl_pack_index_get(container, w), 3);
530 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), 3); 538 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), w);
531} 539}
532EFL_END_TEST 540EFL_END_TEST
533 541
@@ -590,16 +598,17 @@ EFL_START_TEST (efl_ui_spotlight_test_pop3)
590 { 598 {
591 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win); 599 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
592 efl_pack_end(container, w); 600 efl_pack_end(container, w);
601 if (i == 3)
602 efl_ui_spotlight_active_element_set(container, w);
593 } 603 }
594 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win); 604 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
595 efl_ui_spotlight_active_index_set(container, 3);
596 efl_ui_spotlight_push(container, w); 605 efl_ui_spotlight_push(container, w);
597 Eina_Future *f = efl_ui_spotlight_pop(container, EINA_TRUE); 606 Eina_Future *f = efl_ui_spotlight_pop(container, EINA_TRUE);
598 for (int i = 0; i < 10; ++i) 607 for (int i = 0; i < 10; ++i)
599 { 608 {
600 efl_loop_iterate(efl_provider_find(container, EFL_LOOP_CLASS)); 609 efl_loop_iterate(efl_provider_find(container, EFL_LOOP_CLASS));
601 } 610 }
602 ck_assert_int_eq(efl_ui_spotlight_active_index_get(container), 3); 611 ck_assert_ptr_eq(efl_ui_spotlight_active_element_get(container), efl_pack_content_get(container, 3));
603 ck_assert_int_eq(efl_ref_count(w), 0); 612 ck_assert_int_eq(efl_ref_count(w), 0);
604 ck_assert_int_eq(efl_content_count(container), 5); 613 ck_assert_int_eq(efl_content_count(container), 5);
605 ck_assert_ptr_ne(f, NULL); 614 ck_assert_ptr_ne(f, NULL);