[orca] Fix for bgo#483222 - (Java) Where am i in JTree nodes gives little info
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix for bgo#483222 - (Java) Where am i in JTree nodes gives little info
- Date: Fri, 23 Apr 2010 15:49:14 +0000 (UTC)
commit a3646e64f395122990b0f696d4daedf8cc103dbb
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date: Fri Apr 23 11:47:13 2010 -0400
Fix for bgo#483222 - (Java) Where am i in JTree nodes gives little info
.../scripts/toolkits/J2SE-access-bridge/script.py | 76 +++++++++-----
test/keystrokes/java/role_tree.py | 103 ++++++++++----------
2 files changed, 99 insertions(+), 80 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
index 8a41876..f648737 100644
--- a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
+++ b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
@@ -58,7 +58,7 @@ class Script(default.Script):
# parent it shouldn't. See bgo#616582. [[[TODO - JD: remove
# this hack if and when we get a fix for that bug]]]
#
- self._lastDescendantChangedSource = None
+ self.lastDescendantChangedSource = None
def getSpeechGenerator(self):
"""Returns the speech generator for this script.
@@ -110,6 +110,31 @@ class Script(default.Script):
if 0 < keyval < 256:
keyboardEvent.event_string = unichr(keyval).encode("UTF-8")
+ def getValidObj(self, rootObj, obj, onlyShowing=True):
+ """Attempts to convert an older copy of an accessible into the
+ current, active version. We need to do this in order to ascend
+ the hierarchy.
+
+ Arguments:
+ - rootObj: the top-most ancestor of interest
+ - obj: the old object we're attempting to replace
+ - onlyShowing: whether or not we should limit matches to those
+ which have STATE_SHOWING
+
+ Returns an accessible replacement for obj if one can be found;
+ otherwise, None.
+ """
+
+ if not (obj and rootObj):
+ return None
+
+ items = self.findByRole(rootObj, obj.getRole(), onlyShowing)
+ for item in items:
+ if item.name == obj.name and self.isSameObject(item, obj):
+ return item
+
+ return None
+
def getNodeLevel(self, obj):
"""Determines the node level of this object if it is in a tree
relation, with 0 being the top level node. If this object is
@@ -119,34 +144,18 @@ class Script(default.Script):
-obj: the Accessible object
"""
- if not obj:
- return -1
-
- if not self._lastDescendantChangedSource:
- return default.Script.getNodeLevel(self, obj)
-
- # It would seem that Java is making multiple copies of accessibles
- # and/or killing them frequently. This is messing up our ability to
- # ascend the hierarchy. We need to see if we can find our clone and
- # set obj to it before trying to get the node level.
- #
- items = self.findByRole(
- self._lastDescendantChangedSource, obj.getRole())
- for item in items:
- if item.name == obj.name and self.isSameObject(item, obj):
- obj = item
- break
- else:
+ newObj = self.getValidObj(self.lastDescendantChangedSource, obj)
+ if not newObj:
return default.Script.getNodeLevel(self, obj)
count = 0
- while obj:
- state = obj.getState()
+ while newObj:
+ state = newObj.getState()
if state.contains(pyatspi.STATE_EXPANDABLE) \
or state.contains(pyatspi.STATE_COLLAPSED):
if state.contains(pyatspi.STATE_VISIBLE):
count += 1
- obj = obj.parent
+ newObj = newObj.parent
else:
break
@@ -161,11 +170,24 @@ class Script(default.Script):
return True
elif (not obj1) or (not obj2):
return False
-
- if obj1.getIndexInParent() != obj2.getIndexInParent() \
- or obj1.childCount != obj2.childCount:
+ elif (obj1.name != obj2.name) or (obj1.childCount != obj2.childCount):
return False
+ # This is to handle labels in trees. In some cases the default
+ # script's method gives us false positives; other times false
+ # negatives.
+ #
+ if obj1.getRole() == obj2.getRole() == pyatspi.ROLE_LABEL:
+ try:
+ ext1 = obj1.queryComponent().getExtents(0)
+ ext2 = obj2.queryComponent().getExtents(0)
+ except:
+ pass
+ else:
+ if ext1.x == ext2.x and ext1.y == ext2.y \
+ and ext1.width == ext2.width and ext1.height == ext2.height:
+ return True
+
return default.Script.isSameObject(self, obj1, obj2)
def onFocus(self, event):
@@ -202,7 +224,7 @@ class Script(default.Script):
- event: the Event
"""
- self._lastDescendantChangedSource = event.source
+ self.lastDescendantChangedSource = event.source
# In Java comboboxes, when the list of options is popped up via
# an up or down action, control (but not focus) goes to a LIST
@@ -262,7 +284,7 @@ class Script(default.Script):
# equality check is intentional; isSameObject() is especially
# thorough with trees and tables, which is not performant.
#
- if event.source == self._lastDescendantChangedSource:
+ if event.source == self.lastDescendantChangedSource:
return
# We treat selected children as the locus of focus. When the
diff --git a/test/keystrokes/java/role_tree.py b/test/keystrokes/java/role_tree.py
index 5dbc177..32460cc 100644
--- a/test/keystrokes/java/role_tree.py
+++ b/test/keystrokes/java/role_tree.py
@@ -93,8 +93,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"3. Down Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Jazz collapsed'",
- " VISIBLE: 'Jazz collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Jazz collapsed TREE LEVEL 2'",
+ " VISIBLE: 'Jazz collapsed TREE LEVEL 2', cursor=1",
"SPEECH OUTPUT: 'Jazz collapsed'"]))
##########################################################################
@@ -106,8 +106,8 @@ sequence.append(WaitAction("object:state-changed:expanded", None, None,
pyatspi.ROLE_LABEL, 5000))
sequence.append(utils.AssertPresentationAction(
"4. Right Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Jazz expanded'",
- " VISIBLE: 'Jazz expanded', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Jazz expanded TREE LEVEL 2'",
+ " VISIBLE: 'Jazz expanded TREE LEVEL 2', cursor=1",
"SPEECH OUTPUT: 'expanded 4 items'"]))
##########################################################################
@@ -132,8 +132,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"6. Down Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Chet Baker collapsed'",
- " VISIBLE: 'Chet Baker collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Chet Baker collapsed TREE LEVEL 3'",
+ " VISIBLE: 'Chet Baker collapsed TREE LEVEL ', cursor=1",
"SPEECH OUTPUT: 'Chet Baker collapsed'"]))
##########################################################################
@@ -145,8 +145,8 @@ sequence.append(WaitAction("object:state-changed:expanded", None, None,
pyatspi.ROLE_LABEL, 5000))
sequence.append(utils.AssertPresentationAction(
"7. Right Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Chet Baker expanded'",
- " VISIBLE: 'Chet Baker expanded', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Chet Baker expanded TREE LEVEL 3'",
+ " VISIBLE: 'Chet Baker expanded TREE LEVEL 3', cursor=1",
"SPEECH OUTPUT: 'expanded 4 items'"]))
##########################################################################
@@ -171,8 +171,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"9. Down Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application My Funny Valentine collapsed'",
- " VISIBLE: 'My Funny Valentine collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application My Funny Valentine collapsed TREE LEVEL 4'",
+ " VISIBLE: 'My Funny Valentine collapsed TRE', cursor=1",
"SPEECH OUTPUT: 'My Funny Valentine collapsed'"]))
##########################################################################
@@ -184,8 +184,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"10. Down Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Grey December collapsed'",
- " VISIBLE: 'Grey December collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Grey December collapsed TREE LEVEL 4'",
+ " VISIBLE: 'Grey December collapsed TREE LEV', cursor=1",
"SPEECH OUTPUT: 'Grey December collapsed'"]))
########################################################################
@@ -196,10 +196,9 @@ sequence.append(KeyComboAction("KP_Enter"))
sequence.append(PauseAction(3000))
sequence.append(utils.AssertPresentationAction(
"11. Basic Where Am I",
- ["BUG? - Little detail - see bug 483222.",
- "BRAILLE LINE: 'SwingSet2 Application Grey December collapsed'",
- " VISIBLE: 'Grey December collapsed', cursor=1",
- "SPEECH OUTPUT: 'Grey December collapsed'"]))
+ ["BRAILLE LINE: 'SwingSet2 Application Grey December collapsed TREE LEVEL 4'",
+ " VISIBLE: 'Grey December collapsed TREE LEV', cursor=1",
+ "SPEECH OUTPUT: 'Grey December collapsed tree level 4'"]))
##########################################################################
# Expected output when node is expanded:
@@ -210,8 +209,8 @@ sequence.append(WaitAction("object:state-changed:expanded", None, None,
pyatspi.ROLE_LABEL, 5000))
sequence.append(utils.AssertPresentationAction(
"12. Right Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Grey December expanded'",
- " VISIBLE: 'Grey December expanded', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Grey December expanded TREE LEVEL 4'",
+ " VISIBLE: 'Grey December expanded TREE LEVE', cursor=1",
"SPEECH OUTPUT: 'expanded 9 items'"]))
########################################################################
@@ -222,10 +221,9 @@ sequence.append(KeyComboAction("KP_Enter"))
sequence.append(PauseAction(3000))
sequence.append(utils.AssertPresentationAction(
"13. Basic Where Am I",
- ["BUG? - Little detail - see bug 483222.",
- "BRAILLE LINE: 'SwingSet2 Application Grey December expanded'",
- " VISIBLE: 'Grey December expanded', cursor=1",
- "SPEECH OUTPUT: 'Grey December expanded 9 items'"]))
+ ["BRAILLE LINE: 'SwingSet2 Application Grey December expanded TREE LEVEL 4'",
+ " VISIBLE: 'Grey December expanded TREE LEVE', cursor=1",
+ "SPEECH OUTPUT: 'Grey December expanded 9 items tree level 4'"]))
##########################################################################
# Expected output when node is selected:
@@ -249,8 +247,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"15. Down Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application I Wish I Knew'",
- " VISIBLE: 'I Wish I Knew', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application I Wish I Knew TREE LEVEL 5'",
+ " VISIBLE: 'I Wish I Knew TREE LEVEL 5', cursor=1",
"SPEECH OUTPUT: 'I Wish I Knew'"]))
##########################################################################
@@ -262,8 +260,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"16. Down Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Someone To Watch Over Me'",
- " VISIBLE: 'Someone To Watch Over Me', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Someone To Watch Over Me TREE LEVEL 5'",
+ " VISIBLE: 'Someone To Watch Over Me TREE LE', cursor=1",
"SPEECH OUTPUT: 'Someone To Watch Over Me'"]))
########################################################################
@@ -274,10 +272,9 @@ sequence.append(KeyComboAction("KP_Enter"))
sequence.append(PauseAction(3000))
sequence.append(utils.AssertPresentationAction(
"17. Basic Where Am I",
- ["BUG? - Little detail - see bug 483222.",
- "BRAILLE LINE: 'SwingSet2 Application Someone To Watch Over Me'",
- " VISIBLE: 'Someone To Watch Over Me', cursor=1",
- "SPEECH OUTPUT: 'Someone To Watch Over Me'"]))
+ ["BRAILLE LINE: 'SwingSet2 Application Someone To Watch Over Me TREE LEVEL 5'",
+ " VISIBLE: 'Someone To Watch Over Me TREE LE', cursor=1",
+ "SPEECH OUTPUT: 'Someone To Watch Over Me tree level 5'"]))
##########################################################################
# Expected output when node is selected:
@@ -288,8 +285,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"18. Up Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application I Wish I Knew'",
- " VISIBLE: 'I Wish I Knew', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application I Wish I Knew TREE LEVEL 5'",
+ " VISIBLE: 'I Wish I Knew TREE LEVEL 5', cursor=1",
"SPEECH OUTPUT: 'I Wish I Knew'"]))
##########################################################################
@@ -303,7 +300,7 @@ sequence.append(utils.AssertPresentationAction(
"19. Up Arrow in the tree",
["BRAILLE LINE: 'SwingSet2 Application Grey December TREE LEVEL 5'",
" VISIBLE: 'Grey December TREE LEVEL 5', cursor=1",
- "SPEECH OUTPUT: 'Grey December tree level 5'"]))
+ "SPEECH OUTPUT: 'Grey December'"]))
##########################################################################
# Expected output when node is selected:
@@ -314,9 +311,9 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"20. Up Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Grey December expanded'",
- " VISIBLE: 'Grey December expanded', cursor=1",
- "SPEECH OUTPUT: 'Grey December expanded 9 items'"]))
+ ["BRAILLE LINE: 'SwingSet2 Application Grey December expanded TREE LEVEL 4'",
+ " VISIBLE: 'Grey December expanded TREE LEVE', cursor=1",
+ "SPEECH OUTPUT: 'Grey December expanded 9 items tree level 4'"]))
##########################################################################
# Expected output when node is collaped:
@@ -327,8 +324,8 @@ sequence.append(WaitAction("object:state-changed:expanded", None, None,
pyatspi.ROLE_LABEL, 5000))
sequence.append(utils.AssertPresentationAction(
"21. Left Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Grey December collapsed'",
- " VISIBLE: 'Grey December collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Grey December collapsed TREE LEVEL 4'",
+ " VISIBLE: 'Grey December collapsed TREE LEV', cursor=1",
"SPEECH OUTPUT: 'collapsed'"]))
##########################################################################
@@ -340,8 +337,8 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"22. Up Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application My Funny Valentine collapsed'",
- " VISIBLE: 'My Funny Valentine collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application My Funny Valentine collapsed TREE LEVEL 4'",
+ " VISIBLE: 'My Funny Valentine collapsed TRE', cursor=1",
"SPEECH OUTPUT: 'My Funny Valentine collapsed'"]))
##########################################################################
@@ -355,7 +352,7 @@ sequence.append(utils.AssertPresentationAction(
"23. Up Arrow in the tree",
["BRAILLE LINE: 'SwingSet2 Application Sings and Plays collapsed TREE LEVEL 4'",
" VISIBLE: 'Sings and Plays collapsed TREE L', cursor=1",
- "SPEECH OUTPUT: 'Sings and Plays collapsed tree level 4'"]))
+ "SPEECH OUTPUT: 'Sings and Plays collapsed'"]))
##########################################################################
# Expected output when node is selected:
@@ -366,9 +363,9 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"24. Up Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Chet Baker expanded'",
- " VISIBLE: 'Chet Baker expanded', cursor=1",
- "SPEECH OUTPUT: 'Chet Baker expanded 4 items'"]))
+ ["BRAILLE LINE: 'SwingSet2 Application Chet Baker expanded TREE LEVEL 3'",
+ " VISIBLE: 'Chet Baker expanded TREE LEVEL 3', cursor=1",
+ "SPEECH OUTPUT: 'Chet Baker expanded 4 items tree level 3'"]))
##########################################################################
# Expected output when node is collaped:
@@ -379,8 +376,8 @@ sequence.append(WaitAction("object:state-changed:expanded", None, None,
pyatspi.ROLE_LABEL, 5000))
sequence.append(utils.AssertPresentationAction(
"25. Left Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Chet Baker collapsed'",
- " VISIBLE: 'Chet Baker collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Chet Baker collapsed TREE LEVEL 3'",
+ " VISIBLE: 'Chet Baker collapsed TREE LEVEL ', cursor=1",
"SPEECH OUTPUT: 'collapsed'"]))
##########################################################################
@@ -394,7 +391,7 @@ sequence.append(utils.AssertPresentationAction(
"26. Up Arrow in the tree",
["BRAILLE LINE: 'SwingSet2 Application Albert Ayler collapsed TREE LEVEL 3'",
" VISIBLE: 'Albert Ayler collapsed TREE LEVE', cursor=1",
- "SPEECH OUTPUT: 'Albert Ayler collapsed tree level 3'"]))
+ "SPEECH OUTPUT: 'Albert Ayler collapsed'"]))
##########################################################################
# Expected output when node is selected:
@@ -405,9 +402,9 @@ sequence.append(WaitAction("object:active-descendant-changed", None, None,
pyatspi.ROLE_TREE, 5000))
sequence.append(utils.AssertPresentationAction(
"27. Up Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Jazz expanded'",
- " VISIBLE: 'Jazz expanded', cursor=1",
- "SPEECH OUTPUT: 'Jazz expanded 4 items'"]))
+ ["BRAILLE LINE: 'SwingSet2 Application Jazz expanded TREE LEVEL 2'",
+ " VISIBLE: 'Jazz expanded TREE LEVEL 2', cursor=1",
+ "SPEECH OUTPUT: 'Jazz expanded 4 items tree level 2'"]))
##########################################################################
# Expected output when node is collaped:
@@ -418,8 +415,8 @@ sequence.append(WaitAction("object:state-changed:expanded", None, None,
pyatspi.ROLE_LABEL, 5000))
sequence.append(utils.AssertPresentationAction(
"28. Left Arrow in the tree",
- ["BRAILLE LINE: 'SwingSet2 Application Jazz collapsed'",
- " VISIBLE: 'Jazz collapsed', cursor=1",
+ ["BRAILLE LINE: 'SwingSet2 Application Jazz collapsed TREE LEVEL 2'",
+ " VISIBLE: 'Jazz collapsed TREE LEVEL 2', cursor=1",
"SPEECH OUTPUT: 'collapsed'"]))
##########################################################################
@@ -433,7 +430,7 @@ sequence.append(utils.AssertPresentationAction(
"29. Up Arrow in the tree",
["BRAILLE LINE: 'SwingSet2 Application Classical collapsed TREE LEVEL 2'",
" VISIBLE: 'Classical collapsed TREE LEVEL 2', cursor=1",
- "SPEECH OUTPUT: 'Classical collapsed tree level 2'"]))
+ "SPEECH OUTPUT: 'Classical collapsed"]))
##########################################################################
# Expected output when node is selected:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]