summaryrefslogtreecommitdiff
path: root/libnm-glib
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-27 04:54:13 +0200
committerThomas Haller <thaller@redhat.com>2014-08-01 13:07:38 +0200
commit1de6d83e29b43ece726f49b43aeb632543aa42be (patch)
treee72d05d548287d8b560adba3ff4dacca96db7238 /libnm-glib
parentd6b3ef0819dde4e6bc514b815f6259f1eaffa150 (diff)
downloadNetworkManager-1de6d83e29b43ece726f49b43aeb632543aa42be.tar.gz
libnm-glib/test: add asserts to test-remote-settings-client
- register a weak references and ensure that the connection is removed when expected. - disconnect the vis_new_connection_cb() handler Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'libnm-glib')
-rw-r--r--libnm-glib/tests/test-remote-settings-client.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c
index 0019fc1c18..9246cbbc82 100644
--- a/libnm-glib/tests/test-remote-settings-client.c
+++ b/libnm-glib/tests/test-remote-settings-client.c
@@ -49,7 +49,7 @@ cleanup (void)
#define test_assert(condition) \
do { \
- gboolean _condition = ( condition ); \
+ gboolean _condition = !!( condition ); \
\
if (G_UNLIKELY (!_condition)) { \
cleanup (); \
@@ -70,6 +70,7 @@ add_cb (NMRemoteSettings *s,
*((gboolean *) user_data) = TRUE;
remote = connection;
+ g_object_add_weak_pointer (G_OBJECT (connection), (void **) &remote);
}
#define TEST_CON_ID "blahblahblah"
@@ -186,6 +187,7 @@ test_make_invisible (void)
} while ((done == FALSE) && (now - start < 5));
test_assert (done == TRUE);
+ g_assert (remote);
g_signal_handlers_disconnect_by_func (remote, G_CALLBACK (invis_removed_cb), &done);
/* Ensure NMRemoteSettings no longer has the connection */
@@ -198,6 +200,7 @@ test_make_invisible (void)
}
/* And ensure the invisible connection no longer has any settings */
+ g_assert (remote);
nm_connection_for_each_setting_value (NM_CONNECTION (remote),
invis_has_settings_cb,
&has_settings);
@@ -253,8 +256,11 @@ test_make_visible (void)
} while ((new == NULL) && (now - start < 5));
/* Ensure the new connection is the same as the one we made visible again */
+ test_assert (new);
test_assert (new == remote);
+ g_signal_handlers_disconnect_by_func (settings, G_CALLBACK (vis_new_connection_cb), &new);
+
/* Ensure NMRemoteSettings has the connection */
list = nm_remote_settings_list_connections (settings);
for (iter = list; iter; iter = g_slist_next (iter)) {
@@ -311,6 +317,8 @@ test_remove_connection (void)
test_assert (g_slist_length (list) > 0);
connection = NM_REMOTE_CONNECTION (list->data);
+ g_assert (connection);
+ g_assert (remote == connection);
path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection)));
g_signal_connect (connection, "removed", G_CALLBACK (removed_cb), &done);
@@ -330,6 +338,8 @@ test_remove_connection (void)
} while ((done == FALSE) && (now - start < 5));
test_assert (done == TRUE);
+ g_assert (!remote);
+
/* Ensure NMRemoteSettings no longer has the connection */
list = nm_remote_settings_list_connections (settings);
for (iter = list; iter; iter = g_slist_next (iter)) {