stanluk pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=11e38c716b77d45917b9417caf7517cd4e63cf9b

commit 11e38c716b77d45917b9417caf7517cd4e63cf9b
Author: Lukasz Stanislawski <l.stanisl...@samsung.com>
Date:   Tue Oct 6 15:38:09 2015 +0200

    tests: add new tests for AT-SPI beta API.
---
 src/lib/elm_widget.c         |   5 +
 src/tests/elm_test_atspi.c   | 321 ++++++++++++++++++++++++++++++++++++++++++-
 src/tests/elm_test_genlist.c |   2 +-
 3 files changed, 325 insertions(+), 3 deletions(-)

diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 4a9022f..4996141 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -5810,6 +5810,11 @@ EOLIAN static char*
 _elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, 
Elm_Widget_Smart_Data *_pd EINA_UNUSED)
 {
    const char *ret;
+   char *name;
+   eo_do_super(obj, ELM_WIDGET_CLASS, name = 
elm_interface_atspi_accessible_name_get());
+
+   if (name) return name;
+
    ret = elm_object_text_get(obj);
    if (!ret) return NULL;
 
diff --git a/src/tests/elm_test_atspi.c b/src/tests/elm_test_atspi.c
index da616ff..bf7c3b5 100644
--- a/src/tests/elm_test_atspi.c
+++ b/src/tests/elm_test_atspi.c
@@ -25,7 +25,7 @@ void generate_app(void)
    evas_object_show(g_win);
 }
 
-START_TEST (elm_atspi_name_get)
+START_TEST (elm_atspi_app_obj_name_get)
 {
    elm_init(0, NULL);
 
@@ -46,6 +46,64 @@ START_TEST (elm_atspi_name_get)
 }
 END_TEST
 
+START_TEST (elm_atspi_name_get)
+{
+   elm_init(0, NULL);
+   generate_app();
+
+   char *name;
+
+   eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
+
+   if (name && name[0]) {
+      ck_assert(0);
+   }
+
+   free(name);
+
+   // Set name with additional text tags
+   elm_object_text_set(g_btn, "Some<br>text");
+
+   eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
+
+   // Accessible name should have cleared tags
+   ck_assert(name != NULL);
+   ck_assert_str_eq(name, "Some\ntext");
+
+   free(name);
+   elm_shutdown();
+}
+END_TEST
+
+START_TEST (elm_atspi_name_set)
+{
+   elm_init(0, NULL);
+   generate_app();
+
+   char *name;
+
+   elm_object_text_set(g_btn, "Other text");
+   eo_do(g_btn, elm_interface_atspi_accessible_name_set("Test name"));
+
+   eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
+
+   ck_assert(name != NULL);
+   ck_assert_str_eq(name, "Test name");
+
+   free(name);
+
+   eo_do(g_btn, elm_interface_atspi_accessible_name_set(NULL));
+   eo_do(g_btn, name = elm_interface_atspi_accessible_name_get());
+
+   ck_assert(name != NULL);
+   ck_assert_str_eq(name, "Other text");
+
+   free(name);
+
+   elm_shutdown();
+}
+END_TEST
+
 START_TEST (elm_atspi_role_get)
 {
    elm_init(0, NULL);
@@ -63,6 +121,29 @@ START_TEST (elm_atspi_role_get)
 }
 END_TEST
 
+START_TEST (elm_atspi_role_set)
+{
+   elm_init(0, NULL);
+   generate_app();
+   Elm_Atspi_Role role;
+
+   eo_do(g_btn, 
elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_ACCELERATOR_LABEL));
+   eo_do(g_btn, role = elm_interface_atspi_accessible_role_get());
+
+   if (role != ELM_ATSPI_ROLE_ACCELERATOR_LABEL)
+      ck_assert(0);
+
+   eo_do(g_btn, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_ENTRY));
+   eo_do(g_btn, role = elm_interface_atspi_accessible_role_get());
+
+   if (role != ELM_ATSPI_ROLE_ENTRY)
+      ck_assert(0);
+
+   elm_shutdown();
+}
+END_TEST
+
+
 
 START_TEST (elm_atspi_role_name_get)
 {
@@ -113,17 +194,36 @@ START_TEST (elm_atspi_description_set)
    ck_assert(ret == NULL);
 
    eo_do(root, elm_interface_atspi_accessible_description_set(desc));
-
    eo_do(root, ret = elm_interface_atspi_accessible_description_get());
 
    ck_assert(ret != NULL);
    ck_assert_str_eq(ret, "Test description");
 
+   eo_do(root, elm_interface_atspi_accessible_description_set(NULL));
+   eo_do(root, ret = elm_interface_atspi_accessible_description_get());
+
+   ck_assert(ret == NULL);
+
    eo_unref(root);
    elm_shutdown();
 }
 END_TEST
 
