From 8d4d7d8f395714721f4137e89dd9dc320da0e2de Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 7 Jun 2011 15:42:22 +0200 Subject: unit: Add create session test Create a complete session, that is with proper notification object. --- unit/test-session.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'unit/test-session.c') diff --git a/unit/test-session.c b/unit/test-session.c index b129326f..91662dac 100644 --- a/unit/test-session.c +++ b/unit/test-session.c @@ -84,6 +84,41 @@ static gboolean test_session_destroy_no_notify(gpointer data) return FALSE; } +static void test_session_create_notify(struct test_session *session) +{ + LOG("session %p", session); + + g_assert(is_connman_running(session->connection) == TRUE); + util_idle_call(session->fix, util_quit_loop, util_session_destroy); +} + +static gboolean test_session_create(gpointer data) +{ + struct test_fix *fix = data; + struct test_session *session; + DBusMessage *msg; + int err; + + util_session_create(fix, 1); + session = fix->session; + + session->notify_path = "/foo"; + session->notify = test_session_create_notify; + + 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); + g_assert(dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_ERROR); + + dbus_message_unref(msg); + + return FALSE; +} + static void set_session_mode(struct test_fix *fix, connman_bool_t enable) { @@ -140,6 +175,8 @@ int main(int argc, char *argv[]) test_session_create_no_notify, setup_cb, teardown_cb); util_test_add("/manager/session destroy no notify", test_session_destroy_no_notify, setup_cb, teardown_cb); + util_test_add("/manager/session create", + test_session_create, setup_cb, teardown_cb); return g_test_run(); } -- cgit v1.2.3