41c8a7f5154279d657f1959c6435be57d19691ae
[platform/core/uifw/at-spi2-atk.git] / tests / pyatspi / componenttest.py
1 import dbus
2 import gobject
3 import os.path
4
5 from xml.dom import minidom
6 import os
7
8 from pasytest import PasyTest as _PasyTest
9
10 import pyatspi
11 from pyatspi import Accessible
12 from pyatspi import BoundingBox
13
14 ATSPI_LAYER_WIDGET = 3
15 ATSPI_LAYER_MDI = 4
16 ATSPI_LAYER_WINDOW = 7
17
18 extents_expected = [(0,0,30,20), (40,30,30,40), (0,0,70,70)]
19 sizes_expected = [(30,20), (30,40), (70,70)]
20 positions_expected = [(0,0), (40,30), (0,0)]
21 layers_expected = [ATSPI_LAYER_WINDOW, ATSPI_LAYER_WIDGET, ATSPI_LAYER_MDI]
22 zorders_expected = [-100, 100]
23
24 class ComponentTest(_PasyTest):
25
26         __tests__ = ["setup",
27                      "test_contains",
28                      "test_getAccessibleAtPoint",
29                      "test_getExtents",
30                      "test_getPosition",
31                      "test_getSize",
32                      "test_getLayer",
33                      "test_getMDIZOrder",
34                      "test_grabFocus",
35                      "test_registerFocusHandler",
36                      "test_deregisterFocusHandler",
37                      "test_getAlpha",
38                      "teardown",
39                      ]
40
41         def __init__(self, bus, path):
42                 _PasyTest.__init__(self, "Accessible", False)
43                 self._bus = bus
44                 self._path = path
45
46         def setup(self, test):
47                 self._registry = pyatspi.registry.Registry(self._path)
48                 self._desktop = self._registry.getDesktop(0)
49
50         def test_contains(self, test):
51                 pass
52
53         def test_getAccessibleAtPoint(self, test):
54                 pass
55
56         def test_getExtents(self, test):
57                 root = self._desktop.getChildAtIndex(0)
58                 one = root.getChildAtIndex(0)
59                 two = root.getChildAtIndex(1)
60
61                 comps = [one.queryComponent(),
62                          two.queryComponent(),
63                          root.queryComponent(),]
64  
65                 for expected, comp in zip(extents_expected, comps):
66                         extents = comp.getExtents(0)
67                         test.assertEqual(extents, BoundingBox(*expected), 
68                                          "Extents not correct. Expected (%d, %d, %d, %d), Recieved (%d, %d, %d, %d)"
69                                          % (expected[0], expected[1], expected[2], expected[3], 
70                                                 extents[0], extents[1], extents[2], extents[3]))
71
72         def test_getPosition(self, test):
73                 pass
74                 root = self._desktop.getChildAtIndex(0)
75                 one = root.getChildAtIndex(0)
76                 two = root.getChildAtIndex(1)
77
78                 comps = [one.queryComponent(),
79                          two.queryComponent(),
80                          root.queryComponent(),]
81  
82                 for expected, comp in zip(positions_expected, comps):
83                         position = comp.getPosition(0)
84                         test.assertEqual(position, expected, 
85                                          "Position not correct. Expected (%d, %d) Recieved (%d, %d)"
86                                          % (expected[0], expected[1], position[0], position[1]))
87
88         def test_getSize(self, test):
89                 root = self._desktop.getChildAtIndex(0)
90                 one = root.getChildAtIndex(0)
91                 two = root.getChildAtIndex(1)
92
93                 comps = [one.queryComponent(),
94                          two.queryComponent(),
95                          root.queryComponent(),]
96  
97                 for expected, comp in zip(sizes_expected, comps):
98                         size = comp.getSize()
99                         test.assertEqual(size, expected, 
100                                          "Size not correct. Expected (%d, %d) Recieved (%d, %d)"
101                                          % (expected[0], expected[1], size[0], size[1]))
102
103         def test_getLayer(self, test):
104                 root = self._desktop.getChildAtIndex(0)
105                 one = root.getChildAtIndex(0)
106                 two = root.getChildAtIndex(1)
107
108                 comps = [one.queryComponent(),
109                          two.queryComponent(),
110                          root.queryComponent(),]
111  
112                 for expected, comp in zip(layers_expected, comps):
113                         layer = comp.getLayer()
114                         test.assertEqual(layer, expected, 
115                                          "Layer not correct. Expected %d, Recieved %d"
116                                          % (layer, expected))
117
118         def test_getMDIZOrder(self, test):
119                 root = self._desktop.getChildAtIndex(0)
120                 one = root.getChildAtIndex(0)
121                 two = root.getChildAtIndex(1)
122
123                 comps = [two.queryComponent(),
124                          root.queryComponent(),]
125  
126                 for expected, comp in zip(zorders_expected, comps):
127                         mdizo = comp.getMDIZOrder()
128                         test.assertEqual(mdizo, expected, 
129                                          "ZOrder not correct. Expected %d, Recieved %d"
130                                          % (expected, mdizo))
131
132         def test_grabFocus(self, test):
133                 pass
134
135         def test_registerFocusHandler(self, test):
136                 pass
137
138         def test_deregisterFocusHandler(self, test):
139                 pass
140
141         def test_getAlpha(self, test):
142                 pass
143
144         def teardown(self, test):
145                 pass