+/* Test if intial description value is NULL */
+START_TEST (elm_atspi_description_get)
+{
+   elm_init(0, NULL);
+   generate_app();
+
+   const char *descr;
+   eo_do(g_bg, descr = elm_interface_atspi_accessible_description_get());
+
+   ck_assert(descr == NULL);
+
+   elm_shutdown();
+}
+END_TEST
+
 START_TEST (elm_atspi_children_and_parent)
 {
    elm_init(0, NULL);
@@ -184,13 +284,230 @@ START_TEST (elm_atspi_children_and_parent2)
 }
 END_TEST
 
+/* Initial value of translation domain should be NULL */
+START_TEST (elm_atspi_translation_domain_get)
+{
+   elm_init(0, NULL);
+   generate_app();
+
+   const char *domain;
+
+   eo_do(g_btn, domain = 
elm_interface_atspi_accessible_translation_domain_get());
+
+   ck_assert(domain == NULL);
+
+   elm_shutdown();
+}
+END_TEST
+
+START_TEST (elm_atspi_translation_domain_set)
+{
+   elm_init(0, NULL);
+   generate_app();
+
+   const char *domain;
+
+   eo_do(g_btn, elm_interface_atspi_accessible_translation_domain_set("Test 
translation_domain"));
+   eo_do(g_btn, domain = 
elm_interface_atspi_accessible_translation_domain_get());
+
+   ck_assert(domain != NULL);
+   ck_assert_str_eq(domain, "Test translation_domain");
+
+   eo_do(g_btn, elm_interface_atspi_accessible_translation_domain_set(NULL));
+   eo_do(g_btn, domain = 
elm_interface_atspi_accessible_translation_domain_get());
+
+   ck_assert(domain == NULL);
+
+   elm_shutdown();
+}
+END_TEST
+
+START_TEST (elm_atspi_relationship_append)
+{
+   elm_init(0, NULL);
+   generate_app();
+
+   Elm_Atspi_Relation_Set set;
+   Elm_Atspi_Relation *rel, *rel_to, *rel_from;
+   Eina_List *l;
+
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_bg));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM,
 g_win));
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+
+   ck_assert(set != NULL);
+   ck_assert(eina_list_count(set) >= 2);
+
+   rel_to = rel_from = NULL;
+   EINA_LIST_FOREACH(set, l, rel)
+   {
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
+        rel_to = rel;
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
+        rel_from = rel;
+   }
+
+   ck_assert(rel_to != NULL);
+   ck_assert(eina_list_data_find(rel_to->objects, g_bg) != NULL);
+
+   ck_assert(rel_from != NULL);
+   ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
+
+   elm_atspi_relation_set_free(set);
+
+   /* Check if append do not procude duplicated relations */
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_bg));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM,
 g_win));
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+
+   rel_to = rel_from = NULL;
+   EINA_LIST_FOREACH(set, l, rel)
+   {
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
+        rel_to = rel;
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
+        rel_from = rel;
+   }
+
+   ck_assert(rel_to != NULL);
+   ck_assert(rel_to->objects != NULL);
+   rel_to->objects = eina_list_remove(rel_to->objects, g_bg);
+   ck_assert(eina_list_data_find(rel_to->objects, g_bg) == NULL);
+
+   ck_assert(rel_from != NULL);
+   ck_assert(rel_from->objects != NULL);
+   rel_from->objects = eina_list_remove(rel_from->objects, g_win);
+   ck_assert(eina_list_data_find(rel_from->objects, g_win) == NULL);
+
+   elm_atspi_relation_set_free(set);
+
+   elm_shutdown();
+}
+END_TEST
+
+START_TEST (elm_atspi_relationship_remove)
+{
+   elm_init(0, NULL);
+   generate_app();
+
+   Elm_Atspi_Relation_Set set;
+   Elm_Atspi_Relation *rel, *rel_to, *rel_from;
+   Eina_List *l;
+
+   /* Test if removal of single relationship works */
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_bg));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM,
 g_win));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_remove(ELM_ATSPI_RELATION_FLOWS_TO, 
g_bg));
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+
+   ck_assert(set != NULL);
+   ck_assert(eina_list_count(set) >= 1);
+
+   rel_to = rel_from = NULL;
+   EINA_LIST_FOREACH(set, l, rel)
+   {
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
+        rel_to = rel;
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
+        rel_from = rel;
+   }
+
+   if (rel_to) ck_assert(eina_list_data_find(rel_to->objects, g_bg) == NULL);
+   ck_assert(rel_from != NULL);
+   ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
+
+   elm_atspi_relation_set_free(set);
+
+   /* Test if removal of type relationship works */
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_bg));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_win));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_remove(ELM_ATSPI_RELATION_FLOWS_TO, 
NULL));
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+
+   rel_to = rel_from = NULL;
+   EINA_LIST_FOREACH(set, l, rel)
+   {
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
+        rel_to = rel;
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
+        rel_from = rel;
+   }
+
+   ck_assert(rel_to == NULL);
+   ck_assert(rel_from != NULL);
+   ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
+
+   elm_atspi_relation_set_free(set);
+
+   /* Test if relationship is implicity removed when object is deleted */
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_bg));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM,
 g_bg));
