[pyatspi2] Modify pyatspi to use the accessible object located on the registryd.



commit 696390ddf865a71903ef9bb35f16823a7e8a01c2
Author: Mark Doffman <mark doffman codethink co uk>
Date:   Thu Jan 21 06:11:12 2010 -0800

    Modify pyatspi to use the accessible object located on the registryd.

 pyatspi/Accessibility.py        |    1 -
 pyatspi/Makefile.am             |    1 -
 pyatspi/appevent.py             |   75 +------
 pyatspi/cache.py                |   84 +++-----
 pyatspi/desktop.py              |  465 ---------------------------------------
 pyatspi/factory.py              |   40 +---
 pyatspi/interfaces.py           |    3 +-
 pyatspi/registry.py             |   39 ++--
 tests/pyatspi/accessibletest.py |   36 ++--
 tests/pyatspi/actiontest.py     |   10 +-
 tests/pyatspi/componenttest.py  |   11 +-
 tests/pyatspi/relationtest.py   |    2 +-
 12 files changed, 89 insertions(+), 678 deletions(-)
---
diff --git a/pyatspi/Accessibility.py b/pyatspi/Accessibility.py
index 88d2785..ae049d3 100644
--- a/pyatspi/Accessibility.py
+++ b/pyatspi/Accessibility.py
@@ -26,7 +26,6 @@ from action import *
 from application import *
 from collection import *
 from component import *
-from desktop import *
 from document import *
 from editabletext import *
 from hyperlink import *
diff --git a/pyatspi/Makefile.am b/pyatspi/Makefile.am
index e613893..f7fe275 100644
--- a/pyatspi/Makefile.am
+++ b/pyatspi/Makefile.am
@@ -15,7 +15,6 @@ pyatspi_PYTHON = \
 		collection.py		\
 		component.py		\
 		constants.py		\
-		desktop.py		\
 		deviceevent.py		\
 		document.py		\
 		editabletext.py		\
diff --git a/pyatspi/appevent.py b/pyatspi/appevent.py
index cc2dafd..b995758 100644
--- a/pyatspi/appevent.py
+++ b/pyatspi/appevent.py
@@ -314,76 +314,12 @@ class Event(object):
 
 class _ApplicationEventRegister (object):
 
-        def __init__ (self):
+        def __init__ (self, factory):
                 self._bus = AccessibilityBus ()
-		self._factory = AccessibleFactory ()
+		self._factory = factory
 
                 self._event_listeners = {}
 
-                self._children_changed_type = EventType("object:children-changed")
-                self._children_changed_listeners = {}
-
-        def _callClients(self, register, event):
-                for client in register.keys():
-                        client(event)
-
-        def notifyChildrenChange(self, name, path, childref, added):
-                if added:
-                        detail = "add"
-                else:
-                        detail = "remove"
-                event = Event((detail, 0, 0, childref),
-                              self._factory,
-                              path,
-                              name,
-                              "org.freedesktop.atspi.Event.Object",
-                              "children-changed")
-
-                self._callClients(self._children_changed_listeners, event)
-
-        def _registerFake(self, type, register, client, *names):
-                """
-                Registers a client from a register of clients
-                for 'Fake' events emitted by the cache.
-                """
-                try:
-                        registered = register[client]
-                except KeyError:
-                        registered = []
-                        register[client] = registered
-
-                for name in names:
-                        new_type = EventType(name)
-                        if new_type.is_subtype(type):
-                                registered.append(new_type.name)
-
-                if registered == []:
-                        del(register[client])
-
-        def _deregisterFake(self, type, register, client, *names):
-                """
-                Deregisters a client from a register of clients
-                for 'Fake' events emitted by the cache.
-                """
-                try:
-                        registered = register[client]
-                except KeyError:
-                        return True
-
-                for name in names:
-                        remove_type = EventType(name)
-
-                        copy = registered[:]
-                        for i in range(0, len(copy)):
-                                type_name = copy[i]
-                                registered_type = EventType(type_name)
-
-                                if remove_type.is_subtype(registered_type):
-                                        del(registered[i])
-
-                if registered == []:
-                        del(register[client])
-
         def registerEventListener (self, client, *names):
                 try:
                         registered = self._event_listeners[client]
@@ -396,8 +332,6 @@ class _ApplicationEventRegister (object):
                         registered.append((new_type.name,
                                            event_type_to_signal_reciever(self._bus, self._factory, client, new_type)))
 
