libnm/tests: add nmtstc_nm_client_new()
authorThomas Haller <thaller@redhat.com>
Tue, 22 Dec 2015 12:53:20 +0000 (13:53 +0100)
committerThomas Haller <thaller@redhat.com>
Sat, 26 Dec 2015 15:43:49 +0000 (16:43 +0100)
shared/nm-test-libnm-utils.h
shared/nm-test-utils-impl.c

index 290feea..e1aad36 100644 (file)
@@ -64,3 +64,11 @@ NMDevice * nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo,
 
 #endif /* NM_NETWORKMANAGER_COMPILATION_LIB */
 
+#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+
+#include "nm-client.h"
+
+NMClient *nmtstc_nm_client_new (void);
+
+#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
+
index dac07b9..1f73cb3 100644 (file)
@@ -236,3 +236,38 @@ nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo, NMClient *client,
 }
 
 #endif /* NM_NETWORKMANAGER_COMPILATION_LIB */
+
+/*****************************************************************************/
+
+#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+
+NMClient *
+nmtstc_nm_client_new (void)
+{
+       NMClient *client;
+       DBusGConnection *bus;
+       GError *error = NULL;
+       gboolean success;
+
+       bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+       g_assert_no_error (error);
+       g_assert (bus);
+
+       client = g_object_new (NM_TYPE_CLIENT,
+                              NM_OBJECT_DBUS_CONNECTION, bus,
+                              NM_OBJECT_DBUS_PATH, NM_DBUS_PATH,
+                              NULL);
+       g_assert (client != NULL);
+
+       dbus_g_connection_unref (bus);
+
+       success = g_initable_init (G_INITABLE (client), NULL, &error);
+       g_assert_no_error (error);
+       g_assert (success == TRUE);
+
+       return client;
+}
+
+#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
+
+/*****************************************************************************/