+   eo_del(g_bg);
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+
+   rel_to = rel_from = NULL;
+   EINA_LIST_FOREACH(set, l, rel)
+   {
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
+        rel_to = rel;
+      if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
+        rel_from = rel;
+   }
+
+   if (rel_to) ck_assert(eina_list_data_find(rel_to->objects, g_bg) == NULL);
+   if (rel_from) ck_assert(eina_list_data_find(rel_from->objects, g_bg) == 
NULL);
+
+   elm_atspi_relation_set_free(set);
+   elm_shutdown();
+}
+END_TEST
+
+START_TEST (elm_atspi_relationships_clear)
+{
+   Elm_Atspi_Relation_Set set;
+   Elm_Atspi_Relation *rel;
+   Eina_List *l;
+
+   elm_init(0, NULL);
+   generate_app();
+
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_bg));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM,
 g_bg));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, 
g_win));
+   eo_do(g_btn, 
elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM,
 g_win));
+
+   eo_do(g_btn, elm_interface_atspi_accessible_relationships_clear());
+
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+   EINA_LIST_FOREACH(set, l, rel)
+   {
+      ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_TO) && 
eina_list_data_find(rel->objects, g_bg)));
+      ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_FROM) && 
eina_list_data_find(rel->objects, g_bg)));
+      ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_TO) && 
eina_list_data_find(rel->objects, g_win)));
+      ck_assert(!((rel->type == ELM_ATSPI_RELATION_FLOWS_FROM) && 
eina_list_data_find(rel->objects, g_win)));
+   }
+
+   elm_atspi_relation_set_free(set);
+   elm_shutdown();
+}
+END_TEST
+
 void elm_test_atspi(TCase *tc)
 {
+   tcase_add_test(tc, elm_atspi_app_obj_name_get);
    tcase_add_test(tc, elm_atspi_name_get);
+   tcase_add_test(tc, elm_atspi_name_set);
    tcase_add_test(tc, elm_atspi_role_get);
+   tcase_add_test(tc, elm_atspi_role_set);
    tcase_add_test(tc, elm_atspi_role_name_get);
    tcase_add_test(tc, elm_atspi_localized_role_name_get);
    tcase_add_test(tc, elm_atspi_description_set);
+   tcase_add_test(tc, elm_atspi_description_get);
    tcase_add_test(tc, elm_atspi_children_and_parent);
    tcase_add_test(tc, elm_atspi_children_and_parent2);
+   tcase_add_test(tc, elm_atspi_translation_domain_get);
+   tcase_add_test(tc, elm_atspi_translation_domain_set);
+   tcase_add_test(tc, elm_atspi_relationship_append);
+   tcase_add_test(tc, elm_atspi_relationship_remove);
+   tcase_add_test(tc, elm_atspi_relationships_clear);
 }
diff --git a/src/tests/elm_test_genlist.c b/src/tests/elm_test_genlist.c
index 84caec8..593e04c 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)
    itc.func.content_get = gl_content_get;
 
    it = elm_genlist_item_append(genlist, &itc, NULL, NULL, 
ELM_GENLIST_ITEM_NONE, NULL, NULL);
-   elm_gengrid_item_fields_update(it, "*.", ELM_GENGRID_ITEM_FIELD_CONTENT);
+   elm_genlist_item_fields_update(it, "*.", ELM_GENGRID_ITEM_FIELD_CONTENT);
 
    ck_assert(content != NULL);
    eo_do(content, parent = elm_interface_atspi_accessible_parent_get());

-- 


Reply via email to