summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-08-09 15:21:57 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-08-09 15:21:57 +0100
commitc0574477865abe42479d50e9c1be174a75ce620f (patch)
tree2f1597d0ec7bfe995e73931135320dd53f300cc3
parent2348188a751fad97b356728479a01a9981a6438b (diff)
parent8a21c43636459138bac752ed87329ef086ba9bc8 (diff)
Merge branch 'gabble-0.18'
-rw-r--r--docs/reference/wocky-docs.sgml22
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/wocky-connector-test.c13
-rw-r--r--tests/wocky-dummy-xmpp-server.c4
-rw-r--r--tests/wocky-porter-test.c2
-rw-r--r--tests/wocky-test-helper.c16
-rw-r--r--tests/wocky-test-helper.h2
-rw-r--r--tests/wocky-test-sasl-auth-server.c6
-rw-r--r--tests/wocky-xmpp-reader-test.c43
9 files changed, 70 insertions, 40 deletions
diff --git a/docs/reference/wocky-docs.sgml b/docs/reference/wocky-docs.sgml
index c96d710..922e096 100644
--- a/docs/reference/wocky-docs.sgml
+++ b/docs/reference/wocky-docs.sgml
@@ -62,17 +62,17 @@
<xi:include href="xml/wocky-xmpp-reader.xml"/>
<xi:include href="xml/wocky-xmpp-writer.xml"/>
- <xi:include href="xml/jingle-content.xml"/>
- <xi:include href="xml/jingle-factory.xml"/>
- <xi:include href="xml/jingle-info-internal.xml"/>
- <xi:include href="xml/jingle-info.xml"/>
- <xi:include href="xml/jingle-media-rtp.xml"/>
- <xi:include href="xml/jingle-session.xml"/>
- <xi:include href="xml/jingle-transport-google.xml"/>
- <xi:include href="xml/jingle-transport-iceudp.xml"/>
- <xi:include href="xml/jingle-transport-iface.xml"/>
- <xi:include href="xml/jingle-transport-rawudp.xml"/>
- <xi:include href="xml/jingle-types.xml"/>
+ <xi:include href="xml/wocky-jingle-content.xml"/>
+ <xi:include href="xml/wocky-jingle-factory.xml"/>
+ <xi:include href="xml/wocky-jingle-info-internal.xml"/>
+ <xi:include href="xml/wocky-jingle-info.xml"/>
+ <xi:include href="xml/wocky-jingle-media-rtp.xml"/>
+ <xi:include href="xml/wocky-jingle-session.xml"/>
+ <xi:include href="xml/wocky-jingle-transport-google.xml"/>
+ <xi:include href="xml/wocky-jingle-transport-iceudp.xml"/>
+ <xi:include href="xml/wocky-jingle-transport-iface.xml"/>
+ <xi:include href="xml/wocky-jingle-transport-rawudp.xml"/>
+ <xi:include href="xml/wocky-jingle-types.xml"/>
</chapter>
<chapter id="object-tree">
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c4112cb..43578fa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -125,6 +125,8 @@ wocky_data_form_test_SOURCES = \
wocky_dummy_xmpp_server_DEPENDENCIES = $(LIBWOCKY)
wocky_dummy_xmpp_server_SOURCES = wocky-dummy-xmpp-server.c \
wocky-test-connector-server.c wocky-test-connector-server.h \
+ wocky-test-helper.c wocky-test-helper.h \
+ wocky-test-stream.c wocky-test-stream.h \
wocky-test-sasl-auth-server.c wocky-test-sasl-auth-server.h
wocky_dummy_xmpp_server_LDADD = $(LDADD) @LIBSASL2_LIBS@
wocky_dummy_xmpp_server_CFLAGS = $(AM_CFLAGS) @LIBSASL2_CFLAGS@ $(TLSDEFS)
diff --git a/tests/wocky-connector-test.c b/tests/wocky-connector-test.c
index 2bd575e..e2622b4 100644
--- a/tests/wocky-connector-test.c
+++ b/tests/wocky-connector-test.c
@@ -3259,11 +3259,6 @@ client_connected (GIOChannel *channel,
int csock = accept (ssock, (struct sockaddr *) &client, &clen);
GSocket *gsock = g_socket_new_from_fd (csock, NULL);
ConnectorProblem *cproblem = &srv->problem.conn;
-#ifdef G_OS_WIN32
- u_long mode = 0;
-#else
- long flags;
-#endif
GSocketConnection *gconn;
@@ -3277,14 +3272,6 @@ client_connected (GIOChannel *channel,
if (!srv->features.tls)
cproblem->xmpp |= XMPP_PROBLEM_NO_TLS;
-#ifdef G_OS_WIN32
- WSAEventSelect (csock, 0, 0);
- ioctlsocket (csock, FIONBIO, &mode);
-#else
- flags = fcntl (csock, F_GETFL );
- flags = flags & ~O_NONBLOCK;
- fcntl (csock, F_SETFL, flags);
-#endif
gconn = g_object_new (G_TYPE_SOCKET_CONNECTION, "socket", gsock, NULL);
g_object_unref (gsock);
diff --git a/tests/wocky-dummy-xmpp-server.c b/tests/wocky-dummy-xmpp-server.c
index be947b0..c1ffe1a 100644
--- a/tests/wocky-dummy-xmpp-server.c
+++ b/tests/wocky-dummy-xmpp-server.c
@@ -40,7 +40,6 @@ client_connected (GIOChannel *channel,
GSocketConnection *gconn;
pid_t pid = 0;
TestConnectorServer *server;
- long flags;
if (csock < 0)
{
@@ -58,9 +57,6 @@ client_connected (GIOChannel *channel,
case 0:
while (g_source_remove_by_user_data (loop));
g_io_channel_shutdown (channel, TRUE, NULL);
- flags = fcntl (csock, F_GETFL );
- flags = flags & ~O_NONBLOCK;
- fcntl (csock, F_SETFL, flags);
gconn = g_object_new (G_TYPE_SOCKET_CONNECTION, "socket", gsock, NULL);
server = test_connector_server_new (G_IO_STREAM (gconn),
NULL, "foo", "bar", "1.0",
diff --git a/tests/wocky-porter-test.c b/tests/wocky-porter-test.c
index abcd5c3..d36bc00 100644
--- a/tests/wocky-porter-test.c
+++ b/tests/wocky-porter-test.c
@@ -1190,7 +1190,7 @@ test_cancel_sent_stanza_cb (WockyPorter *porter,
test_data_t *test = (test_data_t *) user_data;
test_expected_stanza_received (test, stanza);
- g_cancellable_cancel (test->cancellable);
+ test_cancel_in_idle (test->cancellable);
return TRUE;
}
diff --git a/tests/wocky-test-helper.c b/tests/wocky-test-helper.c
index d2b262e..f7148e5 100644
--- a/tests/wocky-test-helper.c
+++ b/tests/wocky-test-helper.c
@@ -305,3 +305,19 @@ test_deinit (void)
{
wocky_deinit ();
}
+
+static gboolean
+cancel_in_idle_cb (gpointer cancellable)
+{
+ g_cancellable_cancel (cancellable);
+ return FALSE;
+}
+
+void
+test_cancel_in_idle (GCancellable *cancellable)
+{
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ cancel_in_idle_cb,
+ g_object_ref (cancellable),
+ g_object_unref);
+}
diff --git a/tests/wocky-test-helper.h b/tests/wocky-test-helper.h
index 4c9b25c..3810985 100644
--- a/tests/wocky-test-helper.h
+++ b/tests/wocky-test-helper.h
@@ -45,6 +45,8 @@ void test_expected_stanza_received (test_data_t *test,
void test_close_both_porters (test_data_t *test);
+void test_cancel_in_idle (GCancellable *cancellable);
+
#define test_assert_nodes_equal(n1, n2) \
G_STMT_START { \
if (!wocky_node_equal ((n1), (n2))) \
diff --git a/tests/wocky-test-sasl-auth-server.c b/tests/wocky-test-sasl-auth-server.c
index b5b4c76..35c8328 100644
--- a/tests/wocky-test-sasl-auth-server.c
+++ b/tests/wocky-test-sasl-auth-server.c
@@ -30,7 +30,7 @@
#include <gio/gio.h>
#include "wocky-test-sasl-auth-server.h"
-
+#include "wocky-test-helper.h"
#ifdef HAVE_LIBSASL2
@@ -988,9 +988,7 @@ test_sasl_auth_server_stop (TestSaslAuthServer *self)
if (priv->cancellable != NULL)
{
- if (!g_cancellable_is_cancelled (priv->cancellable))
- g_cancellable_cancel (priv->cancellable);
-
+ test_cancel_in_idle (priv->cancellable);
g_object_unref (priv->cancellable);
priv->cancellable = NULL;
}
diff --git a/tests/wocky-xmpp-reader-test.c b/tests/wocky-xmpp-reader-test.c
index 610de0f..dcff2bc 100644
--- a/tests/wocky-xmpp-reader-test.c
+++ b/tests/wocky-xmpp-reader-test.c
@@ -94,12 +94,17 @@
" <body>" WHITESPACE_ONLY_BODY "</body>" \
" </message>"
-#define NON_CHARACTER_CODEPOINTS_REPLACEMENT "�🙈�"
+#define U_FDEF "\xe7\xb7\xaf" /* a non-character */
+#define REPLACE "\xef\xbf\xbd" /* U+FFFD REPLACEMENT CHARACTER */
+#define MONKEY "\xf0\x9f\x99\x88" /* U+1F648 SEE-NO-EVIL MONKEY */
+
+#define NON_CHARACTER_CODEPOINTS U_FDEF MONKEY U_FDEF
+#define NON_CHARACTER_CODEPOINTS_REPLACEMENT REPLACE MONKEY REPLACE
#define MESSAGE_WITH_NON_CHARACTER_CODEPOINTS \
" <message to='morse@thamesvalley.police.uk' " \
" from='lewis@thamesvalley.police.uk'> " \
-" <body>\xef\xb7\xaf🙈\xef\xb7\xaf</body>" \
+" <body>" NON_CHARACTER_CODEPOINTS "</body>" \
" </message>"
@@ -336,9 +341,10 @@ test_invalid_namespace (void)
/* Helper function for the whitespace body tests */
static void
-test_body (
+test_body_with_alternative (
const gchar *xml,
- const gchar *expected_body_text)
+ const gchar *expected_body_text,
+ const gchar *alt_body_text)
{
WockyXmppReader *reader = wocky_xmpp_reader_new_no_stream ();
WockyStanza *stanza;
@@ -353,12 +359,32 @@ test_body (
g_assert (body != NULL);
g_assert (g_utf8_validate (body->content, -1, NULL));
- g_assert_cmpstr (body->content, ==, expected_body_text);
+
+ if (alt_body_text == NULL)
+ {
+ g_assert_cmpstr (body->content, ==, expected_body_text);
+ }
+ else
+ {
+ if (wocky_strdiff (body->content, expected_body_text) &&
+ wocky_strdiff (body->content, alt_body_text))
+ {
+ g_error ("Body text «%s» was neither «%s» nor «%s»",
+ body->content, expected_body_text, alt_body_text);
+ }
+ }
g_object_unref (stanza);
g_object_unref (reader);
}
+static void
+test_body (const gchar *xml,
+ const gchar *exp)
+{
+ test_body_with_alternative (xml, exp, NULL);
+}
+
/* Test that whitespace around the text contents of a message isn't ignored */
static void
test_whitespace_padding (void)
@@ -373,11 +399,14 @@ test_whitespace_only (void)
test_body (MESSAGE_WITH_WHITESPACE_ONLY_BODY, WHITESPACE_ONLY_BODY);
}
-/* Test that a message body consisting entirely of whitespace isn't ignored */
+/* Test that a message body containing non-character codepoints is
+ * handled "appropriately". Older GLib replaces them with U+FFFD,
+ * newer GLib keeps them as-is. */
static void
test_non_character_codepoints (void)
{
- test_body (MESSAGE_WITH_NON_CHARACTER_CODEPOINTS,
+ test_body_with_alternative (MESSAGE_WITH_NON_CHARACTER_CODEPOINTS,
+ NON_CHARACTER_CODEPOINTS,
NON_CHARACTER_CODEPOINTS_REPLACEMENT);
}