summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGlady Handschumaker <gladyhandschumaker@fake-box.com>2020-07-25 10:16:44 +0200
committerGlady Handschumaker <gladyhandschumaker@fake-box.com>2020-07-25 10:16:44 +0200
commit6f5c54054060e8b93ffbfe4a1635defe3b52bfa2 (patch)
tree6761c59f194037724bfc02a852886613413af4c9 /test
parent7e19ba4dad1639f23b9704187e8790b125936b43 (diff)
downloadat-spi2-core-6f5c54054060e8b93ffbfe4a1635defe3b52bfa2.tar.gz
Replace gedit with a light-weight test application
The test `memory` depends on `gedit` being installed. Create our own small test application which can be used instead of `gedit`. Note: The 'depends' argument for tests need at least meson version 0.46.0. Thus, bump that requirement.
Diffstat (limited to 'test')
-rw-r--r--test/memory.c2
-rw-r--r--test/meson.build17
-rw-r--r--test/test-application.c105
3 files changed, 119 insertions, 5 deletions
diff --git a/test/memory.c b/test/memory.c
index df5e0a16..e8357fec 100644
--- a/test/memory.c
+++ b/test/memory.c
@@ -78,7 +78,7 @@ main()
atspi_event_listener_register (listener, "object:children-changed", NULL);
child_pid = fork ();
if (!child_pid)
- execlp ("gedit", "gedit", NULL);
+ execlp ("test/test-application", "test/test-application", NULL);
atspi_event_main ();
return 0;
}
diff --git a/test/meson.build b/test/meson.build
index 1fb35a8a..cd3db669 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,4 +1,13 @@
-test('memory',
- executable('memory', 'memory.c',
- include_directories: root_inc,
- dependencies: [ atspi_dep ]))
+testapp = executable('test-application',
+ 'test-application.c',
+ include_directories: root_inc,
+ dependencies: [ atspi_dep ],
+ )
+
+memory = executable('memory',
+ 'memory.c',
+ include_directories: root_inc,
+ dependencies: [ atspi_dep ],
+ )
+
+test('memory', memory, depends: testapp)
diff --git a/test/test-application.c b/test/test-application.c
new file mode 100644
index 00000000..621d1de4
--- /dev/null
+++ b/test/test-application.c
@@ -0,0 +1,105 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * Simple test application for AT-SPI.
+ *
+ * The only thing this application does, is registering itself to the AT-SPI
+ * registry and then waiting to get killed by some external force.
+ */
+
+#include <stdio.h>
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <atspi/atspi.h>
+
+static GMainLoop *mainloop;
+
+int
+register_app ()
+{
+ DBusConnection *connection = NULL;
+ DBusMessage *message;
+ DBusMessageIter iter;
+ DBusMessageIter subiter;
+ DBusError error;
+ DBusMessage *reply;
+ const gchar *name;
+ gchar *path;
+
+
+ /* Set up D-Bus connection and register bus name */
+ dbus_error_init (&error);
+ connection = atspi_get_a11y_bus ();
+ if (!connection)
+ {
+ printf("Couldn't get a11y bus!\n");
+ return -1;
+ }
+
+ /* Register this app by sending a signal out to AT-SPI registry daemon */
+ message = dbus_message_new_method_call (ATSPI_DBUS_NAME_REGISTRY,
+ ATSPI_DBUS_PATH_ROOT,
+ ATSPI_DBUS_INTERFACE_SOCKET,
+ "Embed");
+
+ dbus_message_iter_init_append (message, &iter);
+
+ name = dbus_bus_get_unique_name (connection);
+ path = g_strdup (ATSPI_DBUS_PATH_NULL);
+
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_STRUCT, NULL,
+ &subiter);
+ dbus_message_iter_append_basic (&subiter, DBUS_TYPE_STRING, &name);
+ dbus_message_iter_append_basic (&subiter, DBUS_TYPE_OBJECT_PATH, &path);
+ dbus_message_iter_close_container (&iter, &subiter);
+
+ g_free (path);
+
+ reply = dbus_connection_send_with_reply_and_block(connection, message, -1, &error);
+ if (!reply)
+ {
+ printf("Did not get a reply from the registry.\n");
+ dbus_message_unref (message);
+ dbus_error_free (&error);
+ return -1;
+ }
+
+ dbus_message_unref (message);
+ dbus_message_unref (reply);
+ dbus_error_free (&error);
+ return 0;
+}
+
+int main (int argc, char *argv[])
+{
+ int ret = register_app ();
+ if (ret) {
+ printf("Failed to send dbus signals. Aborting.\n");
+ return ret;
+ }
+
+ // This keeps the test-application runnig indefinitely, i.e.
+ // until killed by an external signal.
+ mainloop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (mainloop);
+
+ return 0;
+}