libnm/tests: add nmtstc_nm_client_new()

This commit is contained in:
Thomas Haller 2015-12-22 13:53:20 +01:00
parent bdfcf02da3
commit 56880fbe69
2 changed files with 43 additions and 0 deletions

View 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 */

View 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 */
/*****************************************************************************/