summaryrefslogtreecommitdiff
path: root/test/test-utils.h
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-02 16:32:31 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-03 12:00:51 +0100
commit30e7a81302a60adc4ec497deee3c0dfe8ec1123e (patch)
tree62c090f2ad018868dd0115d7bbbe1d544d72143c /test/test-utils.h
parentf17fd1cc4e8d69f92986b6f452618c6c1b9819dc (diff)
downloaddbus-30e7a81302a60adc4ec497deee3c0dfe8ec1123e.tar.gz
Tests: allow dbus-glib to be replaced with use of libdbus-internal
We only use dbus-glib for its main loop; within dbus, DBusLoop is available as an alternative, although it isn't thread-safe and isn't public API. For tests that otherwise only use libdbus public API, it's desirable to be able to avoid DBusLoop, so we can run them against an installed libdbus as an integration test. However, if we don't have dbus-glib, we're going to have to use an in-tree main loop, which might as well be DBusLoop. The major disadvantage of using dbus-glib is that it isn't safe to link both dbus-1 and dbus-internal at the same time. This is awkward for a future test case that wants to use _dbus_getsid() in dbus-daemon.c, but only on Windows (fd.o #54445). If we use the same API wrapper around both dbus-glib and DBusLoop, we can compile that test against dbus-glib or against DBusLoop, depending on the platform. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'test/test-utils.h')
-rw-r--r--test/test-utils.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/test/test-utils.h b/test/test-utils.h
index 8d5357e1..0d3f3690 100644
--- a/test/test-utils.h
+++ b/test/test-utils.h
@@ -1,21 +1,38 @@
#ifndef TEST_UTILS_H
#define TEST_UTILS_H
-#include <dbus/dbus.h>
+
#include <stdio.h>
#include <stdlib.h>
-#include <dbus/dbus-mainloop.h>
-#include <dbus/dbus-internals.h>
-dbus_bool_t test_connection_setup (DBusLoop *loop,
+#include <dbus/dbus.h>
+
+#ifdef DBUS_TEST_USE_INTERNAL
+
+# include <dbus/dbus-mainloop.h>
+# include <dbus/dbus-internals.h>
+ typedef DBusLoop TestMainContext;
+
+#else /* !DBUS_TEST_USE_INTERNAL */
+
+# include <glib.h>
+ typedef GMainContext TestMainContext;
+
+#endif /* !DBUS_TEST_USE_INTERNAL */
+
+TestMainContext *test_main_context_get (void);
+TestMainContext *test_main_context_ref (TestMainContext *ctx);
+void test_main_context_unref (TestMainContext *ctx);
+void test_main_context_iterate (TestMainContext *ctx,
+ dbus_bool_t may_block);
+
+dbus_bool_t test_connection_setup (TestMainContext *ctx,
DBusConnection *connection);
-void test_connection_shutdown (DBusLoop *loop,
+void test_connection_shutdown (TestMainContext *ctx,
DBusConnection *connection);
-void test_connection_dispatch_all_messages (DBusConnection *connection);
-dbus_bool_t test_connection_dispatch_one_message (DBusConnection *connection);
-dbus_bool_t test_server_setup (DBusLoop *loop,
+dbus_bool_t test_server_setup (TestMainContext *ctx,
DBusServer *server);
-void test_server_shutdown (DBusLoop *loop,
+void test_server_shutdown (TestMainContext *ctx,
DBusServer *server);
#endif