summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Doffman <mdoff@silver-wind.(none)>2008-08-25 11:25:25 +0100
committerMark Doffman <mdoff@silver-wind.(none)>2008-08-25 11:25:25 +0100
commit284b0912af473912449a6db3592b396d4092ab27 (patch)
tree82a7cfa32675168870a8a9a451ae355fa059e5df /tests
parentfbd6557599ce5a51401d08b027f39536d36774a5 (diff)
downloadat-spi2-atk-284b0912af473912449a6db3592b396d4092ab27.tar.gz
2008-08-25 Mark Doffman <mark.doffman@codethink.co.uk>
* pyatspi/relation.py Fix the generation of target objects. * pyatspi/accessible.py Fix demarshalling of relation objects. * pyatspi/base.py Add a string representation of the accessible class. * tests/pyatspi/realtiontest.py Add a relation unit test. * atk-adaptor/accessible.c Fix bug in marshalling relation object.
Diffstat (limited to 'tests')
-rw-r--r--tests/apps/Makefile.am8
-rw-r--r--tests/apps/relation-app.c90
-rw-r--r--tests/pyatspi/Makefile.am1
-rw-r--r--tests/pyatspi/relationtest.py70
4 files changed, 168 insertions, 1 deletions
diff --git a/tests/apps/Makefile.am b/tests/apps/Makefile.am
index 7cd93d5..12a3257 100644
--- a/tests/apps/Makefile.am
+++ b/tests/apps/Makefile.am
@@ -2,7 +2,8 @@ check_PROGRAMS = test-application
check_LTLIBRARIES = libnoopapp.la \
libaccessibleapp.la \
libcomponentapp.la \
- libactionapp.la
+ libactionapp.la \
+ librelationapp.la
test_application_CFLAGS = $(DBUS_GLIB_CFLAGS) \
$(ATK_CFLAGS) \
@@ -39,3 +40,8 @@ libactionapp_la_CFLAGS = $(TEST_APP_CFLAGS)
libactionapp_la_LDFLAGS = $(TEST_APP_LDFLAGS)
libactionapp_la_LIBADD = $(TEST_APP_LIBADD)
libactionapp_la_SOURCES = action-app.c
+
+librelationapp_la_CFLAGS = $(TEST_APP_CFLAGS)
+librelationapp_la_LDFLAGS = $(TEST_APP_LDFLAGS)
+librelationapp_la_LIBADD = $(TEST_APP_LIBADD)
+librelationapp_la_SOURCES = relation-app.c
diff --git a/tests/apps/relation-app.c b/tests/apps/relation-app.c
new file mode 100644
index 0000000..5734ffe
--- /dev/null
+++ b/tests/apps/relation-app.c
@@ -0,0 +1,90 @@
+#include <gmodule.h>
+#include <atk/atk.h>
+#include <my-atk.h>
+
+static AtkObject *root_accessible;
+
+G_MODULE_EXPORT void
+test_init (gchar *path)
+{
+ AtkObject *r1, *r2, *r3;
+ AtkObject *m1, *m2, *m3;
+ AtkRelationSet *rset;
+ AtkRelation *rel;
+ AtkObject *rls[3];
+
+ root_accessible = g_object_new(MY_TYPE_ATK_OBJECT, NULL);
+
+ r1 = ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
+ "accessible-name", "r1",
+ "accessible-description", "",
+ "accessible-role", ATK_ROLE_INVALID,
+ NULL));
+ my_atk_object_add_child(MY_ATK_OBJECT(root_accessible), MY_ATK_OBJECT(r1));
+
+ r2 = ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
+ "accessible-name", "r2",
+ "accessible-description", "",
+ "accessible-role", ATK_ROLE_INVALID,
+ NULL));
+ my_atk_object_add_child(MY_ATK_OBJECT(root_accessible), MY_ATK_OBJECT(r2));
+
+ r3 = ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
+ "accessible-name", "r3",
+ "accessible-description", "",
+ "accessible-role", ATK_ROLE_INVALID,
+ NULL));
+ my_atk_object_add_child(MY_ATK_OBJECT(root_accessible), MY_ATK_OBJECT(r3));
+
+ m1 = ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
+ "accessible-name", "m1",
+ "accessible-description", "",
+ "accessible-role", ATK_ROLE_INVALID,
+ NULL));
+ my_atk_object_add_child(MY_ATK_OBJECT(root_accessible), MY_ATK_OBJECT(m1));
+
+ m2 = ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
+ "accessible-name", "m2",
+ "accessible-description", "",
+ "accessible-role", ATK_ROLE_INVALID,
+ NULL));
+ my_atk_object_add_child(MY_ATK_OBJECT(root_accessible), MY_ATK_OBJECT(m2));
+
+ m3 = ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
+ "accessible-name", "m3",
+ "accessible-description", "",
+ "accessible-role", ATK_ROLE_INVALID,
+ NULL));
+ my_atk_object_add_child(MY_ATK_OBJECT(root_accessible), MY_ATK_OBJECT(m3));
+
+ atk_object_add_relationship(root_accessible, ATK_RELATION_EMBEDS, r1);
+ atk_object_add_relationship(root_accessible, ATK_RELATION_PARENT_WINDOW_OF, r2);
+ atk_object_add_relationship(root_accessible, ATK_RELATION_DESCRIBED_BY, r3);
+
+ rls[0] = m1;
+ rls[1] = m2;
+ rls[2] = m3;
+
+ rset = atk_object_ref_relation_set(root_accessible);
+ rel = atk_relation_new(rls, 3, ATK_RELATION_POPUP_FOR);
+ atk_relation_set_add(rset, rel);
+ g_object_unref(G_OBJECT(rset));
+}
+
+G_MODULE_EXPORT void
+test_next (int argc, char *argv[])
+{
+ g_print("Moving to next stage\n");
+}
+
+G_MODULE_EXPORT void
+test_finished (int argc, char *argv[])
+{
+ g_print("Test has completed\n");
+}
+
+G_MODULE_EXPORT AtkObject *
+test_get_root (void)
+{
+ return root_accessible;
+}
diff --git a/tests/pyatspi/Makefile.am b/tests/pyatspi/Makefile.am
index 8c22146..dbe32a8 100644
--- a/tests/pyatspi/Makefile.am
+++ b/tests/pyatspi/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST = \
Makefile.am\
Makefile.in\
setvars.sh\
+ relationtest.py\
testrunner.py
CLEANFILES = *.pyc
diff --git a/tests/pyatspi/relationtest.py b/tests/pyatspi/relationtest.py
new file mode 100644
index 0000000..6f93b14
--- /dev/null
+++ b/tests/pyatspi/relationtest.py
@@ -0,0 +1,70 @@
+import dbus
+import gobject
+import os.path
+
+from xml.dom import minidom
+import os
+
+from pasytest import PasyTest as _PasyTest
+
+import pyatspi
+
+class RelationTest(_PasyTest):
+
+ __tests__ = ["setup",
+ "teardown",
+ "test_getRelationType",
+ "test_getRelationTypeName",
+ "test_getNTargets",
+ "test_getTarget",
+ ]
+
+ def __init__(self, bus, path):
+ _PasyTest.__init__(self, "Relation", False)
+ self._bus = bus
+ self._path = path
+
+ def setup(self, test):
+ self._registry = pyatspi.registry.Registry(self._path)
+ self._desktop = self._registry.getDesktop(0)
+ self._root = self._desktop[0]
+ self._rset = self._root.getRelationSet()
+ test.assertEqual(len(self._rset), 4, "Num relations expected %d, recieved %d" % (6, len(self._rset)))
+
+ def test_getRelationType(self, test):
+ expected = [pyatspi.RELATION_EMBEDS,
+ pyatspi.RELATION_PARENT_WINDOW_OF,
+ pyatspi.RELATION_DESCRIBED_BY,
+ pyatspi.RELATION_POPUP_FOR,]
+ rtypes = [rel.getRelationType() for rel in self._rset]
+ for exp, type in zip(expected, rtypes):
+ test.assertEqual(exp, type, "Relation type expected %s, recieved %s" % (exp, type))
+
+ def test_getRelationTypeName(self, test):
+ # FIXME This may not have been implemented in CORBA.
+ # Completely unused?
+ pass
+
+ def test_getNTargets(self, test):
+ expected = [1, 1, 1, 3]
+ ntargs = [rel.getNTargets() for rel in self._rset]
+ for exp, ntarg in zip(expected, ntargs):
+ test.assertEqual(exp, ntarg, "Number of targets expected %s, recieved %s" % (exp, ntarg))
+
+ def test_getTarget(self, test):
+ rone = self._rset[0]
+ tone = rone.getTarget(0)
+ tonename = tone.name
+ test.assertEqual(tonename, "r1", "Target name expected %s, recieved %s" % ("r1", tonename))
+ tonerole = tone.getRoleName()
+ test.assertEqual(tonerole, "invalid", "Target RoleName expected %s, recieved %s" % ("invalid", tonename))
+
+ rtwo = self._rset[3]
+ ttwo = rtwo.getTarget(2)
+ ttwoname = ttwo.name
+ test.assertEqual(ttwoname, "m3", "Target name expected %s, recieved %s" % ("m3", ttwoname))
+ ttworole = ttwo.getRoleName()
+ test.assertEqual(ttworole, "invalid", "Target RoleName expected %s, recieved %s" % ("invalid", ttwoname))
+
+ def teardown(self, test):
+ pass