summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShilpa Singh <shilpa.singh@samsung.com>2019-03-20 14:16:11 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-03-20 15:29:04 +0100
commite80169a844aaf9cf2f75a814c7561abd9a7bdd25 (patch)
tree7041b319730a8e6d063161c7aafb1b2688777e73
parent89d80ffc52086610f188df345f90e04a5539f5c1 (diff)
efl_access: Add attribute_del API, Add test cases for all access_object_attribute* APIs
Add attribute_del API, currently there is no provision to delete a particular attribute(key-value pair) from the attribute list of a widget. Add test cases for efl_access_attribute_append, efl_access_attributes_get, efl_access_attribute_del and efl_access_attributes_clear API Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Reviewed-by: Shinwoo Kim <cinoo.kim@samsung.com> Differential Revision: https://phab.enlightenment.org/D8386
-rw-r--r--src/lib/elementary/efl_access_object.c25
-rw-r--r--src/lib/elementary/efl_access_object.eo7
-rw-r--r--src/tests/elementary/efl_ui_test_atspi.c118
3 files changed, 149 insertions, 1 deletions
diff --git a/src/lib/elementary/efl_access_object.c b/src/lib/elementary/efl_access_object.c
index 84ae798cc0..fa206449ae 100644
--- a/src/lib/elementary/efl_access_object.c
+++ b/src/lib/elementary/efl_access_object.c
@@ -195,7 +195,7 @@ _efl_access_object_attributes_get(const Eo *obj EINA_UNUSED, Efl_Access_Object_D
195 { 195 {
196 Efl_Access_Attribute *attr = calloc(1, sizeof(Efl_Access_Attribute)); 196 Efl_Access_Attribute *attr = calloc(1, sizeof(Efl_Access_Attribute));
197 if (!attr) 197 if (!attr)
198 return attr_list; 198 return attr_list;
199 199
200 attr->key = eina_stringshare_add(t_attr->key); 200 attr->key = eina_stringshare_add(t_attr->key);
201 attr->value = eina_stringshare_add(t_attr->value); 201 attr->value = eina_stringshare_add(t_attr->value);
@@ -232,6 +232,29 @@ _efl_access_object_attribute_append(Eo *obj EINA_UNUSED, Efl_Access_Object_Data
232 pd->attr_list = eina_list_append(pd->attr_list, attr); 232 pd->attr_list = eina_list_append(pd->attr_list, attr);
233} 233}
234 234
235EOLIAN static void
236_efl_access_object_attribute_del(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd, const char *key)
237{
238 Eina_List *l;
239 Efl_Access_Attribute *attr = NULL;
240
241 if (!key) return;
242 if (!pd->attr_list) return;
243
244 /* Check whether existing attribute list has this key and delete */
245 EINA_LIST_FOREACH(pd->attr_list, l, attr)
246 {
247 if (!strcmp((const char *)attr->key, key))
248 {
249 pd->attr_list = eina_list_remove_list(pd->attr_list, l);
250 eina_stringshare_del(attr->key);
251 eina_stringshare_del(attr->value);
252 free(attr);
253 return;
254 }
255 }
256}
257
235EOLIAN static void _efl_access_object_attributes_clear(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd) 258EOLIAN static void _efl_access_object_attributes_clear(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd)
236{ 259{
237 if (!pd->attr_list) return; 260 if (!pd->attr_list) return;
diff --git a/src/lib/elementary/efl_access_object.eo b/src/lib/elementary/efl_access_object.eo
index 933533663a..451856f97d 100644
--- a/src/lib/elementary/efl_access_object.eo
+++ b/src/lib/elementary/efl_access_object.eo
@@ -307,6 +307,13 @@ mixin @beta Efl.Access.Object requires Efl.Object
307 @in value: string; [[The string value to give extra information]] 307 @in value: string; [[The string value to give extra information]]
308 } 308 }
309 } 309 }
310 attribute_del {
311 [[delete key-value pair identifying object extra attributes when key is given
312 ]]
313 params {
314 @in key: string; [[The string key to identify the key-value pair]]
315 }
316 }
310 attributes_clear { 317 attributes_clear {
311 [[Removes all attributes in accessible object.]] 318 [[Removes all attributes in accessible object.]]
312 } 319 }
diff --git a/src/tests/elementary/efl_ui_test_atspi.c b/src/tests/elementary/efl_ui_test_atspi.c
index 9aa046351c..4b9a68172f 100644
--- a/src/tests/elementary/efl_ui_test_atspi.c
+++ b/src/tests/elementary/efl_ui_test_atspi.c
@@ -451,6 +451,120 @@ EFL_START_TEST(test_efl_access_object_relationships_clear)
451} 451}
452EFL_END_TEST 452EFL_END_TEST
453 453
454EFL_START_TEST(test_efl_access_object_attribute_append)
455{
456 Eina_List *attr_list = NULL, *l = NULL;
457 Efl_Access_Attribute *attr = NULL;
458 generate_app();
459 efl_access_object_attribute_append(g_btn, "color1", "red");
460 efl_access_object_attribute_append(g_btn, "color2", "blue");
461 efl_access_object_attribute_append(g_btn, "color3", "green");
462 attr_list = efl_access_object_attributes_get(g_btn);
463
464 ck_assert(attr_list != NULL);
465 EINA_LIST_FOREACH(attr_list, l, attr)
466 {
467 if (!strcmp(attr->key, "color1"))
468 ck_assert_str_eq(attr->value, "red");
469 else if (!strcmp(attr->key, "color2"))
470 ck_assert_str_eq(attr->value, "blue");
471 else if (!strcmp(attr->key, "color3"))
472 ck_assert_str_eq(attr->value, "green");
473 }
474 EINA_LIST_FREE(attr_list, attr)
475 {
476 eina_stringshare_del(attr->key);
477 eina_stringshare_del(attr->value);
478 free(attr);
479 }
480}
481EFL_END_TEST
482
483EFL_START_TEST(test_efl_access_object_attributes_get)
484{
485 Eina_List *attr_list = NULL, *l = NULL;
486 Efl_Access_Attribute *attr = NULL;
487 generate_app();
488 efl_access_object_attribute_append(g_btn, "color1", "red");
489 efl_access_object_attribute_append(g_btn, "color2", "blue");
490 efl_access_object_attribute_append(g_btn, "color3", "green");
491 attr_list = efl_access_object_attributes_get(g_btn);
492
493 ck_assert(attr_list != NULL);
494 EINA_LIST_FOREACH(attr_list, l, attr)
495 {
496 if (!strcmp(attr->key, "color1"))
497 ck_assert_str_eq(attr->value, "red");
498 else if (!strcmp(attr->key, "color2"))
499 ck_assert_str_eq(attr->value, "blue");
500 else if (!strcmp(attr->key, "color3"))
501 ck_assert_str_eq(attr->value, "green");
502 }
503 EINA_LIST_FREE(attr_list, attr)
504 {
505 eina_stringshare_del(attr->key);
506 eina_stringshare_del(attr->value);
507 free(attr);
508 }
509}
510EFL_END_TEST
511
512EFL_START_TEST(test_efl_access_object_attribute_del)
513{
514 Eina_List *attr_list = NULL;
515 Efl_Access_Attribute *attr = NULL;
516 int count1 = 0;
517 int count2 = 0;
518 generate_app();
519 efl_access_object_attribute_append(g_btn, "color1", "red");
520 efl_access_object_attribute_append(g_btn, "color2", "blue");
521 efl_access_object_attribute_append(g_btn, "color3", "green");
522 attr_list = efl_access_object_attributes_get(g_btn);//default attributes are added again
523 ck_assert(attr_list != NULL);
524 count1 = eina_list_count(attr_list);
525 EINA_LIST_FREE(attr_list, attr)
526 {
527 eina_stringshare_del(attr->key);
528 eina_stringshare_del(attr->value);
529 free(attr);
530 }
531 attr_list = NULL;
532 efl_access_object_attribute_del(g_btn, "color4");//non existent key deletion
533 efl_access_object_attribute_del(g_btn, "color3");//existing key deletion
534 attr_list = efl_access_object_attributes_get(g_btn);
535 ck_assert(attr_list != NULL);
536 count2 = eina_list_count(attr_list);
537 ck_assert(count1 == (count2+1));
538 EINA_LIST_FREE(attr_list, attr)
539 {
540 eina_stringshare_del(attr->key);
541 eina_stringshare_del(attr->value);
542 free(attr);
543 }
544}
545EFL_END_TEST
546
547EFL_START_TEST(test_efl_access_object_attributes_clear)
548{
549 Eina_List *attr_list = NULL;
550 Efl_Access_Attribute *attr = NULL;
551 generate_app();
552 efl_access_object_attribute_append(g_btn, "color1", "red");
553 efl_access_object_attribute_append(g_btn, "color2", "blue");
554 efl_access_object_attribute_append(g_btn, "color3", "green");
555 efl_access_object_attributes_clear(g_btn);
556 attr_list = efl_access_object_attributes_get(g_btn);//default attributes are added again
557 ck_assert(attr_list != NULL);
558 ck_assert(eina_list_count(attr_list) <= 2);
559 EINA_LIST_FREE(attr_list, attr)
560 {
561 eina_stringshare_del(attr->key);
562 eina_stringshare_del(attr->value);
563 free(attr);
564 }
565}
566EFL_END_TEST
567
454void efl_ui_test_atspi(TCase *tc) 568void efl_ui_test_atspi(TCase *tc)
455{ 569{
456 tcase_add_test(tc, test_efl_access_app_obj_name_get); 570 tcase_add_test(tc, test_efl_access_app_obj_name_get);
@@ -469,4 +583,8 @@ void efl_ui_test_atspi(TCase *tc)
469 tcase_add_test(tc, test_efl_access_object_relationship_append); 583 tcase_add_test(tc, test_efl_access_object_relationship_append);
470 tcase_add_test(tc, test_efl_access_object_relationship_remove); 584 tcase_add_test(tc, test_efl_access_object_relationship_remove);
471 tcase_add_test(tc, test_efl_access_object_relationships_clear); 585 tcase_add_test(tc, test_efl_access_object_relationships_clear);
586 tcase_add_test(tc, test_efl_access_object_attribute_append);
587 tcase_add_test(tc, test_efl_access_object_attributes_get);
588 tcase_add_test(tc, test_efl_access_object_attribute_del);
589 tcase_add_test(tc, test_efl_access_object_attributes_clear);
472} 590}