unit: Add create already exists test case
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 7 Jun 2011 13:42:22 +0000 (15:42 +0200)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 7 Jun 2011 13:42:57 +0000 (15:42 +0200)
unit/test-session.c

index a2bd372..2c993f3 100644 (file)
@@ -138,6 +138,34 @@ static gboolean test_session_create_destroy(gpointer data)
        return FALSE;
 }
 
+static gboolean test_session_create_already_exists(gpointer data)
+{
+       struct test_fix *fix = data;
+       struct test_session *session0, *session1;
+       DBusMessage *msg;
+
+       util_session_create(fix, 2);
+       session0 = &fix->session[0];
+       session1 = &fix->session[1];
+
+       session0->notify_path = g_strdup("/foo");
+       session1->notify_path = session0->notify_path;
+
+       util_session_init(session0);
+
+       msg = manager_create_session(session1->connection,
+                                       session1->info,
+                                       session1->notify_path);
+       g_assert(msg == NULL);
+
+       util_session_cleanup(session0);
+
+       g_assert(is_connman_running(session0->connection) == TRUE);
+       util_idle_call(fix, util_quit_loop, util_session_destroy);
+
+       return FALSE;
+}
+
 static void set_session_mode(struct test_fix *fix,
                                        connman_bool_t enable)
 {
@@ -198,6 +226,8 @@ int main(int argc, char *argv[])
                test_session_create, setup_cb, teardown_cb);
        util_test_add("/manager/session create destroy",
                test_session_create_destroy, setup_cb, teardown_cb);
+       util_test_add("/manager/session create already exists",
+               test_session_create_already_exists, setup_cb, teardown_cb);
 
        return g_test_run();
 }