-                self._registerFake(self._children_changed_type, self._children_changed_listeners, client, *names)
-
         def deregisterEventListener(self, client, *names):
                 try:
                         registered = self._event_listeners[client]
@@ -424,17 +358,12 @@ class _ApplicationEventRegister (object):
                 if registered == []:
                         del(self._event_listeners[client])
 
-                self._deregisterFake(self._children_changed_type, self._children_changed_listeners, client, *names)
-
                 return missing
 
 #------------------------------------------------------------------------------
 
 class _NullApplicationEventRegister (object):
 
-        def notifyChildrenChange(self, name, path, added):
-		pass
-
         def registerEventListener(self, client, *names):
                 pass
 
diff --git a/pyatspi/cache.py b/pyatspi/cache.py
index 502d241..c8b09ab 100644
--- a/pyatspi/cache.py
+++ b/pyatspi/cache.py
@@ -35,43 +35,34 @@ class ApplicationCache(object):
 
         @connection: D-Bus connection used to access applications.
         """
+ 
+        ATSPI_EVENT_OBJECT_INTERFACE = "org.freedesktop.atspi.Event.Object"
 
-        _APPLICATIONS_ADD = 1
-        _APPLICATIONS_REMOVE = 0
-
-        def __init__(self, event_dispatcher=None):
+        def __init__(self):
                 self._connection = AccessibilityBus ()
-                self._factory = None
-
-		self._event_dispatcher = event_dispatcher
 
                 self._application_list = []
                 self._application_cache = {}
 
-                self._bus_object = self._connection.get_object("org.freedesktop.DBus",
-                                                               "/org/freedesktop/DBus")
-
+                obj = self._connection.get_object(ATSPI_REGISTRY_NAME, ATSPI_ROOT_PATH)
+                self._desktop = dbus.Interface(obj, ATSPI_ACCESSIBLE)
+                apps = self._desktop.GetChildren()
 
-                self._regsig = self._connection.add_signal_receiver(self._update_handler,
-                                                                    dbus_interface=ATSPI_REGISTRY_INTERFACE,
-                                                                    signal_name="UpdateApplications")
-
-                obj = self._connection.get_object(ATSPI_REGISTRY_NAME,
-                                                  ATSPI_REGISTRY_PATH)
-                self._app_register = dbus.Interface(obj, ATSPI_REGISTRY_INTERFACE)
+                self._connection.add_signal_receiver(self._children_changed_handler,
+						     bus_name=ATSPI_REGISTRY_NAME,
+						     path=ATSPI_ROOT_PATH,
+                                                     dbus_interface=self.ATSPI_EVENT_OBJECT_INTERFACE,
+                                                     signal_name="children_changed",
+						     member_keyword="member",
+						     sender_keyword="sender",
+						     path_keyword="path")
 
-                apps = self._app_register.GetApplications()
 
-                #this_pid = os.getpid()
-                #for app in apps:
-                #        that_pid = self._bus_object.GetConnectionUnixProcessID(app)
-                #        if not this_pid == that_pid:
-                #                self._application_list.append(app)
 
 		self._application_list.extend(apps)
                         
-                for bus_name in self._application_list:
-                                self._application_cache[bus_name] = AccessibleCache(bus_name)
+                for bus_name, object_path in self._application_list:
+                                self._application_cache[bus_name] = AccessibleCache(bus_name, object_path)
 
         def __call__ (self, app_name, acc_path): 
                 """
@@ -94,21 +85,14 @@ class ApplicationCache(object):
                 except Exception:
                         return False
 
-        def _update_handler (self, update_type, bus_name):
-                if update_type == ApplicationCache._APPLICATIONS_ADD:
+	def _children_changed_handler (self, app, minor, detail1, detail2, any_data,
+				             sender=None, member=None, path=None):
+		if minor == "add":
+			bus_name, object_path = any_data
                         self._application_list.append(bus_name)
                         self._application_cache[bus_name] = AccessibleCache(bus_name)
