summaryrefslogtreecommitdiff
path: root/unit
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-08-11 16:56:17 +0200
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2011-08-11 17:40:52 +0200
commitef0ff3328fa0e951647ec187b2085671ab83b553 (patch)
treecde0d7fc500da649db0024dd93a99620e59792fa /unit
parent9d9d2dddec25496155baf2238b4ce876ff05406c (diff)
downloadconnman-ef0ff3328fa0e951647ec187b2085671ab83b553.tar.gz
connman-ef0ff3328fa0e951647ec187b2085671ab83b553.tar.bz2
connman-ef0ff3328fa0e951647ec187b2085671ab83b553.zip
unit: Add manager state callback
Diffstat (limited to 'unit')
-rw-r--r--unit/test-connman.h1
-rw-r--r--unit/test-session.c33
-rw-r--r--unit/utils.c3
3 files changed, 34 insertions, 3 deletions
diff --git a/unit/test-connman.h b/unit/test-connman.h
index 0d9da930..5602daa1 100644
--- a/unit/test-connman.h
+++ b/unit/test-connman.h
@@ -40,6 +40,7 @@ struct test_fix {
guint manager_watch;
struct test_manager manager;
+ GSourceFunc manager_changed;
/* session test cases */
unsigned int max_sessions;
diff --git a/unit/test-session.c b/unit/test-session.c
index c626e045..3431cea7 100644
--- a/unit/test-session.c
+++ b/unit/test-session.c
@@ -216,8 +216,6 @@ static void set_session_mode(struct test_fix *fix,
g_assert(dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_ERROR);
dbus_message_unref(msg);
-
- util_idle_call(fix, util_quit_loop, NULL);
}
static void test_session_connect_notify(struct test_session *session)
@@ -445,12 +443,35 @@ static gboolean test_session_connect_free_ride(gpointer data)
return FALSE;
}
+static connman_bool_t is_online(struct test_fix *fix)
+{
+ if (g_strcmp0(fix->manager.state, "online") == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
static gboolean enable_session_mode(gpointer data)
{
struct test_fix *fix = data;
set_session_mode(fix, TRUE);
+ if (is_online(fix) == FALSE)
+ util_idle_call(fix, util_quit_loop, NULL);
+
+ return FALSE;
+}
+
+static gboolean manager_state_changed(gpointer data)
+{
+ struct test_fix *fix = data;
+
+ if (is_online(fix) == FALSE) {
+ fix->manager_changed = NULL;
+ util_idle_call(fix, util_quit_loop, NULL);
+ }
+
return FALSE;
}
@@ -465,15 +486,21 @@ static gboolean disable_session_mode(gpointer data)
static void setup_cb(struct test_fix *fix, gconstpointer data)
{
- util_setup(fix, data);
+ fix->manager_changed = manager_state_changed;
+ util_setup(fix, data);
util_call(fix, enable_session_mode, NULL);
+
g_main_loop_run(fix->main_loop);
+
+ fix->manager_changed = NULL;
}
static void teardown_cb(struct test_fix *fix, gconstpointer data)
{
util_call(fix, disable_session_mode, NULL);
+ util_idle_call(fix, util_quit_loop, NULL);
+
g_main_loop_run(fix->main_loop);
util_teardown(fix, data);
diff --git a/unit/utils.c b/unit/utils.c
index 96644631..6ff1c710 100644
--- a/unit/utils.c
+++ b/unit/utils.c
@@ -91,6 +91,9 @@ static void manager_changed(struct test_fix *fix,
fix->manager.state = g_strdup(value);
}
+
+ if (fix->manager_changed != NULL)
+ fix->manager_changed(fix);
}
static gboolean handle_manager_changed(DBusConnection *connection,