[orca] Fix for bgo#483212 - (Java) Missing significant information when performing where am i on combo box



commit 3fe4131c8740bbfa22719e8b377db31c20b4c9e4
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Thu Apr 22 20:51:54 2010 -0400

    Fix for bgo#483212 - (Java) Missing significant information when performing where am i on combo box items

 .../J2SE-access-bridge/speech_generator.py         |   42 ++++++++++++++++++++
 test/keystrokes/java/role_combo_box.py             |   17 ++++----
 2 files changed, 50 insertions(+), 9 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/J2SE-access-bridge/speech_generator.py b/src/orca/scripts/toolkits/J2SE-access-bridge/speech_generator.py
index ef0c1a8..53cf162 100644
--- a/src/orca/scripts/toolkits/J2SE-access-bridge/speech_generator.py
+++ b/src/orca/scripts/toolkits/J2SE-access-bridge/speech_generator.py
@@ -25,6 +25,7 @@ __license__   = "LGPL"
 
 import pyatspi
 
+import orca.settings as settings
 import orca.speech_generator as speech_generator
 
 ########################################################################
@@ -52,6 +53,47 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
         del args['requireText']
         return result
 
+    def _generatePositionInList(self, obj, **args):
+        """Returns an array of strings (and possibly voice and audio
+        specifications) that represent the relative position of an
+        object in a list.
+        """
+
+        listObj = None
+        if obj and obj.getRole() == pyatspi.ROLE_COMBO_BOX:
+            allLists = self._script.findByRole(obj, pyatspi.ROLE_LIST, False)
+            if len(allLists) == 1:
+                listObj = allLists[0]
+
+        if not listObj:
+            return speech_generator.SpeechGenerator._generatePositionInList(
+                self, obj, **args)
+
+        result = []
+        name = self._generateName(obj)
+        position = -1
+        index = total = 0
+
+        for child in listObj:
+            nextName = self._generateName(child)
+            if not nextName or nextName[0] in ["", "Empty", "separator"] \
+               or not child.getState().contains(pyatspi.STATE_VISIBLE):
+                continue
+
+            index += 1
+            total += 1
+
+            if nextName == name:
+                position = index
+
+        if (settings.enablePositionSpeaking or args.get('forceList', False)) \
+           and position >= 0:
+            result.append(self._script.formatting.getString(
+                              mode='speech', stringType='groupindex') \
+                              %  {"index" : position, "total" : total})
+
+        return result
+        
     def generateSpeech(self, obj, **args):
         result = []
         if args.get('formatType', 'unfocused') == 'basicWhereAmI' \
diff --git a/test/keystrokes/java/role_combo_box.py b/test/keystrokes/java/role_combo_box.py
index e14f96f..8146fb5 100644
--- a/test/keystrokes/java/role_combo_box.py
+++ b/test/keystrokes/java/role_combo_box.py
@@ -57,6 +57,8 @@ sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_TOGGLE_BUTTON))
 sequence.append(KeyComboAction("Tab"))
 sequence.append(WaitForFocus("ComboBox Demo", acc_role=pyatspi.ROLE_PAGE_TAB))
 
+sequence.append(PauseAction(5000))
+
 ##########################################################################
 # Focusing over first combo box
 # 
@@ -78,10 +80,9 @@ sequence.append(KeyComboAction("KP_Enter"))
 sequence.append(PauseAction(3000))
 sequence.append(utils.AssertPresentationAction(
     "2. basic Where Am I",
-    ["BUG? - Missing the item count. See bug 483212",
-     "BRAILLE LINE:  'SwingSet2 Application SwingSet2 Frame RootPane LayeredPane ComboBox Demo TabList ComboBox Demo Page Presets: Philip, Howard, Jeff Combo'",
+    ["BRAILLE LINE:  'SwingSet2 Application SwingSet2 Frame RootPane LayeredPane ComboBox Demo TabList ComboBox Demo Page Presets: Philip, Howard, Jeff Combo'",
      "     VISIBLE:  'Presets: Philip, Howard, Jeff Co', cursor=10",
-     "SPEECH OUTPUT: 'Presets: combo box Philip, Howard, Jeff'"]))
+     "SPEECH OUTPUT: 'Presets: combo box Philip, Howard, Jeff 1 of 10'"]))
 
 ##########################################################################
 # Bring up combo box list by pressing space
@@ -129,10 +130,9 @@ sequence.append(KeyComboAction("KP_Enter"))
 sequence.append(PauseAction(3000))
 sequence.append(utils.AssertPresentationAction(
     "6. basic Where Am I",
-    ["BUG? - Missing the item count. See bug 483212",
-     "BRAILLE LINE:  'SwingSet2 Application SwingSet2 Frame RootPane LayeredPane ComboBox Demo TabList ComboBox Demo Page Presets: Howard, Scott, Hans Combo'",
+    ["BRAILLE LINE:  'SwingSet2 Application SwingSet2 Frame RootPane LayeredPane ComboBox Demo TabList ComboBox Demo Page Presets: Howard, Scott, Hans Combo'",
      "     VISIBLE:  'Presets: Howard, Scott, Hans Com', cursor=10",
-     "SPEECH OUTPUT: 'Presets: combo box Howard, Scott, Hans'"]))
+     "SPEECH OUTPUT: 'Presets: combo box Howard, Scott, Hans 3 of 8'"]))
 
 ##########################################################################
 # Arrow down to next list item.
@@ -163,10 +163,9 @@ sequence.append(KeyComboAction("KP_Enter"))
 sequence.append(PauseAction(3000))
 sequence.append(utils.AssertPresentationAction(
     "9. basic Where Am I",
-    ["BUG? - Missing the item count. See bug 483212",
-     "BRAILLE LINE:  'SwingSet2 Application SwingSet2 Frame RootPane LayeredPane ComboBox Demo TabList ComboBox Demo Page Presets: Philip, Jeff, Hans Combo'",
+    ["BRAILLE LINE:  'SwingSet2 Application SwingSet2 Frame RootPane LayeredPane ComboBox Demo TabList ComboBox Demo Page Presets: Philip, Jeff, Hans Combo'",
      "     VISIBLE:  'Presets: Philip, Jeff, Hans Comb', cursor=10",
-     "SPEECH OUTPUT: 'Presets: combo box Philip, Jeff, Hans'"]))
+     "SPEECH OUTPUT: 'Presets: combo box Philip, Jeff, Hans 4 of 8'"]))
 
 ##########################################################################
 # Bring up combo box list by pressing space, the following should be 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]