From: Mark Doffman Date: Tue, 3 Jun 2008 03:46:45 +0000 (+0100) Subject: 2008-06-02 Mark Doffman X-Git-Tag: AT_SPI2_CORE_0_1_3~213^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=685229dfd041efb42581b0ec7912b3614d08cbd4;p=platform%2Fupstream%2Fat-spi2-core.git 2008-06-02 Mark Doffman * pyatspi --> python/pyatspi Move the accessible_cache out of test and into the python directory. Move pyatspi to a subdirectory from here. * tests/clients Add a framework for invoking and testing the atk adaptor using the test applications. --- diff --git a/configure.ac b/configure.ac index 8b51084..72f533c 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,10 @@ PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= 0.7.0]) AC_SUBST(DBUS_GLIB_LIBS) AC_SUBST(DBUS_GLIB_CFLAGS) +PKG_CHECK_MODULES(LIB_XML, [libxml-2.0 >= 2.0.0]) +AC_SUBST(LIB_XML_LIBS) +AC_SUBST(LIB_XML_CFLAGS) + PKG_CHECK_MODULES(GOBJ, [gobject-2.0 >= 2.0.0]) AC_SUBST(GOBJ_LIBS) AC_SUBST(GOBJ_CFLAGS) @@ -116,6 +120,7 @@ AC_CONFIG_FILES([Makefile registryd/Makefile atk-adaptor/Makefile tests/dummyatk/Makefile - tests/testapps/Makefile]) + tests/clients/Makefile + tests/apps/Makefile]) AC_OUTPUT diff --git a/tests/accessible_cache.py b/python/accessible_cache.py similarity index 100% rename from tests/accessible_cache.py rename to python/accessible_cache.py diff --git a/pyatspi/ChangeLog b/python/pyatspi/ChangeLog similarity index 100% rename from pyatspi/ChangeLog rename to python/pyatspi/ChangeLog diff --git a/pyatspi/Makefile.am b/python/pyatspi/Makefile.am similarity index 100% rename from pyatspi/Makefile.am rename to python/pyatspi/Makefile.am diff --git a/pyatspi/__init__.py b/python/pyatspi/__init__.py similarity index 100% rename from pyatspi/__init__.py rename to python/pyatspi/__init__.py diff --git a/pyatspi/accessible.py b/python/pyatspi/accessible.py similarity index 100% rename from pyatspi/accessible.py rename to python/pyatspi/accessible.py diff --git a/pyatspi/constants.py b/python/pyatspi/constants.py similarity index 100% rename from pyatspi/constants.py rename to python/pyatspi/constants.py diff --git a/pyatspi/event.py b/python/pyatspi/event.py similarity index 100% rename from pyatspi/event.py rename to python/pyatspi/event.py diff --git a/pyatspi/registry.py b/python/pyatspi/registry.py similarity index 100% rename from pyatspi/registry.py rename to python/pyatspi/registry.py diff --git a/pyatspi/setup.py b/python/pyatspi/setup.py similarity index 100% rename from pyatspi/setup.py rename to python/pyatspi/setup.py diff --git a/pyatspi/utils.py b/python/pyatspi/utils.py similarity index 100% rename from pyatspi/utils.py rename to python/pyatspi/utils.py diff --git a/tests/AccessibleTree.py b/tests/AccessibleTree.py deleted file mode 100644 index ba76d80..0000000 --- a/tests/AccessibleTree.py +++ /dev/null @@ -1,55 +0,0 @@ -import dbus -import dbus.service - -class AccessibleTree(dbus.service.Object): - """ - The Accessible tree provides the interface, - for accessing all the accessible objects - available on a particular application. - """ - - def __init__(self, bus, path): - """ - Parameters: - - bus - The D-Bus bus object to use - path - The object path this interface should use - """ - dbus.service.Object.__init__(self, bus, path) - self._toSend = {} - self._toRemove = [] - self._objects = {} - self._root = '/' - - @dbus.service.method(dbus_interface='org.freedesktop.atspi.Tree', - out_signature='o') - def getRoot(self): - return self._root - - @dbus.service.method(dbus_interface='org.freedesktop.atspi.Tree', - out_signature='a(ooaoassus)') - def getTree(self): - return self._objects.values() - - @dbus.service.signal(dbus_interface='org.freedesktop.atspi.Tree', - signature=('a(ooaoassus)ao')) - def updateTree(self, objects, paths): - #There are some locking issues here. - #Need to make sure that updates are not missed. - oldSend = self._toSend.values() - self._toSend = {} - oldRemove = self._toRemove - self._toRemove = [] - return (oldSend, oldRemove) - - def updateObject(self, path, object): - self._objects[path] = object - self._toSend[path] = object - - def removeObject(self, path): - if path in self._objects: - self._toRemove.append(path) - del(self._objects[path]) - - def setRoot(self, root): - self._root = root diff --git a/tests/Makefile.am b/tests/Makefile.am index b012e65..15f1aff 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,9 +1,3 @@ -SUBDIRS=dummyatk testapps +SUBDIRS=dummyatk apps clients -EXTRA_DIST = \ - AccessibleTree.py \ - AccessibleTreeCache.py \ - desktop.xml \ - makeTree.py \ - testClient.py \ - testServer.py +EXTRA_DIST = testrunner.py diff --git a/tests/testapps/Makefile.am b/tests/apps/Makefile.am similarity index 79% rename from tests/testapps/Makefile.am rename to tests/apps/Makefile.am index a37699c..0f0b550 100644 --- a/tests/testapps/Makefile.am +++ b/tests/apps/Makefile.am @@ -22,7 +22,7 @@ libnoopapp_la_LDFLAGS = $(TEST_APP_LDFLAGS) libnoopapp_la_LIBADD = $(TEST_APP_LIBADD) libnoopapp_la_SOURCES = noop-app.c -libobjectapp_la_CFLAGS = $(TEST_APP_CFLAGS) +libobjectapp_la_CFLAGS = $(TEST_APP_CFLAGS) $(LIB_XML_CFLAGS) libobjectapp_la_LDFLAGS = $(TEST_APP_LDFLAGS) -libobjectapp_la_LIBADD = $(TEST_APP_LIBADD) -libobjectapp_la_SOURCES = object-app.c +libobjectapp_la_LIBADD = $(TEST_APP_LIBADD) $(LIB_XML_LIBS) +libobjectapp_la_SOURCES = object-app.c atk-object-xml-loader.c atk-object-xml-loader.h diff --git a/tests/apps/atk-object-xml-loader.c b/tests/apps/atk-object-xml-loader.c new file mode 100644 index 0000000..5fa2354 --- /dev/null +++ b/tests/apps/atk-object-xml-loader.c @@ -0,0 +1,95 @@ +/* + * Copyright 2008 Codethink Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include + +#include + +#define ACCESSIBLE_NODE ((const xmlChar *) "accessible") +#define INTERFACE_NODE ((const xmlChar *) "interface") + +#define NAME_ATTR ((const xmlChar *) "name") +#define DESC_ATTR ((const xmlChar *) "description") +#define ROLE_ATTR ((const xmlChar *) "role") + +static MyAtkObject * +create_atk_object_from_element(xmlNode *element) +{ + xmlNode *child_node; + + MyAtkObject *obj = NULL; + MyAtkObject *child_obj; + + xmlChar *name; + xmlChar *description; + xmlChar *role_text; + gint role; + + name = xmlGetProp(element, NAME_ATTR); + description = xmlGetProp(element, DESC_ATTR); + role_text = xmlGetProp(element, ROLE_ATTR); + role = atoi(role_text); + + obj = MY_ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT, + "accessible-name", name, + "accessible-description", description, + "accessible-role", role, + NULL)); + + child_node = element->xmlChildrenNode; + while (child_node != NULL) + { + if (!xmlStrcmp(child_node->name, ACCESSIBLE_NODE)) + { + child_obj = create_atk_object_from_element(child_node); + my_atk_object_add_child(obj, child_obj); + } + child_node = child_node->next; + } + return obj; +} + +/* + * Reads the XML from filename and uses it + * to create a tree of MyAtkObjects. + * + * returns: The root object of the tree. + */ +MyAtkObject * +atk_object_xml_parse(gchar *filename) +{ + xmlDoc *doc; + xmlNode *root_element; + MyAtkObject *new_atk_object = NULL; + + doc = xmlReadFile(filename, NULL, 0); + g_assert(doc != NULL); + + root_element = xmlDocGetRootElement(doc); + + if (!xmlStrcmp(root_element->name, ACCESSIBLE_NODE)) + new_atk_object = create_atk_object_from_element(root_element); + + xmlFreeDoc(doc); + return new_atk_object; +} diff --git a/tests/apps/atk-object-xml-loader.h b/tests/apps/atk-object-xml-loader.h new file mode 100644 index 0000000..ce707bd --- /dev/null +++ b/tests/apps/atk-object-xml-loader.h @@ -0,0 +1,29 @@ +/* + * Copyright 2008 Codethink Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef ATK_OBJECT_XML_LOADER_H +#define ATK_OBJECT_XML_LOADER_H + +#include +#include + +MyAtkObject * +atk_object_xml_parse(gchar *filename); + +#endif /*ATK_OBJECT_XML_LOADER_H*/ diff --git a/tests/testapps/noop-app.c b/tests/apps/noop-app.c similarity index 80% rename from tests/testapps/noop-app.c rename to tests/apps/noop-app.c index 7b997cc..42951eb 100644 --- a/tests/testapps/noop-app.c +++ b/tests/apps/noop-app.c @@ -2,7 +2,7 @@ #include G_MODULE_EXPORT void -test_init (void) +test_init (int argc, char *argv[]) { ; } diff --git a/tests/apps/object-app.c b/tests/apps/object-app.c new file mode 100644 index 0000000..74dabb3 --- /dev/null +++ b/tests/apps/object-app.c @@ -0,0 +1,31 @@ +#include +#include +#include + +#include "atk-object-xml-loader.h" + +static gchar *tdata_path = NULL; + +static AtkObject *root_accessible; + +#define OBJECT_TEST_1 "object-test-stage1.xml" + +G_MODULE_EXPORT void +test_init (gchar *path) +{ + gchar *td; + + if (path == NULL) + g_error("No test data path provided"); + tdata_path = path; + + td = g_build_path(G_DIR_SEPARATOR_S, tdata_path, OBJECT_TEST_1, NULL); + root_accessible = ATK_OBJECT(atk_object_xml_parse(td)); + g_free(td); +} + +G_MODULE_EXPORT AtkObject * +test_get_root (void) +{ + return root_accessible; +} diff --git a/tests/testapps/test-application.c b/tests/apps/test-application.c similarity index 85% rename from tests/testapps/test-application.c rename to tests/apps/test-application.c index a499584..41118e3 100644 --- a/tests/testapps/test-application.c +++ b/tests/apps/test-application.c @@ -85,8 +85,10 @@ load_atspi_module(const char *path, int argc, char *argv[]) ((GtkModuleInit) init)(argc, argv); } +typedef void (*TestModuleInit) (gchar *path); + static void -load_test_module(const char *path, int argc, char *argv[]) +load_test_module(const char *path, const char *tdpath) { gpointer init; @@ -100,17 +102,19 @@ load_test_module(const char *path, int argc, char *argv[]) if (!g_module_symbol(test_module, "test_get_root", &test_module_get_root)) g_error("Couldn't load symbol \"test_get_root\"\n"); - ((GtkModuleInit) init)(argc, argv); + ((TestModuleInit) init)((gchar *)tdpath); } /*Command line data*/ -static gchar *tmodule_path; -static gchar *amodule_path; +static gchar *tmodule_path = NULL; +static gchar *amodule_path = NULL; +static gchar *tdata_path = NULL; static GOptionEntry optentries[] = { {"test-module", 't', 0, G_OPTION_ARG_STRING, &tmodule_path, "Module containing test scenario", NULL}, {"atspi-module", 'a', 0, G_OPTION_ARG_STRING, &amodule_path, "Gtk module with atk-atspi adaptor", NULL}, + {"test-data", 'd', 0, G_OPTION_ARG_STRING, &tdata_path, "Path to directory of test data", NULL}, {NULL} }; @@ -127,16 +131,19 @@ main(int argc, char *argv[]) /*Parse command options*/ opt = g_option_context_new(NULL); g_option_context_add_main_entries(opt, optentries, NULL); + g_option_context_set_ignore_unknown_options(opt, TRUE); if (!g_option_context_parse(opt, &argc, &argv, &err)) - { - g_print("Option parsing failed: %s\n", err->message); - exit(1); - } + g_error("Option parsing failed: %s\n", err->message); + + if (tmodule_path == NULL) + g_error("No test module provided"); + if (amodule_path == NULL) + g_error("No atspi module provided"); g_type_init(); setup_atk_util(); - load_test_module(tmodule_path, argc, argv); + load_test_module(tmodule_path, tdata_path); load_atspi_module(amodule_path, argc, argv); mainloop = g_main_loop_new (NULL, FALSE); diff --git a/tests/clients/Makefile.am b/tests/clients/Makefile.am new file mode 100644 index 0000000..2777638 --- /dev/null +++ b/tests/clients/Makefile.am @@ -0,0 +1,5 @@ +EXTRA_DIST = \ + accessibleobject.py \ + __init__.py \ + object-test-stage1.xml \ + testutil.py diff --git a/tests/clients/__init__.py b/tests/clients/__init__.py new file mode 100644 index 0000000..40674f3 --- /dev/null +++ b/tests/clients/__init__.py @@ -0,0 +1,5 @@ + +from accessibleobject import AccessibleObjectTestCase +import testutil + +del accessibleobject diff --git a/tests/clients/accessibleobject.py b/tests/clients/accessibleobject.py new file mode 100644 index 0000000..480b3f7 --- /dev/null +++ b/tests/clients/accessibleobject.py @@ -0,0 +1,49 @@ +import unittest +import testutil + +import dbus +import gobject +import os.path +from dbus.mainloop.glib import DBusGMainLoop + +from accessible_cache import AccessibleCache + +from xml.dom import minidom + +def createNode(accessible, parentElement): + e = minidom.Element("accessible") + + e.attributes["name"] = accessible.name + e.attributes["role"] = str(int(accessible.role)) + e.attributes["description"] = accessible.description + + for i in range(0, accessible.numChildren): + createNode(accessible.getChild(i), e) + + parentElement.appendChild(e) + +class AccessibleObjectTestCase(unittest.TestCase): + def setUp(self): + DBusGMainLoop(set_as_default=True) + self._app = testutil.runTestApp("libobjectapp.so") + + self._bus = dbus.SessionBus() + self._loop = gobject.MainLoop() + self._cache = AccessibleCache(self._bus, testutil.busname, testutil.objectpath) + + def tearDown(self): + del(self._bus) + del(self._loop) + del(self._cache) + #TODO Shut down the test application. + del(self._app) + + def runTest(self): + root = self._cache.getRootAccessible() + doc = minidom.Document() + createNode(root, doc) + answer = doc.toprettyxml() + correct = os.path.join(testutil.testdata, "object-test-stage1.xml") + file = open(correct) + cstring = file.read() + self.assertEqual(answer, cstring, "Object tree not passed correctly") diff --git a/tests/clients/object-test-stage1.xml b/tests/clients/object-test-stage1.xml new file mode 100644 index 0000000..54729ca --- /dev/null +++ b/tests/clients/object-test-stage1.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/clients/testutil.py b/tests/clients/testutil.py new file mode 100644 index 0000000..a5bc9dd --- /dev/null +++ b/tests/clients/testutil.py @@ -0,0 +1,27 @@ +#Bus name where test application can be found. +busname = "test.atspi.tree" + +#Path of tree interface on test application. +objectpath = "/org/freedesktop/atspi/tree" + +#Directory where test data, such as XML results +#can be found. +testdata = "./" + +#Location of test application. +testapp = "../apps/test-application" + +#Directory of test application modules. +testmodules = "../apps/.libs" + +#Atk to at-spi adaptor library location. +atspilib = "../../atk-adaptor/.libs/libspiatk.so" + +from subprocess import Popen +from os.path import join + +def runTestApp(module_name): + testmodule = join(testmodules, module_name) + print testmodule + print testapp + return Popen([testapp , "-a", atspilib, "-t", testmodule, "-d", testdata]) diff --git a/tests/desktop.xml b/tests/desktop.xml deleted file mode 100644 index 54b4f96..0000000 --- a/tests/desktop.xml +++ /dev/null @@ -1,469 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/dummyatk/my-atk-object.c b/tests/dummyatk/my-atk-object.c index d45a2ef..fec5f99 100644 --- a/tests/dummyatk/my-atk-object.c +++ b/tests/dummyatk/my-atk-object.c @@ -5,18 +5,16 @@ static AtkObjectClass *atk_object_parent_class = NULL; - -//add/remove child to/from array of parent(for internal use) -static void my_atk_object_add_child(MyAtkObject* parent, MyAtkObject* child) +void my_atk_object_add_child(MyAtkObject* parent, MyAtkObject* child) { g_ptr_array_add(parent->children, child); - g_object_ref(child); + g_object_ref_sink(child); g_signal_emit_by_name(parent, "children-changed::add", parent->children->len - 1, child); } -static void my_atk_object_remove_child(MyAtkObject* parent, MyAtkObject* child) +void my_atk_object_remove_child(MyAtkObject* parent, MyAtkObject* child) { gint i; for(i = parent->children->len - 1; i >= 0; i--) diff --git a/tests/dummyatk/my-atk-object.h b/tests/dummyatk/my-atk-object.h index 6007e3c..04b0c78 100644 --- a/tests/dummyatk/my-atk-object.h +++ b/tests/dummyatk/my-atk-object.h @@ -28,4 +28,8 @@ struct _MyAtkObjectClass GType my_atk_object_get_type(); +void my_atk_object_add_child(MyAtkObject* parent, MyAtkObject* child); + +void my_atk_object_remove_child(MyAtkObject* parent, MyAtkObject* child); + #endif /*MY_ATK_OBJECT_H*/ diff --git a/tests/makeTree.py b/tests/makeTree.py deleted file mode 100644 index 41395c2..0000000 --- a/tests/makeTree.py +++ /dev/null @@ -1,79 +0,0 @@ -import sys -import pyatspi -import uuid - -from xml.dom import minidom - -INTERFACES = [ -"Accessible", -"Desktop", -"Image", -"StreamableContent", -"Action", -"Document", -"Table", -"Application", -"EditableText", -"MatchRule", -"Text", -"Collection", -"Hyperlink", -"Value", -"Component", -"Hypertext", -"Selection", -] - -def getChild(accessible, i): - try: - child = accessible.getChildAtIndex(i) - except LookupError: - child = None - return child - -def createNode(accessible, parentRef, parentElement): - e = minidom.Element("accessible") - reference = '/' + str(uuid.uuid4()).replace('-', '') - - e.attributes["reference"] = reference - e.attributes["parent"] = parentRef - e.attributes["name"] = accessible.name - e.attributes["role"] = str(accessible.getRole()) - e.attributes["description"] = accessible.description - - for i in INTERFACES: - query = getattr(accessible, "query" + i) - try: - query() - itf = minidom.Element("interface") - itf.attributes["name"] = i - e.appendChild(itf) - except NotImplementedError: - pass - except LookupError: - pass - - try: - count = accessible.childCount - except LookupError: - count = 0 - - for i in range(count): - child = getChild(accessible, i) - if child is not None: - createNode(child, reference, e) - - parentElement.appendChild(e) - -def main(argv): - filename = argv[1] - doc = minidom.Document() - desk = pyatspi.Registry.getDesktop(0) - createNode(desk, '/', doc) - - file = open(filename, 'w') - file.write(doc.toprettyxml()) - file.close() - -if __name__ == "__main__": - sys.exit(main(sys.argv)) diff --git a/tests/testClient.py b/tests/testClient.py deleted file mode 100644 index ebf53c8..0000000 --- a/tests/testClient.py +++ /dev/null @@ -1,51 +0,0 @@ -import sys -import gobject -import dbus -from dbus.mainloop.glib import DBusGMainLoop - -from xml.dom import minidom - -from accessible_cache import AccessibleCache - -DBusGMainLoop(set_as_default=True) - -def createNode(accessible, parentRef, parentElement): - e = minidom.Element("accessible") - - e.attributes["reference"] = accessible.path - try: - e.attributes["parent"] = accessible.parent.path - except: - pass - e.attributes["name"] = accessible.name - e.attributes["role"] = str(int(accessible.role)) - e.attributes["description"] = accessible.description - - for i in accessible.interfaces: - itf = minidom.Element("interface") - itf.attributes["name"] = i - e.appendChild(itf) - - for i in range(0, accessible.numChildren): - createNode(accessible.getChild(i), accessible.path, e) - - parentElement.appendChild(e) - -def main(argv): - filename = argv[1] - bus = dbus.SessionBus() - - loop = gobject.MainLoop() - - cache = AccessibleCache(bus, 'test.atspi.tree', '/org/freedesktop/atspi/tree') - root = cache.getRootAccessible() - - doc = minidom.Document() - createNode(root, '/', doc) - - file = open(filename, 'w') - file.write(doc.toprettyxml()) - file.close() - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/tests/testServer.py b/tests/testServer.py deleted file mode 100644 index 7c360a8..0000000 --- a/tests/testServer.py +++ /dev/null @@ -1,54 +0,0 @@ -import sys -import gobject -import dbus -from dbus.mainloop.glib import DBusGMainLoop - -from xml.dom import minidom - -from AccessibleTree import AccessibleTree - -DBusGMainLoop(set_as_default=True) - -def getChildrenByName(node, name): - return [child for child in node.childNodes if child.nodeType == child.ELEMENT_NODE and child.nodeName == name] - -def registerObject(tree, parent, node): - reference = node.getAttribute('reference').encode('ASCII') - name = node.getAttribute('name').encode('ASCII') - role = node.getAttribute('role').encode('ASCII') - description = node.getAttribute('description').encode('ASCII') - - interfacen = getChildrenByName(node, 'interface') - interfaces = [itf.getAttribute('name').encode('ASCII') for itf in interfacen] - - childrenn = getChildrenByName(node, 'accessible') - children = [cld.getAttribute('reference').encode('ASCII') for cld in childrenn] - - object = (reference, parent, children, interfaces, name, int(role), description) - tree.updateObject(reference, object) - - for child in childrenn: - registerObject(tree, reference, child) - -def main(argv): - filename = argv[1] - bus = dbus.SessionBus() - - loop = gobject.MainLoop() - - bus.request_name('test.atspi.tree', 0) - - tree = AccessibleTree(bus, '/org/freedesktop/atspi/tree') - doc = minidom.parse(filename) - node = doc.firstChild - tree.setRoot(node.getAttribute('reference').encode('ASCII')) - - registerObject(tree, '/', node) - - try: - loop.run() - except KeyboardInterrupt: - loop.quit() - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/tests/testapps/object-app.c b/tests/testapps/object-app.c deleted file mode 100644 index 85d4f2c..0000000 --- a/tests/testapps/object-app.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -static AtkObject *root_accessible; - -G_MODULE_EXPORT void -test_init (void) -{ - root_accessible = (AtkObject *) g_object_new(MY_TYPE_ATK_OBJECT, NULL); - - atk_object_set_name(root_accessible, "Root Accessible"); - atk_object_set_role(root_accessible, ATK_ROLE_ACCEL_LABEL); - atk_object_set_description(root_accessible, "A root object for the test tree"); -} - -G_MODULE_EXPORT AtkObject * -test_get_root (void) -{ - return root_accessible; -} diff --git a/tests/testrunner.py b/tests/testrunner.py new file mode 100644 index 0000000..5684c75 --- /dev/null +++ b/tests/testrunner.py @@ -0,0 +1,36 @@ +import sys +import unittest +import clients + +from optparse import OptionParser + +parser = OptionParser() +parser.add_option("-d", "--testdata", dest="testdata", help="Location of test data directory") +parser.add_option("-a", "--atspilib", dest="atspilib", help="Location of atk to atspi adaptor") +parser.add_option("-t", "--testmodules", dest="testmodules", help="Location of test application libraries") +parser.add_option("-r", "--testapp", dest="testapp", help="Location of test application executable") +parser.add_option("-b", "--busname", dest="busname", help="D-Bus name of test application") +parser.add_option("-o", "--objectpath", dest="objectpath", help="Object path of test applicaiton tree interface") + +optionvars = ["testdata", + "atspilib", + "testmodules", + "testapp", + "busname", + "objectpath"] + +def set_data(options, name): + val = getattr(options, name) + if val is not None: + setattr(clients.testutil, name, val) + +def main(argv): + (options, args) = parser.parse_args() + [set_data(options, name) for name in optionvars] + + runner = unittest.TextTestRunner() + testsuite = unittest.defaultTestLoader.loadTestsFromModule(clients) + runner.run(testsuite) + +if __name__=="__main__": + sys.exit(main(sys.argv))