2008-08-15 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / pyatspi / test.py
1 #Copyright (C) 2008 Codethink Ltd
2
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
6
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14
15 from cache import AccessibleCache
16 from factory import create_accessible
17
18 import constants
19
20 #------------------------------------------------------------------------------
21
22 class TestApplicationCache(object):
23         """
24         Test application cache. Accesses single AccessibleCache.
25         """
26
27         def __init__(self, connection, bus_name):
28                 self._connection = connection
29                 self._bus_name = bus_name
30                 self._accessible_cache = AccessibleCache(connection, bus_name)
31
32         def __getitem__(self, key):
33                 return self._accessible_cache
34
35         def __contains__(self, key):
36                 if key == self._bus_name:
37                         return True
38                 else:
39                         return False
40
41         def get_root(self):
42                 return create_accessible(self,
43                                          self._bus_name, 
44                                          self._accessible_cache.root, 
45                                          None,
46                                          constants.ATSPI_ACCESSIBLE,
47                                          connection=self._connection)
48
49         root = property(fget=get_root)