return id;
}
+static void connman_died(DBusConnection *connection, void *user_data)
+{
+ g_assert(FALSE);
+}
+
guint util_call(struct test_fix *fix, GSourceFunc func,
GDestroyNotify notify)
{
fix->main_loop = g_main_loop_new(NULL, FALSE);
fix->main_connection = g_dbus_setup_private(DBUS_BUS_SYSTEM,
NULL, NULL);
+ fix->watch = g_dbus_add_service_watch(fix->main_connection,
+ CONNMAN_SERVICE,
+ NULL,
+ connman_died,
+ NULL, NULL);
}
void util_teardown(struct test_fix *fix, gconstpointer data)
{
+ g_dbus_remove_watch(fix->main_connection, fix->watch);
dbus_connection_close(fix->main_connection);
dbus_connection_unref(fix->main_connection);
g_free(fix->session);
}
+
+void util_session_init(struct test_session *session)
+{
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ const char *path;
+ int err;
+
+ err = session_notify_register(session, session->notify_path);
+ g_assert(err == 0);
+
+ msg = manager_create_session(session->connection,
+ session->info,
+ session->notify_path);
+ g_assert(msg != NULL);
+ dbus_message_iter_init(msg, &iter);
+
+ dbus_message_iter_get_basic(&iter, &path);
+ session->session_path = g_strdup(path);
+
+ dbus_message_unref(msg);
+}
+
+void util_session_cleanup(struct test_session *session)
+{
+ DBusMessage *msg;
+ int err;
+
+ msg = manager_destroy_session(session->connection,
+ session->session_path);
+ g_assert(msg != NULL);
+ dbus_message_unref(msg);
+
+ err = session_notify_unregister(session,
+ session->notify_path);
+ g_assert(err == 0);
+
+ g_free(session->info->bearer);
+ g_free(session->info->name);
+ g_free(session->info->interface);
+ g_slist_foreach(session->info->allowed_bearers,
+ bearer_info_cleanup, NULL);
+ g_slist_free(session->info->allowed_bearers);
+
+ session->notify = NULL;
+ g_free(session->notify_path);
+ g_free(session->session_path);
+}