[dconf/wip/reorg] dbus test: add function to initialise for testing



commit b9e39fc6812d06769bbeec491e6dc2b71d697599
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Jul 11 11:32:37 2012 -0400

    dbus test: add function to initialise for testing
    
    We were hardcoding g_type_init() in the D-Bus testcase because the GDBus
    backend depended on that happening.  That is not true for the libdbus-1
    backend, so split it out into a separate function implemeneted by the
    backend.

 engine/dconf-engine.h      |    2 ++
 gdbus/dconf-gdbus-filter.c |    8 ++++++++
 gdbus/dconf-gdbus-thread.c |    8 ++++++++
 tests/dbus.c               |    5 ++---
 4 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/engine/dconf-engine.h b/engine/dconf-engine.h
index 9335e02..0128f8b 100644
--- a/engine/dconf-engine.h
+++ b/engine/dconf-engine.h
@@ -39,6 +39,8 @@ typedef enum
 #define DCONF_ERROR (g_quark_from_static_string ("dconf error quark"))
 
 /* These functions need to be implemented by the client library */
+G_GNUC_INTERNAL
+void                    dconf_engine_dbus_init_for_testing              (void);
 
 /* Sends a D-Bus message.
  *
diff --git a/gdbus/dconf-gdbus-filter.c b/gdbus/dconf-gdbus-filter.c
index e074bce..e1447b1 100644
--- a/gdbus/dconf-gdbus-filter.c
+++ b/gdbus/dconf-gdbus-filter.c
@@ -301,3 +301,11 @@ dconf_engine_dbus_call_sync_func (GBusType             bus_type,
                                       bus_name, object_path, interface_name, method_name, parameters, reply_type,
                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
 }
+
+#ifndef PIC
+void
+dconf_engine_dbus_init_for_testing (void)
+{
+  g_type_init ();
+}
+#endif
diff --git a/gdbus/dconf-gdbus-thread.c b/gdbus/dconf-gdbus-thread.c
index 47bc6cb..e3d69d8 100644
--- a/gdbus/dconf-gdbus-thread.c
+++ b/gdbus/dconf-gdbus-thread.c
@@ -347,3 +347,11 @@ dconf_engine_dbus_call_sync_func (GBusType             bus_type,
   return g_dbus_connection_call_sync (connection, bus_name, object_path, interface_name, method_name,
                                       parameters, reply_type, G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
 }
+
+#ifndef PIC
+void
+dconf_engine_dbus_init_for_testing (void)
+{
+  g_type_init ();
+}
+#endif
diff --git a/tests/dbus.c b/tests/dbus.c
index 6b7f07b..d37ab02 100644
--- a/tests/dbus.c
+++ b/tests/dbus.c
@@ -403,11 +403,10 @@ main (int argc, char **argv)
 {
   g_test_init (&argc, &argv, NULL);
 
-  /* XXX should not need to do this here! */
-  g_type_init ();
-
   main_thread = g_thread_self ();
 
+  dconf_engine_dbus_init_for_testing ();
+
   /* test_creation_error absolutely must come first */
   g_test_add_func (DBUS_BACKEND "/creation/error", test_creation_error);
   g_test_add_func (DBUS_BACKEND "/sync-call/success", test_sync_call_success);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]