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);
88 typedef void (*TestModuleInit) (gchar *path);
91 load_test_module(const char *path, const char *tdpath)
95 test_module = g_module_open(path, G_MODULE_BIND_LOCAL|G_MODULE_BIND_LAZY);
97 g_error("Couldn't load test module : %s\n", path);
99 if (!g_module_symbol(test_module, "test_init", &init))
100 g_error("Couldn't load symbol \"test_init\"\n");
102 if (!g_module_symbol(test_module, "test_get_root", &test_module_get_root))
103 g_error("Couldn't load symbol \"test_get_root\"\n");
105 ((TestModuleInit) init)((gchar *)tdpath);
108 /*Command line data*/
109 static gchar *tmodule_path = NULL;
110 static gchar *amodule_path = NULL;
111 static gchar *tdata_path = NULL;
113 static GOptionEntry optentries[] =
115 {"test-module", 't', 0, G_OPTION_ARG_STRING, &tmodule_path, "Module containing test scenario", NULL},
116 {"atspi-module", 'a', 0, G_OPTION_ARG_STRING, &amodule_path, "Gtk module with atk-atspi adaptor", NULL},
117 {"test-data", 'd', 0, G_OPTION_ARG_STRING, &tdata_path, "Path to directory of test data", NULL},
123 * Entry point for all test applications.
125 main(int argc, char *argv[])
131 /*Parse command options*/
132 opt = g_option_context_new(NULL);
133 g_option_context_add_main_entries(opt, optentries, NULL);
134 g_option_context_set_ignore_unknown_options(opt, TRUE);
135 if (!g_option_context_parse(opt, &argc, &argv, &err))
136 g_error("Option parsing failed: %s\n", err->message);
138 if (tmodule_path == NULL)
139 g_error("No test module provided");
140 if (amodule_path == NULL)
141 g_error("No atspi module provided");
146 load_test_module(tmodule_path, tdata_path);
147 load_atspi_module(amodule_path, argc, argv);
149 mainloop = g_main_loop_new (NULL, FALSE);
150 g_main_loop_run (mainloop);