-			if self._event_dispatcher:
-                        	self._event_dispatcher.notifyChildrenChange(ATSPI_REGISTRY_NAME,
-                                	                                    ATSPI_DESKTOP_PATH,
-									    self._application_cache[bus_name].root, 
-                                        	                            True)
-                elif update_type == ApplicationCache._APPLICATIONS_REMOVE:
-			if self._event_dispatcher:
-                        	self._event_dispatcher.notifyChildrenChange(ATSPI_REGISTRY_NAME,
-                                	                                    ATSPI_DESKTOP_PATH,
-									    self._application_cache[bus_name].root, 
-                                        	                            False)
+		elif minor == "remove":
+			bus_name, object_path = any_data
                         self._application_list.remove(bus_name)
                         del(self._application_cache[bus_name])
 
@@ -175,9 +159,6 @@ class AccessibleCache(object):
         For each application the accessible cache stores
         data on every accessible object within the app.
 
-        It also acts as the factory for creating client
-        side proxies for these accessible objects.
-
         connection - DBus connection.
         busName    - Name of DBus connection where cache interface resides.
         """
@@ -185,15 +166,13 @@ class AccessibleCache(object):
         _PATH = '/org/at_spi/cache'
         _INTERFACE = 'org.freedesktop.atspi.Cache'
         _GET_METHOD = 'GetItems'
-        _UPDATE_SIGNAL = 'UpdateAccessible'
-        _REMOVE_SIGNAL = 'RemoveAccessible'
 
         _ATSPI_EVENT_OBJECT_INTERFACE = "org.freedesktop.atspi.Event.Object"
 
         _CACHE_PATH = '/org/at_spi/cache'
         _CACHE_INTERFACE = 'org.freedesktop.atspi.Cache'
 
-        def __init__(self, bus_name):
+        def __init__(self, bus_name, object_path):
                 """
                 Creates a cache.
 
