aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2020-04-05 12:48:58 +0200
committerLNJ <lnj@kaidan.im>2020-04-05 13:07:31 +0200
commit420fddae862b0f67e7d8fe712006525c0239154e (patch)
tree8293c6b0cda42f6cc4fd57b6b79de4bb316180ee /tests
parent2197c188f21d563a192be711d13db7d0d1600681 (diff)
downloadqxmpp-420fddae862b0f67e7d8fe712006525c0239154e.tar.gz
QXmppMessage: Add parent thread attribute from RFC6121
The 'parent' attribute for <thread/> element in messages has been introduced in RFC6121. This commit adds parsing and serialization for it, including unit tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/qxmppmessage/tst_qxmppmessage.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/tests/qxmppmessage/tst_qxmppmessage.cpp b/tests/qxmppmessage/tst_qxmppmessage.cpp
index bfd4daec..e9596799 100644
--- a/tests/qxmppmessage/tst_qxmppmessage.cpp
+++ b/tests/qxmppmessage/tst_qxmppmessage.cpp
@@ -72,38 +72,52 @@ void tst_QXmppMessage::testBasic_data()
QTest::addColumn<QString>("body");
QTest::addColumn<QString>("subject");
QTest::addColumn<QString>("thread");
+ QTest::addColumn<QString>("parentThread");
QTest::newRow("error")
<< QByteArray(R"(<message to="foo@example.com/QXmpp" from="bar@example.com/QXmpp" type="error"/>)")
<< int(QXmppMessage::Error)
- << QString() << QString() << QString();
+ << QString() << QString() << QString() << QString();
QTest::newRow("normal")
<< QByteArray(R"(<message to="foo@example.com/QXmpp" from="bar@example.com/QXmpp" type="normal"/>)")
<< int(QXmppMessage::Normal)
- << QString() << QString() << QString();
+ << QString() << QString() << QString() << QString();
QTest::newRow("chat")
<< QByteArray(R"(<message to="foo@example.com/QXmpp" from="bar@example.com/QXmpp" type="chat"/>)")
<< int(QXmppMessage::Chat)
- << QString() << QString() << QString();
+ << QString() << QString() << QString() << QString();
QTest::newRow("groupchat")
<< QByteArray(R"(<message to="foo@example.com/QXmpp" from="bar@example.com/QXmpp" type="groupchat"/>)")
<< int(QXmppMessage::GroupChat)
- << QString() << QString() << QString();
+ << QString() << QString() << QString() << QString();
QTest::newRow("headline")
<< QByteArray(R"(<message to="foo@example.com/QXmpp" from="bar@example.com/QXmpp" type="headline"/>)")
<< int(QXmppMessage::Headline)
- << QString() << QString() << QString();
+ << QString() << QString() << QString() << QString();
+
+ QTest::newRow("no-parent-thread")
+ << QByteArray("<message to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"normal\">"
+ "<subject>test subject</subject>"
+ "<body>test body &amp; stuff</body>"
+ "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
+ "</message>")
+ << int(QXmppMessage::Normal)
+ << "test body & stuff"
+ << "test subject"
+ << "0e3141cd80894871a68e6fe6b1ec56fa"
+ << QString();
QTest::newRow("full")
<< QByteArray("<message to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"normal\">"
"<subject>test subject</subject>"
"<body>test body &amp; stuff</body>"
- "<thread>test thread</thread>"
+ "<thread parent=\"e0ffe42b28561960c6b12b944a092794b9683a38\">0e3141cd80894871a68e6fe6b1ec56fa</thread>"
"</message>")
<< int(QXmppMessage::Normal)
<< "test body & stuff"
<< "test subject"
- << "test thread";
+ << "0e3141cd80894871a68e6fe6b1ec56fa"
+ << "e0ffe42b28561960c6b12b944a092794b9683a38";
}
void tst_QXmppMessage::testBasic()
@@ -113,6 +127,7 @@ void tst_QXmppMessage::testBasic()
QFETCH(QString, body);
QFETCH(QString, subject);
QFETCH(QString, thread);
+ QFETCH(QString, parentThread);
QXmppMessage message;
parsePacket(message, xml);
@@ -123,6 +138,7 @@ void tst_QXmppMessage::testBasic()
QCOMPARE(message.body(), body);
QCOMPARE(message.subject(), subject);
QCOMPARE(message.thread(), thread);
+ QCOMPARE(message.parentThread(), parentThread);
QCOMPARE(message.state(), QXmppMessage::None);
QCOMPARE(message.isAttentionRequested(), false);
QCOMPARE(message.isReceiptRequested(), false);
@@ -147,6 +163,7 @@ void tst_QXmppMessage::testBasic()
message.setBody(body);
message.setSubject(subject);
message.setThread(thread);
+ message.setParentThread(parentThread);
serializePacket(message, xml);
}