From 61845ef60012f959533d87b275b0b6c7b3647572 Mon Sep 17 00:00:00 2001 From: Lukasz Stanislawski Date: Fri, 2 Oct 2015 16:44:19 +0200 Subject: [PATCH] atspi: properly set parent. Set proper atspi parents in cases when AT-SPI object tree structure should be different then elementary tree (mostly in cases of elm_widget_items) Add regression tests for those cases. --- legacy/elementary/src/lib/elm_gengrid.c | 15 +++++ legacy/elementary/src/lib/elm_genlist.c | 3 + legacy/elementary/src/lib/elm_list.c | 7 +++ legacy/elementary/src/lib/elm_toolbar.c | 8 +++ .../elementary/src/tests/elm_test_gengrid.c | 55 ++++++++++++++++++- .../elementary/src/tests/elm_test_genlist.c | 38 +++++++++++++ legacy/elementary/src/tests/elm_test_list.c | 31 +++++++++++ 7 files changed, 156 insertions(+), 1 deletion(-) diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c index 580d07a343..01c72ccef6 100644 --- a/legacy/elementary/src/lib/elm_gengrid.c +++ b/legacy/elementary/src/lib/elm_gengrid.c @@ -898,6 +898,9 @@ _item_content_realize(Elm_Gen_Item *it, elm_widget_sub_object_add(WIDGET(it), content); if (eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get())) elm_widget_disabled_set(content, EINA_TRUE); + + if (_elm_config->atspi_mode && eo_isa(content, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN)) + eo_do(content, elm_interface_atspi_accessible_parent_set(EO_OBJ(it))); } } } @@ -4432,6 +4435,12 @@ _elm_gengrid_item_append(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_C ecore_job_del(sd->calc_job); sd->calc_job = ecore_job_add(_calc_job, obj); + if (_elm_config->atspi_mode) + { + elm_interface_atspi_accessible_added(EO_OBJ(it)); + elm_interface_atspi_accessible_children_changed_added_signal_emit(sd->obj, EO_OBJ(it)); + } + return EO_OBJ(it); } @@ -4452,6 +4461,12 @@ _elm_gengrid_item_prepend(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_ ecore_job_del(sd->calc_job); sd->calc_job = ecore_job_add(_calc_job, obj); + if (_elm_config->atspi_mode) + { + elm_interface_atspi_accessible_added(EO_OBJ(it)); + elm_interface_atspi_accessible_children_changed_added_signal_emit(sd->obj, EO_OBJ(it)); + } + return EO_OBJ(it); } diff --git a/legacy/elementary/src/lib/elm_genlist.c b/legacy/elementary/src/lib/elm_genlist.c index d76352f66a..cb71fb95d3 100644 --- a/legacy/elementary/src/lib/elm_genlist.c +++ b/legacy/elementary/src/lib/elm_genlist.c @@ -396,6 +396,9 @@ _item_content_realize(Elm_Gen_Item *it, snprintf(buf, sizeof(buf), "elm,state,%s,visible", key); edje_object_signal_emit(target, buf, "elm"); + + if (_elm_config->atspi_mode) + eo_do(content, elm_interface_atspi_accessible_parent_set(EO_OBJ(it))); } } } diff --git a/legacy/elementary/src/lib/elm_list.c b/legacy/elementary/src/lib/elm_list.c index 708648676b..3a4e2fd994 100644 --- a/legacy/elementary/src/lib/elm_list.c +++ b/legacy/elementary/src/lib/elm_list.c @@ -2346,6 +2346,13 @@ _item_new(Evas_Object *obj, obj); } + if (_elm_config->atspi_mode) + { + if (it->end) eo_do(it->end, elm_interface_atspi_accessible_parent_set(eo_it)); + if (it->icon) eo_do(it->icon, elm_interface_atspi_accessible_parent_set(eo_it)); + elm_interface_atspi_accessible_added(eo_it); + } + return it; } diff --git a/legacy/elementary/src/lib/elm_toolbar.c b/legacy/elementary/src/lib/elm_toolbar.c index 124c2ca611..aa39481836 100644 --- a/legacy/elementary/src/lib/elm_toolbar.c +++ b/legacy/elementary/src/lib/elm_toolbar.c @@ -2431,6 +2431,14 @@ _item_new(Evas_Object *obj, _resizing_eval_item(it); if ((!sd->items) && (sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS)) _item_select(it); + + if (_elm_config->atspi_mode) + { + eo_do(icon_obj, elm_interface_atspi_accessible_parent_set(eo_it)); + eo_do(VIEW(it), elm_interface_atspi_accessible_parent_set(eo_it)); + elm_interface_atspi_accessible_added(eo_it); + } + return it; } diff --git a/legacy/elementary/src/tests/elm_test_gengrid.c b/legacy/elementary/src/tests/elm_test_gengrid.c index 1d95a67bc5..f0b3c2a299 100644 --- a/legacy/elementary/src/tests/elm_test_gengrid.c +++ b/legacy/elementary/src/tests/elm_test_gengrid.c @@ -5,6 +5,7 @@ #define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED #include #include "elm_suite.h" +#include "elm_test_helper.h" START_TEST (elm_atspi_role_get) @@ -24,7 +25,59 @@ START_TEST (elm_atspi_role_get) } END_TEST +// Temporary commnted since gengrid fields_update function do not call content callbacks +// (different behaviour then genlist - which calls) +#if 0 +static Evas_Object *content; + +static Evas_Object * +gl_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part EINA_UNUSED) +{ + content = elm_button_add(obj); + evas_object_show(content); + return content; +} + +/** + * Validate if gengrid implementation properly reset AT-SPI parent to Elm_Gengrid_Item + * from Elm_Gengrid + */ +START_TEST(elm_atspi_children_parent) +{ + elm_init(1, NULL); + elm_config_atspi_mode_set(EINA_TRUE); + static Elm_Gengrid_Item_Class itc; + + Evas_Object *win = elm_win_add(NULL, "gengrid", ELM_WIN_BASIC); + evas_object_resize(win, 100, 100); + Evas_Object *gengrid = elm_gengrid_add(win); + evas_object_resize(gengrid, 100, 100); + + Elm_Interface_Atspi_Accessible *parent; + content = NULL; + + itc.item_style = "default"; + itc.func.content_get = gl_content_get; + + evas_object_show(win); + evas_object_show(gengrid); + + Elm_Object_Item *it = elm_gengrid_item_append(gengrid, &itc, NULL, NULL, NULL); + elm_gengrid_item_fields_update(it, "*.", ELM_GENGRID_ITEM_FIELD_CONTENT); + + ck_assert(content != NULL); + eo_do(content, parent = elm_interface_atspi_accessible_parent_get()); + ck_assert(it == parent); + + elm_shutdown(); +} +END_TEST +#endif + void elm_test_gengrid(TCase *tc) { - tcase_add_test(tc, elm_atspi_role_get); + tcase_add_test(tc, elm_atspi_role_get); +#if 0 + tcase_add_test(tc, elm_atspi_children_parent); +#endif } diff --git a/legacy/elementary/src/tests/elm_test_genlist.c b/legacy/elementary/src/tests/elm_test_genlist.c index 1dc64a256c..84caec82a2 100644 --- a/legacy/elementary/src/tests/elm_test_genlist.c +++ b/legacy/elementary/src/tests/elm_test_genlist.c @@ -11,6 +11,8 @@ static Elm_Gen_Item_Class itc; static Eo *current; static int counter; static Elm_Atspi_Event_Children_Changed_Data ev_data; +Evas_Object *content; + void test_init(void) { @@ -178,6 +180,41 @@ START_TEST(elm_atspi_children_events_del2) } END_TEST +static Evas_Object * +gl_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part EINA_UNUSED) +{ + content = elm_button_add(obj); + return content; +} + +/** + * Validate if genlist implementation properly reset AT-SPI parent to Elm_Genlist_Item + * from Elm_Genlist + */ +START_TEST(elm_atspi_children_parent) +{ + test_init(); + + evas_object_show(genlist); + + Elm_Object_Item *it; + Elm_Interface_Atspi_Accessible *parent; + content = NULL; + + itc.item_style = "default"; + 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); + + ck_assert(content != NULL); + eo_do(content, parent = elm_interface_atspi_accessible_parent_get()); + ck_assert(it == parent); + + elm_shutdown(); +} +END_TEST + void elm_test_genlist(TCase *tc) { tcase_add_test(tc, elm_atspi_role_get); @@ -186,4 +223,5 @@ void elm_test_genlist(TCase *tc) tcase_add_test(tc, elm_atspi_children_events_add); tcase_add_test(tc, elm_atspi_children_events_del1); tcase_add_test(tc, elm_atspi_children_events_del2); + tcase_add_test(tc, elm_atspi_children_parent); } diff --git a/legacy/elementary/src/tests/elm_test_list.c b/legacy/elementary/src/tests/elm_test_list.c index 4578dd1b06..c5404c3541 100644 --- a/legacy/elementary/src/tests/elm_test_list.c +++ b/legacy/elementary/src/tests/elm_test_list.c @@ -200,6 +200,36 @@ START_TEST (elm_atspi_role_get) } END_TEST + +/** + * Validate if genlist implementation properly reset parent to Elm_Genlist_Item + * from Elm_Genlist + */ +START_TEST(elm_atspi_children_parent) +{ + Elm_Interface_Atspi_Accessible *parent; + + elm_init(1, NULL); + Evas_Object *win = elm_win_add(NULL, "list", ELM_WIN_BASIC); + + Evas_Object *icon = elm_icon_add(win); + Evas_Object *end = elm_icon_add(win); + + Evas_Object *list = elm_list_add(win); + Elm_Object_Item *it = elm_list_item_append(list, "First Element", icon, end, NULL, NULL); + + evas_object_show(list); + + eo_do(icon, parent = elm_interface_atspi_accessible_parent_get()); + ck_assert(it == parent); + + eo_do(end, parent = elm_interface_atspi_accessible_parent_get()); + ck_assert(it == parent); + + elm_shutdown(); +} +END_TEST + void elm_test_list(TCase *tc) { tcase_add_test(tc, elm_atspi_role_get); @@ -212,4 +242,5 @@ void elm_test_list(TCase *tc) tcase_add_test(tc, elm_list_atspi_selection_clear); tcase_add_test(tc, elm_list_atspi_selection_child_deselect); #endif + tcase_add_test(tc, elm_atspi_children_parent); }