summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2010-10-07 19:10:09 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2010-10-08 17:48:39 -0400
commitbb167324fb0a1c9b21b7a7d7d1146ca8753c0d65 (patch)
tree6c5013f3c59c717b7f1fac10901d806982af71ae /tests
parent7e22acb544bffb4bae9fd13da72e20f3f438d87d (diff)
Add explicit _stop() to test SASL auth server
The test SASL auth server did not have a _stop() method. As the call to new() starts an infinit async call on internal XmppConnection, the Xmpp Connection get leaked. Adding an explici _stop(), fixes this issue.
Diffstat (limited to 'tests')
-rw-r--r--tests/wocky-test-sasl-auth-server.c29
-rw-r--r--tests/wocky-test-sasl-auth-server.h2
-rw-r--r--tests/wocky-test-sasl-auth.c2
3 files changed, 28 insertions, 5 deletions
diff --git a/tests/wocky-test-sasl-auth-server.c b/tests/wocky-test-sasl-auth-server.c
index 9fd26f2..c035269 100644
--- a/tests/wocky-test-sasl-auth-server.c
+++ b/tests/wocky-test-sasl-auth-server.c
@@ -949,13 +949,34 @@ test_sasl_auth_server_new (GIOStream *stream, gchar *mech,
{
priv->stream = g_object_ref (stream);
priv->conn = wocky_xmpp_connection_new (stream);
+ priv->cancellable = g_cancellable_new ();
wocky_xmpp_connection_recv_open_async (priv->conn,
- NULL, stream_open_received, server);
+ priv->cancellable, stream_open_received, server);
}
return server;
}
+void
+test_sasl_auth_server_stop (TestSaslAuthServer *self)
+{
+ TestSaslAuthServerPrivate *priv = self->priv;
+
+ if (priv->cancellable != NULL)
+ {
+ if (!g_cancellable_is_cancelled (priv->cancellable))
+ {
+ g_cancellable_cancel (priv->cancellable);
+ }
+ g_object_unref (priv->cancellable);
+ priv->cancellable = NULL;
+ }
+
+ if (priv->conn)
+ g_object_unref (priv->conn);
+ priv->conn = NULL;
+}
+
gboolean
test_sasl_auth_server_auth_finish (TestSaslAuthServer *self,
GAsyncResult *res,
@@ -987,10 +1008,8 @@ test_sasl_auth_server_auth_async (GObject *obj,
TestSaslAuthServer *self = TEST_SASL_AUTH_SERVER (obj);
TestSaslAuthServerPrivate *priv = self->priv;
- /* we would normally expect this to be NULL in a take-over situation,
- but just in case: */
- if (priv->conn != NULL)
- g_object_unref (priv->conn);
+ /* We expect the server to not be started but just in case */
+ test_sasl_auth_server_stop (TEST_SASL_AUTH_SERVER (obj));
priv->state = AUTH_STATE_STARTED;
priv->conn = g_object_ref (conn);
diff --git a/tests/wocky-test-sasl-auth-server.h b/tests/wocky-test-sasl-auth-server.h
index 86e506a..e2fe0b9 100644
--- a/tests/wocky-test-sasl-auth-server.h
+++ b/tests/wocky-test-sasl-auth-server.h
@@ -97,6 +97,8 @@ TestSaslAuthServer * test_sasl_auth_server_new (GIOStream *stream,
gchar *mech, const gchar *user, const gchar *password,
const gchar *servername, ServerProblem problem, gboolean start);
+void test_sasl_auth_server_stop (TestSaslAuthServer *self);
+
gint test_sasl_auth_server_set_mechs (GObject *obj, WockyStanza *feat);
G_END_DECLS
diff --git a/tests/wocky-test-sasl-auth.c b/tests/wocky-test-sasl-auth.c
index a461fad..8629172 100644
--- a/tests/wocky-test-sasl-auth.c
+++ b/tests/wocky-test-sasl-auth.c
@@ -232,6 +232,8 @@ run_test (gconstpointer user_data)
sasl = NULL;
}
+ test_sasl_auth_server_stop (server);
+
g_object_unref (server);
g_object_unref (stream);
g_object_unref (conn);