diff options
author | Shilpa Singh <shilpa.singh@samsung.com> | 2019-03-20 14:16:11 +0000 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-03-20 15:29:04 +0100 |
commit | e80169a844aaf9cf2f75a814c7561abd9a7bdd25 (patch) | |
tree | 7041b319730a8e6d063161c7aafb1b2688777e73 | |
parent | 89d80ffc52086610f188df345f90e04a5539f5c1 (diff) | |
download | efl-e80169a844aaf9cf2f75a814c7561abd9a7bdd25.tar.gz |
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.c | 25 | ||||
-rw-r--r-- | src/lib/elementary/efl_access_object.eo | 7 | ||||
-rw-r--r-- | src/tests/elementary/efl_ui_test_atspi.c | 118 |
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 { Efl_Access_Attribute *attr = calloc(1, sizeof(Efl_Access_Attribute)); if (!attr) - return attr_list; + return attr_list; attr->key = eina_stringshare_add(t_attr->key); 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 pd->attr_list = eina_list_append(pd->attr_list, attr); } +EOLIAN static void +_efl_access_object_attribute_del(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd, const char *key) +{ + Eina_List *l; + Efl_Access_Attribute *attr = NULL; + + if (!key) return; + if (!pd->attr_list) return; + + /* Check whether existing attribute list has this key and delete */ + EINA_LIST_FOREACH(pd->attr_list, l, attr) + { + if (!strcmp((const char *)attr->key, key)) + { + pd->attr_list = eina_list_remove_list(pd->attr_list, l); + eina_stringshare_del(attr->key); + eina_stringshare_del(attr->value); + free(attr); + return; + } + } +} + EOLIAN static void _efl_access_object_attributes_clear(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd) { 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 @in value: string; [[The string value to give extra information]] } } + attribute_del { + [[delete key-value pair identifying object extra attributes when key is given + ]] + params { + @in key: string; [[The string key to identify the key-value pair]] + } + } attributes_clear { [[Removes all attributes in accessible object.]] } 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) } EFL_END_TEST +EFL_START_TEST(test_efl_access_object_attribute_append) +{ + Eina_List *attr_list = NULL, *l = NULL; + Efl_Access_Attribute *attr = NULL; + generate_app(); + efl_access_object_attribute_append(g_btn, "color1", "red"); + efl_access_object_attribute_append(g_btn, "color2", "blue"); + efl_access_object_attribute_append(g_btn, "color3", "green"); + attr_list = efl_access_object_attributes_get(g_btn); + + ck_assert(attr_list != NULL); + EINA_LIST_FOREACH(attr_list, l, attr) + { + if (!strcmp(attr->key, "color1")) + ck_assert_str_eq(attr->value, "red"); + else if (!strcmp(attr->key, "color2")) + ck_assert_str_eq(attr->value, "blue"); + else if (!strcmp(attr->key, "color3")) + ck_assert_str_eq(attr->value, "green"); + } + EINA_LIST_FREE(attr_list, attr) + { + eina_stringshare_del(attr->key); + eina_stringshare_del(attr->value); + free(attr); + } +} +EFL_END_TEST + +EFL_START_TEST(test_efl_access_object_attributes_get) +{ + Eina_List *attr_list = NULL, *l = NULL; + Efl_Access_Attribute *attr = NULL; + generate_app(); + efl_access_object_attribute_append(g_btn, "color1", "red"); + efl_access_object_attribute_append(g_btn, "color2", "blue"); + efl_access_object_attribute_append(g_btn, "color3", "green"); + attr_list = efl_access_object_attributes_get(g_btn); + + ck_assert(attr_list != NULL); + EINA_LIST_FOREACH(attr_list, l, attr) + { + if (!strcmp(attr->key, "color1")) + ck_assert_str_eq(attr->value, "red"); + else if (!strcmp(attr->key, "color2")) + ck_assert_str_eq(attr->value, "blue"); + else if (!strcmp(attr->key, "color3")) + ck_assert_str_eq(attr->value, "green"); + } + EINA_LIST_FREE(attr_list, attr) + { + eina_stringshare_del(attr->key); + eina_stringshare_del(attr->value); + free(attr); + } +} +EFL_END_TEST + +EFL_START_TEST(test_efl_access_object_attribute_del) +{ + Eina_List *attr_list = NULL; + Efl_Access_Attribute *attr = NULL; + int count1 = 0; + int count2 = 0; + generate_app(); + efl_access_object_attribute_append(g_btn, "color1", "red"); + efl_access_object_attribute_append(g_btn, "color2", "blue"); + efl_access_object_attribute_append(g_btn, "color3", "green"); + attr_list = efl_access_object_attributes_get(g_btn);//default attributes are added again + ck_assert(attr_list != NULL); + count1 = eina_list_count(attr_list); + EINA_LIST_FREE(attr_list, attr) + { + eina_stringshare_del(attr->key); + eina_stringshare_del(attr->value); + free(attr); + } + attr_list = NULL; + efl_access_object_attribute_del(g_btn, "color4");//non existent key deletion + efl_access_object_attribute_del(g_btn, "color3");//existing key deletion + attr_list = efl_access_object_attributes_get(g_btn); + ck_assert(attr_list != NULL); + count2 = eina_list_count(attr_list); + ck_assert(count1 == (count2+1)); + EINA_LIST_FREE(attr_list, attr) + { + eina_stringshare_del(attr->key); + eina_stringshare_del(attr->value); + free(attr); + } +} +EFL_END_TEST + +EFL_START_TEST(test_efl_access_object_attributes_clear) +{ + Eina_List *attr_list = NULL; + Efl_Access_Attribute *attr = NULL; + generate_app(); + efl_access_object_attribute_append(g_btn, "color1", "red"); + efl_access_object_attribute_append(g_btn, "color2", "blue"); + efl_access_object_attribute_append(g_btn, "color3", "green"); + efl_access_object_attributes_clear(g_btn); + attr_list = efl_access_object_attributes_get(g_btn);//default attributes are added again + ck_assert(attr_list != NULL); + ck_assert(eina_list_count(attr_list) <= 2); + EINA_LIST_FREE(attr_list, attr) + { + eina_stringshare_del(attr->key); + eina_stringshare_del(attr->value); + free(attr); + } +} +EFL_END_TEST + void efl_ui_test_atspi(TCase *tc) { tcase_add_test(tc, test_efl_access_app_obj_name_get); @@ -469,4 +583,8 @@ void efl_ui_test_atspi(TCase *tc) tcase_add_test(tc, test_efl_access_object_relationship_append); tcase_add_test(tc, test_efl_access_object_relationship_remove); tcase_add_test(tc, test_efl_access_object_relationships_clear); + tcase_add_test(tc, test_efl_access_object_attribute_append); + tcase_add_test(tc, test_efl_access_object_attributes_get); + tcase_add_test(tc, test_efl_access_object_attribute_del); + tcase_add_test(tc, test_efl_access_object_attributes_clear); } |