@@ -202,17 +181,13 @@ class AccessibleCache(object):
                 """
                 self._connection = AccessibilityBus()
                 self._bus_name = bus_name
-
-                obj = self._connection.get_object(bus_name, self._PATH)
-                self._tree_itf = dbus.Interface(obj, self._INTERFACE)
+		self._object_path = object_path
 
                 self._objects = {}
 
-                get_method = self._tree_itf.get_dbus_method(self._GET_METHOD)
-                self._update_objects(get_method())
-
-                self._updateMatch = self._tree_itf.connect_to_signal(self._UPDATE_SIGNAL, self._update_object)
-                self._removeMatch = self._tree_itf.connect_to_signal(self._REMOVE_SIGNAL, self._remove_object)
+                obj = self._connection.get_object (bus_name, self._CACHE_PATH)
+                cache = dbus.Interface (obj, self._CACHE_INTERFACE)
+                self._update_objects(cache.GetItems())
 
                 self._connection.add_signal_receiver(self._property_change_handler,
                                                      dbus_interface=self._ATSPI_EVENT_OBJECT_INTERFACE,
@@ -227,11 +202,6 @@ class AccessibleCache(object):
 						     sender_keyword="sender",
 						     path_keyword="path")
 
-                obj = self._connection.get_object (bus_name, self._CACHE_PATH)
-                cache = dbus.Interface (obj, self._CACHE_INTERFACE)
-
-                self.root = cache.GetRoot ()
-
         def __getitem__(self, key):
                 try:
                         name, path = key
diff --git a/pyatspi/factory.py b/pyatspi/factory.py
index ea60d1e..2ed9c31 100644
--- a/pyatspi/factory.py
+++ b/pyatspi/factory.py
@@ -40,9 +40,12 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class _AccessibleFactory (object):
+class AccessibleFactory (object):
 
-        def __init__ (self):
+        def __new__ (cls, cache):
+		return object.__new__ (cls)
+
+        def __init__ (self, cache):
 
                 self._connection = AccessibilityBus() 
 
@@ -64,40 +67,15 @@ class _AccessibleFactory (object):
                         interfaces.ATSPI_VALUE:Value,
                 }
 
-                self._cache = None
-                self._desktop = None
-
-	def set_cache (self, cache):
 		self._cache = cache
 
-	def set_desktop (self, desktop):
-		self._desktop = desktop
-
         def __call__ (self, name, path, itf, dbus_object=None):
                 if dbus_object == None:
                         dbus_object = self._connection.get_object (name, path)
+
+		if path == interfaces.ATSPI_NULL_PATH:
+			return None
         
-                # Hack to link applications 'parent' property up to the desktop object.
-                if name == interfaces.ATSPI_REGISTRY_NAME or path == interfaces.ATSPI_DESKTOP_PATH:
-                        return self._desktop
-                else:
-                        return self._interfaces[itf] (self._cache, self, name, path, dbus_object)
-
-class AccessibleFactory (_AccessibleFactory):
-	"""
-	Shared instance of the D-Bus bus used for accessibility.
-	"""
-
-	_shared_instance = None
-	
-	def __new__ (cls):
-		if AccessibleFactory._shared_instance:
-			return AccessibleFactory._shared_instance
-		else:
-			AccessibleFactory._shared_instance = _AccessibleFactory.__new__ (cls)
-			return AccessibleFactory._shared_instance
-
-	def __init__ (self):
-		_AccessibleFactory.__init__ (self)
+                return self._interfaces[itf] (self._cache, self, name, path, dbus_object)
 
 #END----------------------------------------------------------------------------
diff --git a/pyatspi/interfaces.py b/pyatspi/interfaces.py
index 8b642b3..c55be51 100644
--- a/pyatspi/interfaces.py
+++ b/pyatspi/interfaces.py
@@ -35,7 +35,8 @@ ATSPI_REGISTRY_INTERFACE = 'org.freedesktop.atspi.Registry'
 ATSPI_REGISTRY_PATH = '/org/freedesktop/atspi/registry'
 ATSPI_REGISTRY_NAME = 'org.freedesktop.atspi.Registry'
 
-ATSPI_DESKTOP_PATH = '/org/freedesktop/atspi/accessible/desktop'
+ATSPI_ROOT_PATH = '/org/freedesktop/atspi/accessible/root'
+ATSPI_NULL_PATH = '/org/freedesktop/atspi/null'
 
 ATSPI_DEVICE_EVENT_LISTENER_INTERFACE = 'org.freedesktop.atspi.DeviceEventListener'
 ATSPI_DEVICE_EVENT_CONTROLLER_INTERFACE = 'org.freedesktop.atspi.DeviceEventController'
diff --git a/pyatspi/registry.py b/pyatspi/registry.py
index 182ad72..3d6e99f 100644
--- a/pyatspi/registry.py
+++ b/pyatspi/registry.py
@@ -27,14 +27,14 @@ import os as _os
 from factory import AccessibleFactory
 from appevent import _ApplicationEventRegister, _NullApplicationEventRegister
 from deviceevent import _DeviceEventRegister, _NullDeviceEventRegister
-from desktop import *
+from busutils import AccessibilityBus
 from cache import *
 
 from deviceevent import KEY_PRESSED_EVENT as _KEY_PRESSED_EVENT
 from deviceevent import KEY_RELEASED_EVENT as _KEY_RELEASED_EVENT
 
 from interfaces import ATSPI_REGISTRY_NAME as _ATSPI_REGISTRY_NAME
-from interfaces import ATSPI_DESKTOP_PATH as _ATSPI_DESKTOP_PATH
+from interfaces import ATSPI_ROOT_PATH as _ATSPI_ROOT_PATH
 from interfaces import ATSPI_DESKTOP as _ATSPI_DESKTOP
 
 __all__ = ["Registry",
@@ -115,33 +115,30 @@ class Registry(object):
                 @param app_name: D-Bus name of the application to connect to when not using the registry daemon.
                 """
 
-		factory = AccessibleFactory()
-
-                # Set up the device event controllers
-                if app_name:
-                        devreg = _NullDeviceEventRegister()
-                        appreg = _NullApplicationEventRegister()
-                else:
-                        devreg = _DeviceEventRegister()
-                        appreg = _ApplicationEventRegister()
-
-
-                if app_name:
-                        desktop = TestDesktop (app_name, factory)
-                else:
-                        desktop = Desktop (factory)
+                _connection = AccessibilityBus ()
+                _bus_object = _connection.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
 
                 # Set up the cache
 		cache = None
 
                 if main_loop_type == MAIN_LOOP_GLIB:
                         if app_name:
-                                cache = AccessibleCache(app_name)
+                                cache = AccessibleCache(app_name, _ATSPI_ROOT_PATH)
                         else:
-                                cache = ApplicationCache(appreg)
+                                cache = ApplicationCache()
+
+		factory = AccessibleFactory(cache)
 
