summaryrefslogtreecommitdiff
path: root/tests/message.c
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2013-02-22 00:09:04 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2013-04-14 11:53:40 +0100
commiteb6aea91d8e88c573652a9f03709928969a64498 (patch)
tree82dc901f7e447b8ca3fa269444cf90c5b5b9119d /tests/message.c
parent66982e6c17691869aa17c00416d61674b5b3e34f (diff)
downloadtelepathy-glib-eb6aea91d8e88c573652a9f03709928969a64498.tar.gz
Always flag delivery reports with Non_Text_Content
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=61254
Diffstat (limited to 'tests/message.c')
-rw-r--r--tests/message.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/message.c b/tests/message.c
new file mode 100644
index 000000000..4fc08a997
--- /dev/null
+++ b/tests/message.c
@@ -0,0 +1,70 @@
+/* Tests of TpMessage
+ *
+ * Copyright © 2013 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * Copying and distribution of this file, with or without modification,
+ * are permitted in any medium without royalty provided the copyright
+ * notice and this notice are preserved.
+ */
+
+#include "tests/lib/util.h"
+
+static void
+test_delivery_report_with_body (void)
+{
+ TpMessage *message = tp_client_message_new ();
+ guint i;
+ gchar *text;
+ TpChannelTextMessageFlags flags;
+
+ g_test_bug ("61254");
+
+ tp_message_set_uint32 (message, 0, "message-type",
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_DELIVERY_REPORT);
+ tp_message_set_uint32 (message, 0, "delivery-status",
+ TP_DELIVERY_STATUS_PERMANENTLY_FAILED);
+
+ /* message from server (alternative in English) */
+ i = tp_message_append_part (message);
+ tp_message_set_string (message, i, "alternative", "404");
+ tp_message_set_string (message, i, "content-type", "text/plain");
+ tp_message_set_string (message, i, "lang", "en");
+ tp_message_set_string (message, i, "content",
+ "I have no contact with that name");
+
+ /* message from server (alternative in German) */
+ i = tp_message_append_part (message);
+ tp_message_set_string (message, i, "alternative", "404");
+ tp_message_set_string (message, i, "content-type", "text/plain");
+ tp_message_set_string (message, i, "lang", "de");
+ tp_message_set_string (message, i, "content",
+ "Ich habe keinen Kontakt mit diesem Namen");
+
+ text = tp_message_to_text (message, &flags);
+
+ g_assert (text != NULL);
+ /* tp_message_to_text should only pick one language, and it's arbitrarily the
+ * first. */
+ g_assert_cmpstr (text, ==, "I have no contact with that name");
+
+ /* This is a delivery report, so old clients should know that there's
+ * something more to the message than just a message.
+ */
+ g_assert_cmpuint (flags, ==, TP_CHANNEL_TEXT_MESSAGE_FLAG_NON_TEXT_CONTENT);
+
+ g_free (text);
+ g_object_unref (message);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ tp_tests_init (&argc, &argv);
+ g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
+
+ g_test_add_func ("/text-channel/delivery-report-with-body",
+ test_delivery_report_with_body);
+
+ return g_test_run ();
+}