Fix double reading issue [mobile-demo>Toolbar>Tab Style> List Item, or Menu Item] 48/123148/3
authorPawel Kurowski <p.kurowski2@samsung.com>
Tue, 4 Apr 2017 16:51:11 +0000 (18:51 +0200)
committerPawel Kurowski <p.kurowski2@samsung.com>
Wed, 5 Apr 2017 10:20:52 +0000 (03:20 -0700)
Fix bug that was allowing to unselect List Item, or Menu Item by double tap

Add IDS_ACCS_BODY_SELECTED_TTS to state reading info of Menu Item

Change-Id: I851c49f5c4b4f3bb639380a18c03039d4bb14117

src/app_tracker.c
src/navigator.c
src/screen_reader_utils.c
tests2/utils_description_trait.cpp
tests2/utils_state_trait.cpp

index c634754aa232ca3185c31387655a517aac96cee6..37b7c7b8b8369dfffb97b792d6b9220a777e77ed 100644 (file)
@@ -491,52 +491,55 @@ static void _on_atspi_event_cb(AtspiEvent *event, void *user_data)
        }
 
        if (!strcmp(event->type, "object:state-changed:selected") && (attribute & ACCESSIBLE_READING_INFO_TYPE_STATE)) {
-               char buf[256] = "\0";
+               char buf[256] = {0};
                AtspiAccessible *parent = atspi_accessible_get_parent(event->source, NULL);
                gchar *name = atspi_accessible_get_name(event->source, NULL);
                if (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_MENU_ITEM) {
-                       char tab_index[16] = "\0";
-                       int children_count = atspi_accessible_get_child_count(parent, NULL);
-                       int index = atspi_accessible_get_index_in_parent(event->source, NULL);
-                       strncat(buf, name, sizeof(buf) - strlen(buf) - 1);
-                       strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1);
-                       snprintf(tab_index, sizeof(tab_index), _("IDS_ACCS_BODY_TAB_P1SD_OF_P2SD"), index + 1, children_count);
-                       strncat(buf, tab_index, sizeof(buf) - strlen(buf) - 1);
-                       strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1);
                        if (event->detail1) {
+                               char tab_index[16] = {0};
+                               int children_count = atspi_accessible_get_child_count(parent, NULL);
+                               int index = atspi_accessible_get_index_in_parent(event->source, NULL);
+                               strncat(buf, name, sizeof(buf) - strlen(buf) - 1);
+                               strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1);
+                               snprintf(tab_index, sizeof(tab_index), _("IDS_ACCS_BODY_TAB_P1SD_OF_P2SD"), index + 1, children_count);
+                               strncat(buf, tab_index, sizeof(buf) - strlen(buf) - 1);
+                               strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1);
                                strncat(buf, _("IDS_ACCS_BODY_SELECTED_TTS"), sizeof(buf) - strlen(buf) - 1);
+                               tts_speak(buf, EINA_TRUE, tts_data);
                        }
-                       else strncat(buf, _("IDS_ACCS_BODY_DOUBLE_TAP_TO_SELECT_TTS"), sizeof(buf) - strlen(buf) - 1);
-                       tts_speak(buf, EINA_TRUE, tts_data);
                }
-               else if (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_LIST_ITEM && atspi_accessible_get_role(parent, NULL) == ATSPI_ROLE_TREE_TABLE) {
+               else if (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_LIST_ITEM || atspi_accessible_get_role(parent, NULL) == ATSPI_ROLE_TREE_TABLE) {
                        if (event->detail1) {
                                AtspiStateSet *parent_state_set = atspi_accessible_get_state_set(parent);
                                bool is_parent_multiselectable = atspi_state_set_contains(parent_state_set, ATSPI_STATE_MULTISELECTABLE);
-                               snprintf(buf, sizeof(buf), "%s, %s, ", name,_("IDS_BR_BODY_IMAGE_T_TTS"));
+                               snprintf(buf, sizeof(buf) - 1, name);
 
                                AtspiStateSet *state_set = atspi_accessible_get_state_set(event->source);
                                gboolean is_selected = atspi_state_set_contains(state_set, ATSPI_STATE_SELECTED);
                                g_object_unref(state_set);
 
-                               if(is_selected)
-                                       snprintf(buf + strlen(buf), sizeof(buf), "%s, ", _("IDS_ACCS_BODY_SELECTED_TTS"));
+                               if(is_selected){
+                                       if (buf[0] != 0)
+                                               snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf) - 1, ", ");
+                                       snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf) -1, _("IDS_ACCS_BODY_SELECTED_TTS"));
+                               }
 
                                if(is_parent_multiselectable) {
                                        AtspiSelection *parent_selection = atspi_accessible_get_selection(parent);
                                        int selected_children_count = atspi_selection_get_n_selected_children(parent_selection, NULL);
-                                       snprintf(buf + strlen(buf), sizeof(buf), _("IDS_SCR_BODY_PD_SELECTED_IN_TOTAL_TTS"), selected_children_count);
+                                       if (buf[0] != 0)
+                                               snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf) - 1, ", ");
+                                       snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf) - 1, _("IDS_SCR_BODY_PD_SELECTED_IN_TOTAL_TTS"), selected_children_count);
                                        g_object_unref(parent_selection);
                                }
