def test_match_any(self, test): collection = self._root.queryCollection() stateSet = pyatspi.StateSet() rule = collection.createMatchRule( stateSet.raw(), collection.MATCH_ANY, [], # attributes collection.MATCH_ANY, [], # role collection.MATCH_ANY, "", # interfaces collection.MATCH_NONE, False) ret = collection.getMatches(rule, collection.SORT_ORDER_CANONICAL, 5, True) self.assertObjects(test, ret, ( "gnome-settings-daemon", 79, "gnome-panel", 79, "Bottom Expanded Edge Panel", 25, "Top Expanded Edge Panel", 25, "nautilus", 79, ), " 1 ")
def test_role(self, test): collection = self._root.queryCollection() stateSet = pyatspi.StateSet() rule = collection.createMatchRule( stateSet.raw(), collection.MATCH_NONE, [], # attributes collection.MATCH_NONE, [pyatspi.ROLE_RADIO_MENU_ITEM], collection.MATCH_ANY, "", # interfaces collection.MATCH_NONE, False) ret = collection.getMatches(rule, collection.SORT_ORDER_CANONICAL, 5, True) self.assertObjects(test, ret, ( "Activity Indicator", 45, "Back", 45, "Forward", 45, "", 45, "Reload", 45, ), " role ") rule = collection.createMatchRule( stateSet.raw(), collection.MATCH_NONE, [], # attributes collection.MATCH_NONE, [pyatspi.ROLE_ENTRY, pyatspi.ROLE_HTML_CONTAINER], collection.MATCH_ANY, "", # interfaces collection.MATCH_NONE, False) ret = collection.getMatches(rule, collection.SORT_ORDER_CANONICAL, 5, True) self.assertObjects(test, ret, ( "gnome-settings-daemon", 79, "gnome-panel", 79, "Bottom Expanded Edge Panel", 25, "Top Expanded Edge Panel", 25, "nautilus", 79, ), " role #2")
def test_setStateSet(self): """ Node.stateSet should be read-only """ # FIXME should be AttributeError? self.assertRaises(RuntimeError, self.app.__setattr__, "states", pyatspi.StateSet())
def test_getState(self, test): state = self._desktop.getState() res = pyatspi.StateSet() if not state.equals(res): test.fail("Desktop state set is not empty")
def test_basic(self, test): collection = self._root.queryCollection() stateSet = pyatspi.StateSet() rule = collection.createMatchRule( stateSet.raw(), collection.MATCH_NONE, [], # attributes collection.MATCH_NONE, [], # role collection.MATCH_NONE, "", # interfaces collection.MATCH_NONE, False) ret = collection.getMatches(rule, collection.SORT_ORDER_CANONICAL, 5, True) self.assertObjects(test, ret, ( "gnome-settings-daemon", 79, "gnome-panel", 79, "Bottom Expanded Edge Panel", 25, "Top Expanded Edge Panel", 25, "nautilus", 79, ), " 1 ") ret = collection.getMatches(rule, collection.SORT_ORDER_REVERSE_CANONICAL, 5, True) self.assertObjects(test, ret, ( "nautilus", 79, "Top Expanded Edge Panel", 25, "Bottom Expanded Edge Panel", 25, "gnome-panel", 79, "gnome-settings-daemon", 79, ), " reverse canonical ") obj = ret[2] ret = collection.getMatchesTo(obj, rule, collection.SORT_ORDER_REVERSE_CANONICAL, collection.TREE_INORDER, True, 5, True) print "--ret:", len(ret) self.assertObjects(test, ret, ( "gnome-settings-daemon", 79, "gnome-panel", 79, ), " getMatchesTo ") ret = collection.getMatchesTo(obj, rule, collection.SORT_ORDER_REVERSE_CANONICAL, collection.TREE_INORDER, True, 1, True) self.assertObjects(test, ret, ( "gnome-panel", 79, ), " getMatchesTo w/count=1") ret = collection.getMatchesFrom( obj, rule, collection.SORT_ORDER_REVERSE_CANONICAL, collection.TREE_INORDER, 5, True) self.assertObjects(test, ret, ( "tracker-applet", 79, "metacity", 79, "Desktop", 25, "nautilus", 79, "Top Expanded Edge Panel", 25, ), " getMatchesFrom ") obj = self._root.getChildAtIndex(1) ret = collection.getMatchesFrom(obj, rule, collection.SORT_ORDER_CANONICAL, collection.TREE_RESTRICT_CHILDREN, 5, True) self.assertObjects(test, ret, ( "Top Expanded Edge Panel", 25, ), " Restrict Children ")