aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2019-04-27 20:14:57 +0100
committerJeremy Lainé <jeremy.laine@m4x.org>2019-05-04 13:40:44 +0200
commitcaeb6f2608ab0f6e769fb93fef14658bfe165378 (patch)
treeeab9704b81495a29eea09100db8b0fccadd31e34 /tests
parent537e325e2d44e696993b78ae2b8dd8437433c2b9 (diff)
downloadqxmpp-caeb6f2608ab0f6e769fb93fef14658bfe165378.tar.gz
Implement XEP-0382: Spoiler messages (v0.2.0)
This adds parsing and serialization of spoilers in the QXmppMessage class.
Diffstat (limited to 'tests')
-rw-r--r--tests/qxmppmessage/tst_qxmppmessage.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/qxmppmessage/tst_qxmppmessage.cpp b/tests/qxmppmessage/tst_qxmppmessage.cpp
index c026ad86..9e8786d6 100644
--- a/tests/qxmppmessage/tst_qxmppmessage.cpp
+++ b/tests/qxmppmessage/tst_qxmppmessage.cpp
@@ -49,6 +49,7 @@ private slots:
void testOutOfBandUrl();
void testMessageCorrect();
void testMix();
+ void testSpoiler();
};
void tst_QXmppMessage::testBasic_data()
@@ -112,6 +113,7 @@ void tst_QXmppMessage::testBasic()
QCOMPARE(message.isReceiptRequested(), false);
QCOMPARE(message.receiptId(), QString());
QCOMPARE(message.xhtml(), QString());
+ QVERIFY(!message.isSpoiler());
serializePacket(message, xml);
}
@@ -643,5 +645,44 @@ void tst_QXmppMessage::testMix()
QCOMPARE(message.mixUserNick(), QString("erik"));
}
+void tst_QXmppMessage::testSpoiler()
+{
+ // test parsing with hint
+ const QByteArray xmlWithHint(
+ "<message to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"normal\">"
+ "<body>And at the end of the story, both of them die! It is so tragic!</body>"
+ "<spoiler xmlns=\"urn:xmpp:spoiler:0\">Love story end</spoiler>"
+ "</message>");
+
+ QXmppMessage messageWithHint;
+ parsePacket(messageWithHint, xmlWithHint);
+ QVERIFY(messageWithHint.isSpoiler());
+ QCOMPARE(messageWithHint.spoilerHint(), QString("Love story end"));
+ serializePacket(messageWithHint, xmlWithHint);
+
+ // test parsing without hint
+ const QByteArray xmlWithoutHint(
+ "<message to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"normal\">"
+ "<body>And at the end of the story, both of them die! It is so tragic!</body>"
+ "<spoiler xmlns=\"urn:xmpp:spoiler:0\"></spoiler>"
+ "</message>");
+
+ QXmppMessage messageWithoutHint;
+ parsePacket(messageWithoutHint, xmlWithoutHint);
+ QVERIFY(messageWithoutHint.isSpoiler());
+ QCOMPARE(messageWithoutHint.spoilerHint(), QString(""));
+ serializePacket(messageWithoutHint, xmlWithoutHint);
+
+ // test setters
+ QXmppMessage message;
+ message.setIsSpoiler(true);
+ QVERIFY(message.isSpoiler());
+
+ message.setIsSpoiler(false);
+ message.setSpoilerHint("test hint");
+ QCOMPARE(message.spoilerHint(), QString("test hint"));
+ QVERIFY(message.isSpoiler());
+}
+
QTEST_MAIN(tst_QXmppMessage)
#include "tst_qxmppmessage.moc"