-                               else {
-                                       snprintf(buf + strlen(buf), sizeof(buf), _("IDS_ACCS_BODY_SELECTED_TTS"));
-                               }
                                tts_speak(buf, EINA_TRUE, tts_data);
                                g_object_unref(parent_state_set);
                        }
                }
-               else strncat(buf, _("IDS_ACCS_BODY_DOUBLE_TAP_TO_SELECT_TTS"), sizeof(buf) - strlen(buf) - 1);
-               tts_speak(buf, EINA_TRUE, tts_data);
+               else {
+                       strncat(buf, _("IDS_ACCS_BODY_DOUBLE_TAP_TO_SELECT_TTS"), sizeof(buf) - strlen(buf)  - 1);
+                       tts_speak(buf, EINA_TRUE, tts_data);
+               }
                g_free(name);
                g_object_unref(parent);
        }
index 9ec1b6190fed279d5fd50596bc4902e7a9a30365..570c8486be5751f7b9e6b4769f0eb1196492c868 100644 (file)
@@ -921,8 +921,10 @@ static void _activate_widget(Navigator_Data *nd, Screen_Reader_Vconf_Data_t *vco
                                gint index = atspi_accessible_get_index_in_parent(current_widget, NULL);
                                AtspiSelection *selection = atspi_accessible_get_selection_iface(parent);
                                if (selection) {
-                                       if(atspi_state_set_contains(ss, ATSPI_STATE_SELECTED))
-                                               atspi_selection_deselect_child (selection, index, NULL);
+                                       if(atspi_state_set_contains(ss, ATSPI_STATE_SELECTED)) {
+                                               if(!(role == ATSPI_ROLE_LIST_ITEM || role == ATSPI_ROLE_MENU_ITEM))
+                                                       atspi_selection_deselect_child (selection, index, NULL);
+                                               }
                                        else {
                                                DEBUG("SELECT CHILD NO:%d\n", index);
                                                atspi_selection_select_child(selection, index, NULL);
index bfbb013a57db791912a0dbe54784aa38e815b3f0..a84d6b067dc9651d5cc3b58bf7a56b2791e14926 100644 (file)
@@ -412,7 +412,9 @@ char *generate_description_trait(AtspiAccessible *obj) {
                        gboolean is_selected = atspi_selection_is_child_selected(selection, index, &err);
                        GERROR_CHECK(err);
                        snprintf(ret, sizeof(ret), _("IDS_ACCS_BODY_TAB_P1SD_OF_P2SD"), index + 1, children_count);
-                       if (!is_selected)
+                       if (is_selected)
+                               snprintf(ret + strlen(ret), sizeof(ret), ", %s", _("IDS_ACCS_BODY_SELECTED_TTS"));
+                       else
                                snprintf(ret + strlen(ret), sizeof(ret), ", %s", _("IDS_ACCS_BODY_DOUBLE_TAP_TO_SELECT_TTS"));
                        g_object_unref(selection);
                }
@@ -556,7 +558,7 @@ char *generate_state_trait(AtspiAccessible *obj)
                AtspiRole parent_role = atspi_accessible_get_role(parent, NULL);
                g_object_unref(parent);
 
-               if (parent_role == ATSPI_ROLE_TREE_TABLE) {
+               if (parent_role == ATSPI_ROLE_TREE_TABLE || parent_role == ATSPI_ROLE_LIST) {
                        gboolean is_selected = atspi_state_set_contains(state_set, ATSPI_STATE_SELECTED);
 
                        if (is_selected)
@@ -587,7 +589,8 @@ char *generate_state_trait(AtspiAccessible *obj)
                break;
        }
        case ATSPI_ROLE_RADIO_MENU_ITEM: {
-               strncpy(ret, _("IDS_ACCS_BODY_SELECTED_TTS"), sizeof(ret) - strlen(ret) - 1);
+               if (atspi_state_set_contains(state_set, ATSPI_STATE_CHECKED))
+                       strncpy(ret, _("IDS_ACCS_BODY_SELECTED_TTS"), sizeof(ret) - strlen(ret) - 1);
                break;
        }
 
index da44becb6c47a5eb0fb19db203ec8ec028580926..0435444897bbc5057a3e243ef3ad536d517a4fe7 100644 (file)
@@ -115,7 +115,7 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, MenuItemWithToolbarSelec
 
        EXPECT_FUNCTION_CALL(m_atspi_selection_is_child_selected, (_, _, _)).WillOnce(Return(true));
 
-       EXPECT_STREQ(generate_description_trait(obj_), "IDS_ACCS_BODY_TAB_P1SD_OF_P2SD");
+       EXPECT_STREQ(generate_description_trait(obj_), "IDS_ACCS_BODY_TAB_P1SD_OF_P2SD, IDS_ACCS_BODY_SELECTED_TTS");
 }
 
 TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, MenuItemWithToolbarNotSelected) {
index 6d0f902fe31ca030b9c81a795c2f4e24304434c1..643a9743905014b44ec9614007041c20f5d8a29d 100644 (file)
@@ -179,5 +179,5 @@ TEST_F(StateTraitFixture, RadioMenuItem) {
 
        CallGeneralDependencies(ATSPI_ROLE_RADIO_MENU_ITEM, stateSet_);
 
-       RunGenStateTraitAndFreeMemory(obj_, "IDS_ACCS_BODY_SELECTED_TTS");
+       RunGenStateTraitAndFreeMemory(obj_, "");
 }