5 from xml.dom import minidom
8 from pasytest import PasyTest as _PasyTest
11 from pyatspi import Accessible
12 from pyatspi import BoundingBox
14 ATSPI_LAYER_WIDGET = 3
16 ATSPI_LAYER_WINDOW = 7
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]
24 class ComponentTest(_PasyTest):
28 "test_getAccessibleAtPoint",
35 "test_registerFocusHandler",
36 "test_deregisterFocusHandler",
41 def __init__(self, bus, path):
42 _PasyTest.__init__(self, "Component", False)
46 def setup(self, test):
47 self._registry = pyatspi.Registry()
48 self._desktop = self._registry.getDesktop(0)
50 def test_contains(self, test):
53 def test_getAccessibleAtPoint(self, test):
56 def test_getExtents(self, test):
57 root = self._desktop.getChildAtIndex(0)
58 one = root.getChildAtIndex(0)
59 two = root.getChildAtIndex(1)
61 comps = [one.queryComponent(),
63 root.queryComponent(),]
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]))
72 def test_getPosition(self, test):
74 root = self._desktop.getChildAtIndex(0)
75 one = root.getChildAtIndex(0)
76 two = root.getChildAtIndex(1)
78 comps = [one.queryComponent(),
80 root.queryComponent(),]
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]))
88 def test_getSize(self, test):
89 root = self._desktop.getChildAtIndex(0)
90 one = root.getChildAtIndex(0)
91 two = root.getChildAtIndex(1)
93 comps = [one.queryComponent(),
95 root.queryComponent(),]
97 for expected, comp in zip(sizes_expected, comps):
99 test.assertEqual(size, expected,
100 "Size not correct. Expected (%d, %d) Recieved (%d, %d)"
101 % (expected[0], expected[1], size[0], size[1]))
103 def test_getLayer(self, test):
104 root = self._desktop.getChildAtIndex(0)
105 one = root.getChildAtIndex(0)
106 two = root.getChildAtIndex(1)
108 comps = [one.queryComponent(),
109 two.queryComponent(),
110 root.queryComponent(),]
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 % (int(layer), int(expected)))
118 def test_getMDIZOrder(self, test):
119 root = self._desktop.getChildAtIndex(0)
120 one = root.getChildAtIndex(0)
121 two = root.getChildAtIndex(1)
123 comps = [two.queryComponent(),
124 root.queryComponent(),]
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"
132 def test_grabFocus(self, test):
135 def test_registerFocusHandler(self, test):
138 def test_deregisterFocusHandler(self, test):
141 def test_getAlpha(self, test):
144 def teardown(self, test):