2009-27-09 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / tests / pyatspi / actiontest.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
12 class ActionTest(_PasyTest):
13
14         __tests__ = ["setup",
15                      "test_nActions",
16                      "test_getDescription",
17                      "test_getName",
18                      "test_doAction",
19                      "test_getKeyBinding",
20                      "teardown",
21                      ]
22
23         def __init__(self, bus, path):
24                 _PasyTest.__init__(self, "Action", False)
25                 self._bus = bus
26                 self._path = path
27
28         def setup(self, test):
29                 self._registry = pyatspi.Registry()
30                 self._desktop = self._registry.getDesktop(0)
31
32         def test_nActions(self, test):
33                 root = self._desktop[0]
34                 root = root.queryAction()
35                 nact = root.nActions
36                 test.assertEqual(nact, 10, "nActions expected %d, recieved %d" % (10, nact))
37
38         def test_getName(self, test):
39                 root = self._desktop[0]
40                 root = root.queryAction()
41                 name = root.getName(0)
42                 test.assertEqual(name, "First action", "Name expected %s, recieved %s" % ("First action", name))
43                 name = root.getName(1)
44                 test.assertEqual(name, "Action", "Name expected %s, recieved %s" % ("Action", name))
45
46         def test_getDescription(self, test):
47                 root = self._desktop[0]
48                 root = root.queryAction()
49                 description = root.getDescription(0)
50                 expected = "First action performed"
51                 test.assertEqual(description, expected, "Description expected %s, recieved %s" % (expected, description))
52                 description = root.getDescription(1)
53                 expected = "Description of action"
54                 test.assertEqual(description, expected, "Description expected %s, recieved %s" % (expected, description))
55
56         def test_doAction(self, test):
57                 root = self._desktop[0]
58                 root = root.queryAction()
59                 #TODO have event emitted to check action has been performed
60                 for i in range(0, root.nActions):
61                         root.doAction(i)
62
63         def test_getKeyBinding(self, test):
64                 root = self._desktop[0]
65                 root = root.queryAction()
66                 for i in range(0, root.nActions):
67                         keybinding = root.getKeyBinding(i)
68                         expected = "%s" % (i,)
69                         test.assertEqual(keybinding, expected,
70                                          "Keybinding expected %s, recieved %s" % (expected, keybinding))
71
72         def teardown(self, test):
73                 pass