2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2008 Codethink Ltd.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * Testing AT-SPI requires both a test application and AT client.
25 * Test applications are built using the Dummy ATK implementation: MyAtk.
26 * This file contains the entry point for all test applications.
27 * Each test is built as a GModule, and this program loads the
28 * test module, as well as the AT-SPI module. The test module will
29 * provide its own implementation of atk_get_root, and as such provide
30 * all the application state for the test.
36 #include <dbus/dbus.h>
38 /* The test module, GModule containing interface for an atk-test */
39 static GModule *test_module;
40 static gpointer test_module_get_root;
42 /* Test module interface */
43 /*************************/
45 typedef AtkObject *(*TestModuleGetRoot) (void);
47 /* Calls into the test module to get the root atk object */
51 return ((TestModuleGetRoot) test_module_get_root)();
54 /*************************/
56 /* The AtkUtil class is called to find the root accessible and to deal
57 * with events. Its an incomplete class, its v-table needs to be filled in.
64 klass = g_type_class_ref(ATK_TYPE_UTIL);
65 klass->get_root = get_root;
66 g_type_class_unref(klass);
69 typedef void (*GtkModuleInit) (int argc, char *argv[]);
71 /* AT-SPI is a gtk module that must be loaded and initialized */
73 load_atspi_module(const char *path, int argc, char *argv[])
78 bridge = g_module_open(path, G_MODULE_BIND_LOCAL|G_MODULE_BIND_LAZY);
80 g_error("Couldn't load atk-bridge module : %s\n", path);
82 if (!g_module_symbol(bridge, "gtk_module_init", &init))
83 g_error("Couldn't load symbol \"gtk_module_init\"\n");
85 ((GtkModuleInit) init)(argc, argv);
89 load_test_module(const char *path, int argc, char *argv[])
93 test_module = g_module_open(path, G_MODULE_BIND_LOCAL|G_MODULE_BIND_LAZY);
95 g_error("Couldn't load test module : %s\n", path);
97 if (!g_module_symbol(test_module, "test_init", &init))
98 g_error("Couldn't load symbol \"test_init\"\n");
100 if (!g_module_symbol(test_module, "test_get_root", &test_module_get_root))
101 g_error("Couldn't load symbol \"test_get_root\"\n");
103 ((GtkModuleInit) init)(argc, argv);
106 /*Command line data*/
107 static gchar *tmodule_path;
108 static gchar *amodule_path;
110 static GOptionEntry optentries[] =
112 {"test-module", 't', 0, G_OPTION_ARG_STRING, &tmodule_path, "Module containing test scenario", NULL},
113 {"atspi-module", 'a', 0, G_OPTION_ARG_STRING, &amodule_path, "Gtk module with atk-atspi adaptor", NULL},
119 * Entry point for all test applications.
121 main(int argc, char *argv[])
127 /*Parse command options*/
128 opt = g_option_context_new(NULL);
129 g_option_context_add_main_entries(opt, optentries, NULL);
130 if (!g_option_context_parse(opt, &argc, &argv, &err))
132 g_print("Option parsing failed: %s\n", err->message);
139 load_test_module(tmodule_path, argc, argv);
140 load_atspi_module(amodule_path, argc, argv);
142 mainloop = g_main_loop_new (NULL, FALSE);
143 g_main_loop_run (mainloop);