atspi: overload children_get method for elm_genlist
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 30 Sep 2014 11:10:22 +0000 (13:10 +0200)
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>
Mon, 6 Apr 2015 08:24:56 +0000 (10:24 +0200)
src/lib/elm_genlist.c
src/lib/elm_genlist.eo
src/tests/elm_test_genlist.c

index 4aa0d86..84af800 100644 (file)
@@ -7817,5 +7817,20 @@ _elm_genlist_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUS
    return &atspi_actions[0];
 }
 
+EOLIAN Eina_List*
+_elm_genlist_elm_interface_atspi_accessible_children_get(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd)
+{
+   Eina_List *ret = NULL;
+   Elm_Gen_Item *it;
+
+   EINA_INLIST_FOREACH(sd->items, it)
+     {
+        if (!it->parent)
+          ret = eina_list_append(ret, EO_OBJ(it));
+     }
+
+   return ret;
+}
+
 #include "elm_genlist.eo.c"
 #include "elm_genlist_item.eo.c"
index dcf40f3..0595a74 100644 (file)
@@ -728,6 +728,7 @@ class Elm_Genlist (Elm_Layout, Elm_Interface_Scrollable, Evas.Clickable_Interfac
       Elm_Layout.sizing_eval;
       Elm_Interface_Scrollable.bounce_allow;
       Elm_Interface_Scrollable.policy;
+      Elm_Interface_Atspi_Accessible.children.get;
       Elm_Interface_Atspi_Widget_Action.elm_actions.get;
    }
    events {
index d3bb70d..1dd3135 100644 (file)
@@ -6,16 +6,22 @@
 #include <Elementary.h>
 #include "elm_suite.h"
 
+static Evas_Object *win, *genlist;
+static Elm_Gen_Item_Class itc;
 
-START_TEST (elm_atspi_role_get)
+void test_init(void)
 {
-   Evas_Object *win, *genlist;
-   Elm_Atspi_Role role;
-
    elm_init(1, NULL);
    win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
-
    genlist = elm_genlist_add(win);
+}
+
+START_TEST (elm_atspi_role_get)
+{
+   test_init();
+
+   Elm_Atspi_Role role;
+
    eo_do(genlist, role = elm_interface_atspi_accessible_role_get());
 
    ck_assert(role == ELM_ATSPI_ROLE_LIST);
@@ -24,7 +30,63 @@ START_TEST (elm_atspi_role_get)
 }
 END_TEST
 
+START_TEST(elm_atspi_children_get1)
+{
+   test_init();
+   Eina_List *children;
+   Elm_Object_Item *it[3];
+
+   eo_do(genlist, children = elm_interface_atspi_accessible_children_get());
+   ck_assert(children == NULL);
+
+   it[0] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+   it[1] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+   it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+
+   eo_do(genlist, children = elm_interface_atspi_accessible_children_get());
+   ck_assert(eina_list_count(children) == 3);
+   ck_assert(eina_list_nth(children, 0) == it[0]);
+   ck_assert(eina_list_nth(children, 1) == it[1]);
+   ck_assert(eina_list_nth(children, 2) == it[2]);
+
+   eina_list_free(children);
+
+   elm_genlist_item_append(genlist, &itc, NULL, it[0], ELM_GENLIST_ITEM_NONE, NULL, NULL);
+   elm_genlist_item_append(genlist, &itc, NULL, it[1], ELM_GENLIST_ITEM_NONE, NULL, NULL);
+   elm_genlist_item_append(genlist, &itc, NULL, it[2], ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+   eo_do(genlist, children = elm_interface_atspi_accessible_children_get());
+   ck_assert(eina_list_count(children) == 3);
+   ck_assert(eina_list_nth(children, 0) == it[0]);
+   ck_assert(eina_list_nth(children, 1) == it[1]);
+   ck_assert(eina_list_nth(children, 2) == it[2]);
+
+   elm_shutdown();
+}
+END_TEST
+
+START_TEST(elm_atspi_children_get2)
+{
+   test_init();
+   Eina_List *children;
+   Elm_Object_Item *it[3];
+
+   it[0] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+   it[1] = elm_genlist_item_prepend(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+   it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+
+   eo_do(genlist, children = elm_interface_atspi_accessible_children_get());
+   ck_assert(eina_list_nth(children, 1) == it[0]);
+   ck_assert(eina_list_nth(children, 0) == it[1]);
+   ck_assert(eina_list_nth(children, 2) == it[2]);
+
+   elm_shutdown();
+}
+END_TEST
+
 void elm_test_genlist(TCase *tc)
 {
- tcase_add_test(tc, elm_atspi_role_get);
+   tcase_add_test(tc, elm_atspi_role_get);
+   tcase_add_test(tc, elm_atspi_children_get1);
+   tcase_add_test(tc, elm_atspi_children_get2);
 }