a33cba8b41b87add4efdb63b0ef2fe1ae8616ffb
[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 interfaces
19
20 __all__ = [
21            "TestApplicationCache",
22           ]
23
24 #------------------------------------------------------------------------------
25
26 class TestApplicationCache(object):
27         """
28         Test application cache. Accesses single AccessibleCache.
29         """
30
31         def __init__(self, registry, connection, bus_name):
32                 self._connection = connection
33                 self._bus_name = bus_name
34                 self._accessible_cache = AccessibleCache(registry, connection, bus_name)
35
36         def __getitem__(self, key):
37                 return self._accessible_cache
38
39         def __contains__(self, key):
40                 if key == self._bus_name:
41                         return True
42                 else:
43                         return False
44
45         def get_application_at_index(self, index, parent):
46                 return create_accessible(self,
47                                          self._bus_name, 
48                                          self._accessible_cache.root, 
49                                          interfaces.ATSPI_ACCESSIBLE,
50                                          connection=self._connection,
51                                          parent=parent)
52
53         def get_application_count(self):
54                 return 1
55
56 #END----------------------------------------------------------------------------