2008-07-28 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / tests / pyatspi / accessibletest.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 PasyTestSuite
9
10 def createNode(accessible, parentElement):
11         e = minidom.Element("accessible")
12
13         e.attributes["name"] = accessible.name
14         e.attributes["role"] = str(int(accessible.role))
15         e.attributes["description"] = accessible.description
16
17         for i in range(0, accessible.numChildren):
18                 createNode(accessible.getChild(i), e)
19
20         parentElement.appendChild(e)
21
22 class TreeTestSuite(PasyTestSuite):
23
24         __tests__ = ["accessibleTree"]
25
26         def __init__(self, bus, name):
27                 PasyTestSuite.__init__(self, "Tree")
28                 self._cache = getAccessibleCache(bus, name)
29
30         def accessibleTree(test):
31                 root = self._cache.getRootAccessible()
32
33                 doc = minidom.Document()
34                 createNode(root, doc)
35                 answer = doc.toprettyxml()
36
37                 correct = os.path.join(os.environ["TEST_DATA_DIRECTORY"],
38                                         "object-test-stage1-results.xml")
39                 file = open(correct)
40                 cstring = file.read()
41                 
42                 test.assertEqual(answer, cstring, "Object tree not passed correctly")
43
44                 test.win()