-                factory.set_cache (cache)
-		factory.set_desktop (desktop)
+                # Set up the device event controllers
+                if app_name:
+                        devreg = _NullDeviceEventRegister()
+                        appreg = _NullApplicationEventRegister()
+			name = _bus_object.GetNameOwner (app_name)
+                        desktop = factory (name, _ATSPI_ROOT_PATH, _ATSPI_DESKTOP)
+                else:
+                        devreg = _DeviceEventRegister()
+                        appreg = _ApplicationEventRegister(factory)
+                        desktop = factory (_ATSPI_REGISTRY_NAME, _ATSPI_ROOT_PATH, _ATSPI_DESKTOP)
 
                 # Create the registry object
                 self.has_implementations = True
diff --git a/tests/pyatspi/accessibletest.py b/tests/pyatspi/accessibletest.py
index 6cd2cdd..bd3f5c5 100644
--- a/tests/pyatspi/accessibletest.py
+++ b/tests/pyatspi/accessibletest.py
@@ -56,15 +56,14 @@ class AccessibleTest(_PasyTest):
 
 	def setup(self, test):
 		self._registry = pyatspi.Registry()
-		print self._path
 		self._desktop = self._registry.getDesktop(0)
 
 	def test_name(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		test.assertEqual(root.name, "main", "Expected name - \"main\". Recieved - \"%s\"" % (root.name,))
 
 	def test_getChildAtIndex(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		a = root.getChildAtIndex(0)
 		test.assertEqual(a.name, "gnome-settings-daemon",
 					 "Expected name - \"gnome-settings-daemon\". Recieved - \"%s\"" % (a.name,))
@@ -76,7 +75,7 @@ class AccessibleTest(_PasyTest):
 					 "Expected name - \"nautilus\". Recieved - \"%s\"" % (c.name,))
 		
 	def test_isEqual(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 
 		a = root.getChildAtIndex(1)
 		if not a.isEqual(a):
@@ -95,8 +94,13 @@ class AccessibleTest(_PasyTest):
 			test.fail("Different accessibles found equal")
 
 	def test_getApplication(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
+		print root._app_name
+		print root._acc_path
 		application = root.getApplication()
+		print application._app_name
+		print application._acc_path
+		print application
 		if not root.isEqual(application):
 			test.fail("Root accessible does not provide itself as its Application")
 
@@ -107,7 +111,7 @@ class AccessibleTest(_PasyTest):
 
 
 	def test_getAttributes(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		attr = root.getAttributes()
 		res = ["foo:bar", "baz:qux", "quux:corge"]
                 attr.sort()
@@ -115,7 +119,7 @@ class AccessibleTest(_PasyTest):
 		test.assertEqual(attr, res, "Attributes expected %s, recieved %s" % (attr, res))
 
 	def test_parent(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 
 		a = root.getChildAtIndex(1)
 		pa = a.parent
@@ -123,14 +127,14 @@ class AccessibleTest(_PasyTest):
 			test.fail("Child does not correctly report its parent")
 
 	def test_getIndexInParent(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 
 		for i in range(0, root.childCount):
 			child = root.getChildAtIndex(i)
 			test.assertEqual(i, child.getIndexInParent(), "Childs index in parent reported incorrectly")
 
 	def test_getLocalizedRoleName(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 
 		ans = "window"
 		res = root.getLocalizedRoleName()
@@ -145,17 +149,17 @@ class AccessibleTest(_PasyTest):
 				 "Expected LocalizedRoleName - \"%s\". Recieved - \"%s\"" % (ans, res,))
 
 	def test_getRelationSet(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		# Complete test of Relation interface is separate
 		rset = root.getRelationSet()
 
 	def test_getRole(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		test.assertEqual(root.getRole(), 69,
 				 "Expected role - \"69\". Recieved - \"%d\"" % (int(root.getRole()),))
 
 	def test_getRoleName(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 
 		ans = "window"
 		res = root.getRoleName()
@@ -170,19 +174,19 @@ class AccessibleTest(_PasyTest):
 				 "Expected roleName - \"%s\". Recieved - \"%s\"" % (ans, res,))
 
 	def test_getState(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		state = root.getState()
 		res = StateSet(*st)
 		if not res.equals(state):
 			test.fail("States not reported correctly")
 
 	def test_childCount(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		test.assertEqual(root.childCount, 11,
 				 "Expected role - \"11\". Recieved - \"%d\"" % (root.childCount,))
 
 	def test_description(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		description = "The main accessible object, root of the accessible tree"
 		test.assertEqual(root.description, description,
 				 "Expected description - \"%s\". Recieved - \"%s\"" % (description, root.description,))
@@ -202,7 +206,7 @@ class AccessibleTest(_PasyTest):
 		It checks a tree of these values is correctly
 		passed from Application to AT.
 		"""
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 
 		doc = minidom.Document()
 		_createNode(root, doc)
diff --git a/tests/pyatspi/actiontest.py b/tests/pyatspi/actiontest.py
index 405f898..d943206 100644
--- a/tests/pyatspi/actiontest.py
+++ b/tests/pyatspi/actiontest.py
@@ -30,13 +30,13 @@ class ActionTest(_PasyTest):
 		self._desktop = self._registry.getDesktop(0)
 
 	def test_nActions(self, test):
-		root = self._desktop[0]
+		root = self._desktop
 		root = root.queryAction()
 		nact = root.nActions
 		test.assertEqual(nact, 10, "nActions expected %d, recieved %d" % (10, nact))
 
 	def test_getName(self, test):
-		root = self._desktop[0]
+		root = self._desktop
 		root = root.queryAction()
 		name = root.getName(0)
 		test.assertEqual(name, "First action", "Name expected %s, recieved %s" % ("First action", name))
@@ -44,7 +44,7 @@ class ActionTest(_PasyTest):
 		test.assertEqual(name, "Action", "Name expected %s, recieved %s" % ("Action", name))
 
 	def test_getDescription(self, test):
-		root = self._desktop[0]
+		root = self._desktop
 		root = root.queryAction()
 		description = root.getDescription(0)
 		expected = "First action performed"
@@ -54,14 +54,14 @@ class ActionTest(_PasyTest):
 		test.assertEqual(description, expected, "Description expected %s, recieved %s" % (expected, description))
 
 	def test_doAction(self, test):
-		root = self._desktop[0]
+		root = self._desktop
 		root = root.queryAction()
 		#TODO have event emitted to check action has been performed
 		for i in range(0, root.nActions):
 			root.doAction(i)
 
 	def test_getKeyBinding(self, test):
-		root = self._desktop[0]
+		root = self._desktop
 		root = root.queryAction()
 		for i in range(0, root.nActions):
 			keybinding = root.getKeyBinding(i)
diff --git a/tests/pyatspi/componenttest.py b/tests/pyatspi/componenttest.py
index fe30c88..1ac4410 100644
--- a/tests/pyatspi/componenttest.py
+++ b/tests/pyatspi/componenttest.py
@@ -54,7 +54,7 @@ class ComponentTest(_PasyTest):
 		pass
 
 	def test_getExtents(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		one = root.getChildAtIndex(0)
 		two = root.getChildAtIndex(1)
 
@@ -70,8 +70,7 @@ class ComponentTest(_PasyTest):
 						extents[0], extents[1], extents[2], extents[3]))
 
 	def test_getPosition(self, test):
-		pass
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		one = root.getChildAtIndex(0)
 		two = root.getChildAtIndex(1)
 
@@ -86,7 +85,7 @@ class ComponentTest(_PasyTest):
 					 % (expected[0], expected[1], position[0], position[1]))
 
 	def test_getSize(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		one = root.getChildAtIndex(0)
 		two = root.getChildAtIndex(1)
 
@@ -101,7 +100,7 @@ class ComponentTest(_PasyTest):
 					 % (expected[0], expected[1], size[0], size[1]))
 
 	def test_getLayer(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		one = root.getChildAtIndex(0)
 		two = root.getChildAtIndex(1)
 
@@ -116,7 +115,7 @@ class ComponentTest(_PasyTest):
 					 % (int(layer), int(expected)))
 
 	def test_getMDIZOrder(self, test):
-		root = self._desktop.getChildAtIndex(0)
+		root = self._desktop
 		one = root.getChildAtIndex(0)
 		two = root.getChildAtIndex(1)
 
diff --git a/tests/pyatspi/relationtest.py b/tests/pyatspi/relationtest.py
index 77ce31c..6171716 100644
--- a/tests/pyatspi/relationtest.py
+++ b/tests/pyatspi/relationtest.py
@@ -27,7 +27,7 @@ class RelationTest(_PasyTest):
 	def setup(self, test):
 		self._registry = pyatspi.Registry()
 		self._desktop = self._registry.getDesktop(0)
-		self._root = self._desktop[0]
+		self._root = self._desktop
 		self._rset = self._root.getRelationSet()
 		test.assertEqual(len(self._rset), 4, "Num relations expected %d, recieved %d" % (6, len(self._rset)))
 



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