summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2015-10-06 15:38:09 +0200
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-11-12 10:15:03 +0100
commit6bf9a1fe767d8c77a9952dac690f153e72c20f79 (patch)
tree633623db154816d4a61d5a720d97f0c394f5c9c0
parente24deab4afbf8d8036d5e0e9f3c37d466b6e8afb (diff)
tests: add new tests for AT-SPI beta API.
-rw-r--r--src/lib/elm_widget.c5
-rw-r--r--src/tests/elm_test_atspi.c321
-rw-r--r--src/tests/elm_test_genlist.c2
3 files changed, 325 insertions, 3 deletions
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 4a9022f78..4996141ee 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -5810,6 +5810,11 @@ EOLIAN static char*
5810_elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED) 5810_elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
5811{ 5811{
5812 const char *ret; 5812 const char *ret;
5813 char *name;
5814 eo_do_super(obj, ELM_WIDGET_CLASS, name = elm_interface_atspi_accessible_name_get());
5815
5816 if (name) return name;
5817
5813 ret = elm_object_text_get(obj); 5818 ret = elm_object_text_get(obj);
5814 if (!ret) return NULL; 5819 if (!ret) return NULL;
5815 5820
diff --git a/src/tests/elm_test_atspi.c b/src/tests/elm_test_atspi.c
index da616ff07..bf7c3b55f 100644
--- a/src/tests/elm_test_atspi.c
+++ b/src/tests/elm_test_atspi.c
@@ -25,7 +25,7 @@ void generate_app(void)
25 evas_object_show(g_win); 25 evas_object_show(g_win);
26} 26}
27 27
28START_TEST (elm_atspi_name_get) 28START_TEST (elm_atspi_app_obj_name_get)
29{ 29{
30 elm_init(0, NULL); 30 elm_init(0, NULL);
31 31
@@ -46,6 +46,64 @@ START_TEST (elm_atspi_name_get)
46} 46}
47END_TEST 47END_TEST
48 48
49START_TEST (elm_atspi_name_get)
50{
51 elm_init(0, NULL);
52 generate_app();
53
54 char *name;
55
56 eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
57
58 if (name && name[0]) {
59 ck_assert(0);
60 }
61
62 free(name);
63
64 // Set name with additional text tags
65 elm_object_text_set(g_btn, "Some<br>text");
66
67 eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
68
69 // Accessible name should have cleared tags
70 ck_assert(name != NULL);
71 ck_assert_str_eq(name, "Some\ntext");
72
73 free(name);
74 elm_shutdown();
75}
76END_TEST
77
78START_TEST (elm_atspi_name_set)
79{
80 elm_init(0, NULL);
81 generate_app();
82
83 char *name;
84
85 elm_object_text_set(g_btn, "Other text");
86 eo_do(g_btn, elm_interface_atspi_accessible_name_set("Test name"));
87
88 eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
89
90 ck_assert(name != NULL);
91 ck_assert_str_eq(name, "Test name");
92
93 free(name);
94
95 eo_do(g_btn, elm_interface_atspi_accessible_name_set(NULL));
96 eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
97
98 ck_assert(name != NULL);
99 ck_assert_str_eq(name, "Other text");
100
101 free(name);
102
103 elm_shutdown();
104}
105END_TEST
106
49START_TEST (elm_atspi_role_get) 107START_TEST (elm_atspi_role_get)
50{ 108{
51 elm_init(0, NULL); 109 elm_init(0, NULL);
@@ -63,6 +121,29 @@ START_TEST (elm_atspi_role_get)
63} 121}
64END_TEST 122END_TEST
65 123
124START_TEST (elm_atspi_role_set)
125{
126 elm_init(0, NULL);
127 generate_app();
128 Elm_Atspi_Role role;
129
130 eo_do(g_btn, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_ACCELERATOR_LABEL));
131 eo_do(g_btn, role = elm_interface_atspi_accessible_role_get());
132
133 if (role != ELM_ATSPI_ROLE_ACCELERATOR_LABEL)
134 ck_assert(0);
135
136 eo_do(g_btn, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_ENTRY));
137 eo_do(g_btn, role = elm_interface_atspi_accessible_role_get());
138
139 if (role != ELM_ATSPI_ROLE_ENTRY)
140 ck_assert(0);
141
142 elm_shutdown();
143}
144END_TEST
145
146
66 147
67START_TEST (elm_atspi_role_name_get) 148START_TEST (elm_atspi_role_name_get)
68{ 149{
@@ -113,17 +194,36 @@ START_TEST (elm_atspi_description_set)
113 ck_assert(ret == NULL); 194 ck_assert(ret == NULL);
114 195
115 eo_do(root, elm_interface_atspi_accessible_description_set(desc)); 196 eo_do(root, elm_interface_atspi_accessible_description_set(desc));
116
117 eo_do(root, ret = elm_interface_atspi_accessible_description_get()); 197 eo_do(root, ret = elm_interface_atspi_accessible_description_get());
118 198
119 ck_assert(ret != NULL); 199 ck_assert(ret != NULL);
120 ck_assert_str_eq(ret, "Test description"); 200 ck_assert_str_eq(ret, "Test description");
121 201
202 eo_do(root, elm_interface_atspi_accessible_description_set(NULL));
203 eo_do(root, ret = elm_interface_atspi_accessible_description_get());
204
205 ck_assert(ret == NULL);
206
122 eo_unref(root); 207 eo_unref(root);
123 elm_shutdown(); 208 elm_shutdown();
124} 209}
125END_TEST 210END_TEST
126 211
212/* Test if intial description value is NULL */
213START_TEST (elm_atspi_description_get)
214{
215 elm_init(0, NULL);
216 generate_app();
217
218 const char *descr;
219 eo_do(g_bg, descr = elm_interface_atspi_accessible_description_get());
220
221 ck_assert(descr == NULL);
222
223 elm_shutdown();
224}
225END_TEST
226
127START_TEST (elm_atspi_children_and_parent) 227START_TEST (elm_atspi_children_and_parent)
128{ 228{
129 elm_init(0, NULL); 229 elm_init(0, NULL);
@@ -184,13 +284,230 @@ START_TEST (elm_atspi_children_and_parent2)
184} 284}
185END_TEST 285END_TEST
186 286
287/* Initial value of translation domain should be NULL */
288START_TEST (elm_atspi_translation_domain_get)
289{
290 elm_init(0, NULL);
291 generate_app();
292
293 const char *domain;
294
295 eo_do(g_btn, domain = elm_interface_atspi_accessible_translation_domain_get());
296
297 ck_assert(domain == NULL);
298
299 elm_shutdown();
300}
301END_TEST
302
303START_TEST (elm_atspi_translation_domain_set)
304{
305 elm_init(0, NULL);
306 generate_app();
307
308 const char *domain;
309
310 eo_do(g_btn, elm_interface_atspi_accessible_translation_domain_set("Test translation_domain"));
311 eo_do(g_btn, domain = elm_interface_atspi_accessible_translation_domain_get());
312
313 ck_assert(domain != NULL);
314 ck_assert_str_eq(domain, "Test translation_domain");
315
316 eo_do(g_btn, elm_interface_atspi_accessible_translation_domain_set(NULL));
317 eo_do(g_btn, domain = elm_interface_atspi_accessible_translation_domain_get());
318
319 ck_assert(domain == NULL);
320
321 elm_shutdown();
322}
323END_TEST
324
325START_TEST (elm_atspi_relationship_append)
326{
327 elm_init(0, NULL);
328 generate_app();
329
330 Elm_Atspi_Relation_Set set;
331 Elm_Atspi_Relation *rel, *rel_to, *rel_from;
332 Eina_List *l;
333
334 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
335 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_win));
336 eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
337
338 ck_assert(set != NULL);
339 ck_assert(eina_list_count(set) >= 2);
340
341 rel_to = rel_from = NULL;
342 EINA_LIST_FOREACH(set, l, rel)
343 {
344 if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
345 rel_to = rel;
346 if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
347 rel_from = rel;
348 }
349
350 ck_assert(rel_to != NULL);
351 ck_assert(eina_list_data_find(rel_to->objects, g_bg) != NULL);
352
353 ck_assert(rel_from != NULL);
354 ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
355
356 elm_atspi_relation_set_free(set);
357
358 /* Check if append do not procude duplicated relations */
359 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
360 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_win));
361 eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
362
363 rel_to = rel_from = NULL;
364 EINA_LIST_FOREACH(set, l, rel)
365 {
366 if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
367 rel_to = rel;
368 if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
369 rel_from = rel;
370 }
371
372 ck_assert(rel_to != NULL);
373 ck_assert(rel_to->objects != NULL);
374 rel_to->objects = eina_list_remove(rel_to->objects, g_bg);
375 ck_assert(eina_list_data_find(rel_to->objects, g_bg) == NULL);
376
377 ck_assert(rel_from != NULL);
378 ck_assert(rel_from->objects != NULL);
379 rel_from->objects = eina_list_remove(rel_from->objects, g_win);
380 ck_assert(eina_list_data_find(rel_from->objects, g_win) == NULL);
381
382 elm_atspi_relation_set_free(set);
383
384 elm_shutdown();
385}
386END_TEST
387
388START_TEST (elm_atspi_relationship_remove)
389{
390 elm_init(0, NULL);
391 generate_app();
392
393 Elm_Atspi_Relation_Set set;
394 Elm_Atspi_Relation *rel, *rel_to, *rel_from;
395 Eina_List *l;
396
397 /* Test if removal of single relationship works */
398 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
399 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_win));
400 eo_do(g_btn, elm_interface_atspi_accessible_relationship_remove(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
401 eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
402
403 ck_assert(set != NULL);
404 ck_assert(eina_list_count(set) >= 1);
405
406 rel_to = rel_from = NULL;
407 EINA_LIST_FOREACH(set, l, rel)
408 {
409 if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
410 rel_to = rel;
411 if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
412 rel_from = rel;
413 }
414
415 if (rel_to) ck_assert(eina_list_data_find(rel_to->objects, g_bg) == NULL);
416 ck_assert(rel_from != NULL);
417 ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
418
419 elm_atspi_relation_set_free(set);
420
421 /* Test if removal of type relationship works */
422 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
423 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_win));
424 eo_do(g_btn, elm_interface_atspi_accessible_relationship_remove(ELM_ATSPI_RELATION_FLOWS_TO, NULL));
425 eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
426
427 rel_to = rel_from = NULL;
428 EINA_LIST_FOREACH(set, l, rel)
429 {
430 if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
431 rel_to = rel;
432 if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
433 rel_from = rel;
434 }
435
436 ck_assert(rel_to == NULL);
437 ck_assert(rel_from != NULL);
438 ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
439
440 elm_atspi_relation_set_free(set);
441
442 /* Test if relationship is implicity removed when object is deleted */
443 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
444 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_bg));
445 eo_del(g_bg);
446 eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
447
448 rel_to = rel_from = NULL;
449 EINA_LIST_FOREACH(set, l, rel)
450 {
451 if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
452 rel_to = rel;
453 if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
454 rel_from = rel;
455 }
456
457 if (rel_to) ck_assert(eina_list_data_find(rel_to->objects, g_bg) == NULL);
458 if (rel_from) ck_assert(eina_list_data_find(rel_from->objects, g_bg) == NULL);
459
460 elm_atspi_relation_set_free(set);
461 elm_shutdown();
462}
463END_TEST
464
465START_TEST (elm_atspi_relationships_clear)
466{
467 Elm_Atspi_Relation_Set set;
468 Elm_Atspi_Relation *rel;
469 Eina_List *l;
470
471 elm_init(0, NULL);
472 generate_app();
473
474 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
475 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_bg));
476 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_win));
477 eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_win));
478
479 eo_do(g_btn, elm_interface_atspi_accessible_relationships_clear());
480
481 eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
482 EINA_LIST_FOREACH(set, l, rel)
483 {
484 ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_TO) && eina_list_data_find(rel->objects, g_bg)));
485 ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_FROM) && eina_list_data_find(rel->objects, g_bg)));
486 ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_TO) && eina_list_data_find(rel->objects, g_win)));
487 ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_FROM) && eina_list_data_find(rel->objects, g_win)));
488 }
489
490 elm_atspi_relation_set_free(set);
491 elm_shutdown();
492}
493END_TEST
494
187void elm_test_atspi(TCase *tc) 495void elm_test_atspi(TCase *tc)
188{ 496{
497 tcase_add_test(tc, elm_atspi_app_obj_name_get);
189 tcase_add_test(tc, elm_atspi_name_get); 498 tcase_add_test(tc, elm_atspi_name_get);
499 tcase_add_test(tc, elm_atspi_name_set);
190 tcase_add_test(tc, elm_atspi_role_get); 500 tcase_add_test(tc, elm_atspi_role_get);
501 tcase_add_test(tc, elm_atspi_role_set);
191 tcase_add_test(tc, elm_atspi_role_name_get); 502 tcase_add_test(tc, elm_atspi_role_name_get);
192 tcase_add_test(tc, elm_atspi_localized_role_name_get); 503 tcase_add_test(tc, elm_atspi_localized_role_name_get);
193 tcase_add_test(tc, elm_atspi_description_set); 504 tcase_add_test(tc, elm_atspi_description_set);
505 tcase_add_test(tc, elm_atspi_description_get);
194 tcase_add_test(tc, elm_atspi_children_and_parent); 506 tcase_add_test(tc, elm_atspi_children_and_parent);
195 tcase_add_test(tc, elm_atspi_children_and_parent2); 507 tcase_add_test(tc, elm_atspi_children_and_parent2);
508 tcase_add_test(tc, elm_atspi_translation_domain_get);
509 tcase_add_test(tc, elm_atspi_translation_domain_set);
510 tcase_add_test(tc, elm_atspi_relationship_append);
511 tcase_add_test(tc, elm_atspi_relationship_remove);
512 tcase_add_test(tc, elm_atspi_relationships_clear);
196} 513}
diff --git a/src/tests/elm_test_genlist.c b/src/tests/elm_test_genlist.c
index 84caec82a..593e04cab 100644
--- a/src/tests/elm_test_genlist.c
+++ b/src/tests/elm_test_genlist.c
@@ -205,7 +205,7 @@ START_TEST(elm_atspi_children_parent)
205 itc.func.content_get = gl_content_get; 205 itc.func.content_get = gl_content_get;
206 206
207 it = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); 207 it = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
208 elm_gengrid_item_fields_update(it, "*.", ELM_GENGRID_ITEM_FIELD_CONTENT); 208 elm_genlist_item_fields_update(it, "*.", ELM_GENGRID_ITEM_FIELD_CONTENT);
209 209
210 ck_assert(content != NULL); 210 ck_assert(content != NULL);
211 eo_do(content, parent = elm_interface_atspi_accessible_parent_get()); 211 eo_do(content, parent = elm_interface_atspi_accessible_parent_get());