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
This commit is contained in:
Shilpa Singh 2019-03-20 14:16:11 +00:00 committed by Marcel Hollerbach
parent 89d80ffc52
commit e80169a844
3 changed files with 149 additions and 1 deletions

View File

@ -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;

View File

@ -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.]]
}

View File

@ -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);
}