[pyatspi2/gi] Test fixes/refactoring
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pyatspi2/gi] Test fixes/refactoring
- Date: Sun, 28 Nov 2010 15:07:26 +0000 (UTC)
commit ec2494e1628af52896cccb97d63bee34007ca3cc
Author: Mike Gorse <mgorse novell com>
Date: Thu Nov 25 06:14:26 2010 -0500
Test fixes/refactoring
Have test-runner return a non-zero exit code on failure.
Adapt testsuite to run in conjunction with at-spi-registryd; remove the
need to initialize pyatspi with a custom app name.
tests/apps/action-app.c | 2 +
tests/apps/component-app.c | 5 ++++
tests/apps/relation-app.c | 2 +
tests/data/accessible-test-results.xml | 2 +-
tests/data/accessible-test.xml | 2 +-
tests/dummyatk/my-atk-action.c | 2 +-
tests/pyatspi/accessibletest.py | 34 ++++++++++++++++---------------
tests/pyatspi/actiontest.py | 19 +++++++++++++----
tests/pyatspi/collectiontest.py | 10 ++++----
tests/pyatspi/componenttest.py | 11 +++++----
tests/pyatspi/pasytest/Pasy.py | 1 +
tests/pyatspi/relationtest.py | 2 +-
tests/pyatspi/testrunner.in | 8 +-----
13 files changed, 59 insertions(+), 41 deletions(-)
---
diff --git a/tests/apps/action-app.c b/tests/apps/action-app.c
index 612cd59..a6bd742 100644
--- a/tests/apps/action-app.c
+++ b/tests/apps/action-app.c
@@ -8,6 +8,8 @@ G_MODULE_EXPORT void
test_init (gchar *path)
{
root_accessible = g_object_new(MY_TYPE_ATK_ACTION, NULL);
+ root_accessible->name = g_strdup ("atspi-test-main");
+ root_accessible->role = ATK_ROLE_APPLICATION;
}
G_MODULE_EXPORT void
diff --git a/tests/apps/component-app.c b/tests/apps/component-app.c
index d51e1ac..3c96228 100644
--- a/tests/apps/component-app.c
+++ b/tests/apps/component-app.c
@@ -14,6 +14,7 @@ G_MODULE_EXPORT void
test_init (gchar *path)
{
int i;
+ AtkObject *atk;
if (path == NULL)
g_error("No test data path provided");
@@ -34,6 +35,10 @@ test_init (gchar *path)
my_atk_object_add_child(MY_ATK_OBJECT(comps[2]), MY_ATK_OBJECT(comps[0]));
my_atk_object_add_child(MY_ATK_OBJECT(comps[2]), MY_ATK_OBJECT(comps[1]));
+
+ atk = ATK_OBJECT (comps [2]);
+ atk->name = g_strdup ("atspi-test-main");
+ atk->role = ATK_ROLE_APPLICATION;
}
G_MODULE_EXPORT void
diff --git a/tests/apps/relation-app.c b/tests/apps/relation-app.c
index 5734ffe..0ee4517 100644
--- a/tests/apps/relation-app.c
+++ b/tests/apps/relation-app.c
@@ -14,6 +14,8 @@ test_init (gchar *path)
AtkObject *rls[3];
root_accessible = g_object_new(MY_TYPE_ATK_OBJECT, NULL);
+ root_accessible->name = g_strdup ("atspi-test-main");
+ root_accessible->role = ATK_ROLE_APPLICATION;
r1 = ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
"accessible-name", "r1",
diff --git a/tests/data/accessible-test-results.xml b/tests/data/accessible-test-results.xml
index a522187..d2db548 100644
--- a/tests/data/accessible-test-results.xml
+++ b/tests/data/accessible-test-results.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
-<accessible description="The main accessible object, root of the accessible tree" name="main" role="69">
+<accessible description="The main accessible object, root of the accessible tree" name="atspi-test-main" role="69">
<accessible description="" name="gnome-settings-daemon" role="79"/>
<accessible description="" name="gnome-panel" role="79">
<accessible description="" name="Bottom Expanded Edge Panel" role="25"/>
diff --git a/tests/data/accessible-test.xml b/tests/data/accessible-test.xml
index c881873..abab68c 100644
--- a/tests/data/accessible-test.xml
+++ b/tests/data/accessible-test.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
-<accessible description="The main accessible object, root of the accessible tree" name="main" role="68">
+<accessible description="The main accessible object, root of the accessible tree" name="atspi-test-main" role="68">
<accessible description="" name="gnome-settings-daemon" role="77"/>
<accessible description="" name="gnome-panel" role="77">
<accessible description="" name="Bottom Expanded Edge Panel" role="24"/>
diff --git a/tests/dummyatk/my-atk-action.c b/tests/dummyatk/my-atk-action.c
index 363356a..31964c2 100644
--- a/tests/dummyatk/my-atk-action.c
+++ b/tests/dummyatk/my-atk-action.c
@@ -6,7 +6,7 @@
#include "my-atk-action.h"
static GObjectClass *parent_class = NULL;
-//implementaion of the interface
+//implementation of the interface
static gboolean my_atk_action_do_action(AtkAction *action, gint i)
{
MyAtkAction *self = (MyAtkAction*)action;
diff --git a/tests/pyatspi/accessibletest.py b/tests/pyatspi/accessibletest.py
index bd3f5c5..3b5efd1 100644
--- a/tests/pyatspi/accessibletest.py
+++ b/tests/pyatspi/accessibletest.py
@@ -57,13 +57,14 @@ class AccessibleTest(_PasyTest):
def setup(self, test):
self._registry = pyatspi.Registry()
self._desktop = self._registry.getDesktop(0)
+ self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_WINDOW)
def test_name(self, test):
- root = self._desktop
- test.assertEqual(root.name, "main", "Expected name - \"main\". Recieved - \"%s\"" % (root.name,))
+ root = self._root
+ test.assertEqual(root.name, "atspi-test-main", "Expected name - \"main\". Recieved - \"%s\"" % (root.name,))
def test_getChildAtIndex(self, test):
- root = self._desktop
+ root = self._root
a = root.getChildAtIndex(0)
test.assertEqual(a.name, "gnome-settings-daemon",
"Expected name - \"gnome-settings-daemon\". Recieved - \"%s\"" % (a.name,))
@@ -75,7 +76,7 @@ class AccessibleTest(_PasyTest):
"Expected name - \"nautilus\". Recieved - \"%s\"" % (c.name,))
def test_isEqual(self, test):
- root = self._desktop
+ root = self._root
a = root.getChildAtIndex(1)
if not a.isEqual(a):
@@ -94,7 +95,7 @@ class AccessibleTest(_PasyTest):
test.fail("Different accessibles found equal")
def test_getApplication(self, test):
- root = self._desktop
+ root = self._root
print root._app_name
print root._acc_path
application = root.getApplication()
@@ -111,7 +112,7 @@ class AccessibleTest(_PasyTest):
def test_getAttributes(self, test):
- root = self._desktop
+ root = self._root
attr = root.getAttributes()
res = ["foo:bar", "baz:qux", "quux:corge"]
attr.sort()
@@ -119,7 +120,7 @@ class AccessibleTest(_PasyTest):
test.assertEqual(attr, res, "Attributes expected %s, recieved %s" % (attr, res))
def test_parent(self, test):
- root = self._desktop
+ root = self._root
a = root.getChildAtIndex(1)
pa = a.parent
@@ -127,14 +128,14 @@ class AccessibleTest(_PasyTest):
test.fail("Child does not correctly report its parent")
def test_getIndexInParent(self, test):
- root = self._desktop
+ root = self._root
for i in range(0, root.childCount):
child = root.getChildAtIndex(i)
test.assertEqual(i, child.getIndexInParent(), "Childs index in parent reported incorrectly")
def test_getLocalizedRoleName(self, test):
- root = self._desktop
+ root = self._root
ans = "window"
res = root.getLocalizedRoleName()
@@ -149,17 +150,17 @@ class AccessibleTest(_PasyTest):
"Expected LocalizedRoleName - \"%s\". Recieved - \"%s\"" % (ans, res,))
def test_getRelationSet(self, test):
- root = self._desktop
+ root = self._root
# Complete test of Relation interface is separate
rset = root.getRelationSet()
def test_getRole(self, test):
- root = self._desktop
+ root = self._root
test.assertEqual(root.getRole(), 69,
"Expected role - \"69\". Recieved - \"%d\"" % (int(root.getRole()),))
def test_getRoleName(self, test):
- root = self._desktop
+ root = self._root
ans = "window"
res = root.getRoleName()
@@ -174,19 +175,19 @@ class AccessibleTest(_PasyTest):
"Expected roleName - \"%s\". Recieved - \"%s\"" % (ans, res,))
def test_getState(self, test):
- root = self._desktop
+ root = self._root
state = root.getState()
res = StateSet(*st)
if not res.equals(state):
test.fail("States not reported correctly")
def test_childCount(self, test):
- root = self._desktop
+ root = self._root
test.assertEqual(root.childCount, 11,
"Expected role - \"11\". Recieved - \"%d\"" % (root.childCount,))
def test_description(self, test):
- root = self._desktop
+ root = self._root
description = "The main accessible object, root of the accessible tree"
test.assertEqual(root.description, description,
"Expected description - \"%s\". Recieved - \"%s\"" % (description, root.description,))
@@ -206,12 +207,13 @@ class AccessibleTest(_PasyTest):
It checks a tree of these values is correctly
passed from Application to AT.
"""
- root = self._desktop
+ root = self._root
doc = minidom.Document()
_createNode(root, doc)
answer = doc.toprettyxml()
+
correct = os.path.join(os.environ["TEST_DATA_DIRECTORY"],
"accessible-test-results.xml")
file = open(correct)
diff --git a/tests/pyatspi/actiontest.py b/tests/pyatspi/actiontest.py
index d943206..cfdb36d 100644
--- a/tests/pyatspi/actiontest.py
+++ b/tests/pyatspi/actiontest.py
@@ -27,16 +27,25 @@ class ActionTest(_PasyTest):
def setup(self, test):
self._registry = pyatspi.Registry()
+ import time
self._desktop = self._registry.getDesktop(0)
+ print "--desktop len", len(self._desktop)
+ for i in self._desktop:
+ try:
+ print "-- object",i,i.getRole()
+ except:
+ pass
+ self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_APPLICATION)
+ print "--root", self._root
def test_nActions(self, test):
- root = self._desktop
+ root = self._root
root = root.queryAction()
nact = root.nActions
test.assertEqual(nact, 10, "nActions expected %d, recieved %d" % (10, nact))
def test_getName(self, test):
- root = self._desktop
+ root = self._root
root = root.queryAction()
name = root.getName(0)
test.assertEqual(name, "First action", "Name expected %s, recieved %s" % ("First action", name))
@@ -44,7 +53,7 @@ class ActionTest(_PasyTest):
test.assertEqual(name, "Action", "Name expected %s, recieved %s" % ("Action", name))
def test_getDescription(self, test):
- root = self._desktop
+ root = self._root
root = root.queryAction()
description = root.getDescription(0)
expected = "First action performed"
@@ -54,14 +63,14 @@ class ActionTest(_PasyTest):
test.assertEqual(description, expected, "Description expected %s, recieved %s" % (expected, description))
def test_doAction(self, test):
- root = self._desktop
+ root = self._root
root = root.queryAction()
#TODO have event emitted to check action has been performed
for i in range(0, root.nActions):
root.doAction(i)
def test_getKeyBinding(self, test):
- root = self._desktop
+ root = self._root
root = root.queryAction()
for i in range(0, root.nActions):
keybinding = root.getKeyBinding(i)
diff --git a/tests/pyatspi/collectiontest.py b/tests/pyatspi/collectiontest.py
index 1c508c7..abb6254 100644
--- a/tests/pyatspi/collectiontest.py
+++ b/tests/pyatspi/collectiontest.py
@@ -47,7 +47,7 @@ class AccessibleTest(_PasyTest):
self._registry = pyatspi.Registry()
print self._path
self._desktop = self._registry.getDesktop(0)
- self.root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "main" and x.getRole() == pyatspi.ROLE_WINDOW)
+ self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_WINDOW)
def assertObjects(self,test,obj,vars,msg):
test.assertEqual(len(obj), len(vars) / 2, msg + " length")
@@ -63,7 +63,7 @@ class AccessibleTest(_PasyTest):
print "\t\t), \"", msg, "\")"
def test_basic(self, test):
- collection = self.root.queryCollection()
+ collection = self._root.queryCollection()
stateSet = pyatspi.StateSet()
rule = collection.createMatchRule (stateSet.raw(),
collection.MATCH_NONE,
@@ -111,14 +111,14 @@ class AccessibleTest(_PasyTest):
"nautilus", 79,
"Top Expanded Edge Panel", 25,
), " getMatchesFrom ")
- obj = self.root.getChildAtIndex(1)
+ obj = self._root.getChildAtIndex(1)
ret = collection.getMatchesFrom (obj, rule, collection.SORT_ORDER_CANONICAL, collection.TREE_RESTRICT_CHILDREN, 5, True)
self.assertObjects(test,ret,(
"Top Expanded Edge Panel", 25,
), " Restrict Children ")
def test_match_any(self, test):
- collection = self.root.queryCollection()
+ collection = self._root.queryCollection()
stateSet = pyatspi.StateSet()
rule = collection.createMatchRule (stateSet.raw(),
collection.MATCH_ANY,
@@ -140,7 +140,7 @@ class AccessibleTest(_PasyTest):
), " 1 ")
def test_role(self, test):
- collection = self.root.queryCollection()
+ collection = self._root.queryCollection()
stateSet = pyatspi.StateSet()
rule = collection.createMatchRule (stateSet.raw(),
diff --git a/tests/pyatspi/componenttest.py b/tests/pyatspi/componenttest.py
index 1ac4410..63ef364 100644
--- a/tests/pyatspi/componenttest.py
+++ b/tests/pyatspi/componenttest.py
@@ -46,6 +46,7 @@ class ComponentTest(_PasyTest):
def setup(self, test):
self._registry = pyatspi.Registry()
self._desktop = self._registry.getDesktop(0)
+ self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_APPLICATION)
def test_contains(self, test):
pass
@@ -54,7 +55,7 @@ class ComponentTest(_PasyTest):
pass
def test_getExtents(self, test):
- root = self._desktop
+ root = self._root
one = root.getChildAtIndex(0)
two = root.getChildAtIndex(1)
@@ -70,7 +71,7 @@ class ComponentTest(_PasyTest):
extents[0], extents[1], extents[2], extents[3]))
def test_getPosition(self, test):
- root = self._desktop
+ root = self._root
one = root.getChildAtIndex(0)
two = root.getChildAtIndex(1)
@@ -85,7 +86,7 @@ class ComponentTest(_PasyTest):
% (expected[0], expected[1], position[0], position[1]))
def test_getSize(self, test):
- root = self._desktop
+ root = self._root
one = root.getChildAtIndex(0)
two = root.getChildAtIndex(1)
@@ -100,7 +101,7 @@ class ComponentTest(_PasyTest):
% (expected[0], expected[1], size[0], size[1]))
def test_getLayer(self, test):
- root = self._desktop
+ root = self._root
one = root.getChildAtIndex(0)
two = root.getChildAtIndex(1)
@@ -115,7 +116,7 @@ class ComponentTest(_PasyTest):
% (int(layer), int(expected)))
def test_getMDIZOrder(self, test):
- root = self._desktop
+ root = self._root
one = root.getChildAtIndex(0)
two = root.getChildAtIndex(1)
diff --git a/tests/pyatspi/pasytest/Pasy.py b/tests/pyatspi/pasytest/Pasy.py
index 80318ee..372ce80 100644
--- a/tests/pyatspi/pasytest/Pasy.py
+++ b/tests/pyatspi/pasytest/Pasy.py
@@ -31,6 +31,7 @@ class PasyTestStep(object):
def __init__(self, name):
self.events = PasyEvents()
self._state = PASY_TEST_NOT_STARTED
+ self.failMsg = None
self._name = name
diff --git a/tests/pyatspi/relationtest.py b/tests/pyatspi/relationtest.py
index 6171716..b39ae1c 100644
--- a/tests/pyatspi/relationtest.py
+++ b/tests/pyatspi/relationtest.py
@@ -27,7 +27,7 @@ class RelationTest(_PasyTest):
def setup(self, test):
self._registry = pyatspi.Registry()
self._desktop = self._registry.getDesktop(0)
- self._root = self._desktop
+ self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_APPLICATION)
self._rset = self._root.getRelationSet()
test.assertEqual(len(self._rset), 4, "Num relations expected %d, recieved %d" % (6, len(self._rset)))
diff --git a/tests/pyatspi/testrunner.in b/tests/pyatspi/testrunner.in
index e6dd9b2..f70a1d9 100755
--- a/tests/pyatspi/testrunner.in
+++ b/tests/pyatspi/testrunner.in
@@ -28,14 +28,12 @@ def run_test_app(module_name, dbus_name=None, wait_for_debug=False):
if (dbus_name):
print " ".join([test_application,
"--atspi-dbus-name", dbus_name,
- "--atspi-no-register",
"--test-dbus-name", dbus_name,
"--test-atspi-library", test_atspi_library,
"--test-module", test_module,
"--test-data-directory", test_data_directory,])
pop = Popen([test_application,
"--atspi-dbus-name", dbus_name,
- "--atspi-no-register",
"--test-dbus-name", dbus_name,
"--test-atspi-library", test_atspi_library,
"--test-module", test_module,
@@ -76,10 +74,6 @@ def main(argv):
to = bus.get_object(name, "/org/codethink/atspi/test")
test = dbus.Interface(to, "org.codethink.atspi.test")
- # Set the main loop specifications for pyatspi.
- import pyatspi
- pyatspi.set_default_registry(pyatspi.MAIN_LOOP_GLIB, name)
-
# Run the test script here
os.environ["ATSPI_TEST_APP_NAME"] = name
module = __import__(options.test_module)
@@ -93,6 +87,8 @@ def main(argv):
loop.quit()
print "\n" + test_object.report() + "\n"
test.finish()
+ if test_object.failMsg:
+ sys.exit (-1)
test_object.events.finished += finished_handler
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]