orca r3699 - in trunk: . src/orca test/keystrokes/gtk-demo



Author: richb
Date: Fri Mar  7 21:32:15 2008
New Revision: 3699
URL: http://svn.gnome.org/viewvc/orca?rev=3699&view=rev

Log:
        * test/keystrokes/gtk-demo/role_icon.py:
          Fix for bug #519541 - gtk-demo/role_icon.py regression test #2 
          produces the wrong results.


Modified:
   trunk/ChangeLog
   trunk/src/orca/where_am_I.py
   trunk/test/keystrokes/gtk-demo/role_icon.py

Modified: trunk/src/orca/where_am_I.py
==============================================================================
--- trunk/src/orca/where_am_I.py	(original)
+++ trunk/src/orca/where_am_I.py	Fri Mar  7 21:32:15 2008
@@ -145,6 +145,9 @@
         elif role == pyatspi.ROLE_LABEL:
             self._speakLabel(obj, basicOnly)
 
+        elif role  == pyatspi.ROLE_LAYERED_PANE:
+            self._speakLayeredPane(obj, basicOnly)
+
         else:
             self._speakGenericObject(obj, basicOnly)
 
@@ -703,34 +706,7 @@
 
         utterances.append(_("Icon panel"))
         utterances.append(self.getObjLabelAndName(obj))
-
-        selectedItems = []
-        totalSelectedItems = 0
-        currentItem = 0
-        for child in panel:
-            state = child.getState()
-            if state.contains(pyatspi.STATE_SELECTED):
-                totalSelectedItems += 1
-                selectedItems.append(child)
-            if state.contains(pyatspi.STATE_FOCUSED):
-                currentItem = child.getIndexInParent() + 1
-
-        # Translators: this is a count of the number of selected icons 
-        # and the count of the total number of icons within an icon panel. 
-        # An example of an icon panel is the Nautilus folder view.
-        #
-        itemString = ngettext("%d of %d item selected",
-                              "%d of %d items selected",
-                              childCount) % \
-                              (totalSelectedItems, childCount)
-        utterances.append(itemString)
-
-        # Translators: this is a indication of the focused icon and the
-        # count of the total number of icons within an icon panel. An
-        # example of an icon panel is the Nautilus folder view.
-        #
-        itemString = _("on item %d of %d") % (currentItem, childCount)
-        utterances.append(itemString)
+        utterances.extend(self._getSelectedItemCount(panel))
 
         if not basicOnly:
             for i in range(0, len(selectedItems)):
@@ -866,6 +842,23 @@
         utterances.append(text)
         speech.speakUtterances(utterances)
 
+    def _speakLayeredPane(self, obj, basicOnly):
+        """Speak layered pane information:
+           1. Name/Label
+           2. Role
+           3. Number of selected items and total number of items.
+        """
+
+        utterances = []
+        text = self.getObjLabelAndName(obj)
+        utterances.append(text)
+
+        text = rolenames.getSpeechForRoleName(obj)
+        utterances.append(text)
+        utterances.extend(self._getSelectedItemCount(obj))
+
+        speech.speakUtterances(utterances)
+
     def _getSpeechForAllTextSelection(self, obj):
         """Check if this object has text associated with it and it's
         completely selected.
@@ -894,6 +887,43 @@
 
         return utterance
 
+    def _getSelectedItemCount(self, obj):
+        """Return a string indicating how many items are selected in this
+        object. This object will by an icon panel or a layered pane.
+
+        Arguments:
+        - obj: the object being presented
+        """
+
+        childCount = obj.childCount
+        selectedItems = []
+        totalSelectedItems = 0
+        currentItem = 0
+        for child in obj:
+            state = child.getState()
+            if state.contains(pyatspi.STATE_SELECTED):
+                totalSelectedItems += 1
+                selectedItems.append(child)
+            if state.contains(pyatspi.STATE_FOCUSED):
+                currentItem = child.getIndexInParent() + 1
+
+        # Translators: this is a count of the number of selected icons
+        # and the count of the total number of icons within an icon panel.
+        # An example of an icon panel is the Nautilus folder view.
+        #
+        countString = ngettext("%d of %d item selected",
+                              "%d of %d items selected",
+                              childCount) % \
+                              (totalSelectedItems, childCount)
+
+        # Translators: this is a indication of the focused icon and the
+        # count of the total number of icons within an icon panel. An
+        # example of an icon panel is the Nautilus folder view.
+        #
+        itemString = _("on item %d of %d") % (currentItem, childCount)
+
+        return [ countString, itemString ]
+
     def __extractSize(self, uri):
         """Get the http header for a given uri and try to extract the size
         (Content-length).

Modified: trunk/test/keystrokes/gtk-demo/role_icon.py
==============================================================================
--- trunk/test/keystrokes/gtk-demo/role_icon.py	(original)
+++ trunk/test/keystrokes/gtk-demo/role_icon.py	Fri Mar  7 21:32:15 2008
@@ -67,11 +67,12 @@
 sequence.append(PauseAction(3000))
 sequence.append(utils.AssertPresentationAction(
     "Layered pane Where Am I",
-    ["BUG? - should we present the number of items in the layered pane?",
-     "BRAILLE LINE:  'gtk-demo Application GtkIconView demo Frame ScrollPane LayeredPane'",
+    ["BRAILLE LINE:  'gtk-demo Application GtkIconView demo Frame ScrollPane LayeredPane'",
      "     VISIBLE:  'LayeredPane', cursor=1",
      "SPEECH OUTPUT: ''",
-     "SPEECH OUTPUT: 'layered pane'"]))
+     "SPEECH OUTPUT: 'layered pane'",
+     "SPEECH OUTPUT: '0 of 24 items selected'",
+     "SPEECH OUTPUT: 'on item 0 of 24'"]))
 
 ########################################################################
 # Down into the icon list, finally making something be selected in the
@@ -96,8 +97,12 @@
 sequence.append(PauseAction(3000))
 sequence.append(utils.AssertPresentationAction(
     "bin icon Where Am I",
-    ["BUG? - we cannot get reliable output from this test since it depends on the contents of /",
-     "BUG? - the icon is shown as selected, so we should present 1 of 26 items selected."]))
+    ["BRAILLE LINE:  'gtk-demo Application GtkIconView demo Frame ScrollPane LayeredPane bin Icon'",
+     "     VISIBLE:  'bin Icon', cursor=1",
+     "SPEECH OUTPUT: 'Icon panel'",
+     "SPEECH OUTPUT: 'bin'",
+     "SPEECH OUTPUT: '1 of 24 items selected'",
+     "SPEECH OUTPUT: 'on item 1 of 24'"]))
 
 ########################################################################
 # Arrow right and wait for the next icon to be selected.
@@ -135,8 +140,12 @@
 sequence.append(PauseAction(3000))
 sequence.append(utils.AssertPresentationAction(
     "icon selection Where Am I",
-    ["BUG? - we cannot get reliable output from this test since it depends on the contents of /",
-     "BUG? - we do not announce selection of icons (e.g., 2 of 26 items selected)."]))
+    ["BRAILLE LINE:  'gtk-demo Application GtkIconView demo Frame ScrollPane LayeredPane cdrom Icon'",
+     "     VISIBLE:  'cdrom Icon', cursor=1",
+     "SPEECH OUTPUT: 'Icon panel'",
+     "SPEECH OUTPUT: 'cdrom'",
+     "SPEECH OUTPUT: '2 of 24 items selected'",
+     "SPEECH OUTPUT: 'on item 3 of 24'"]))
 
 ########################################################################
 # Close the GtkIconView demo window



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