aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-08-23 09:46:01 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-08-23 09:46:01 +0000
commit07c7b8b93fd757810cb083aeb3bc0dc5142d2994 (patch)
tree711a2b88db7be770155702cf7df0b9deb0e9131c /tests/tests.cpp
parent94bb4b3e8975371ca97a49ef4ff99d3c1da28cdb (diff)
downloadqxmpp-07c7b8b93fd757810cb083aeb3bc0dc5142d2994.tar.gz
test QXmppArchiveChatIq
Diffstat (limited to 'tests/tests.cpp')
-rw-r--r--tests/tests.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/tests.cpp b/tests/tests.cpp
index bbc8b286..21021409 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -125,6 +125,36 @@ void TestPackets::testArchiveList()
serializePacket(iq, xml);
}
+void TestPackets::testArchiveChat()
+{
+ const QByteArray xml(
+ "<iq id=\"chat_1\" type=\"result\">"
+ "<chat xmlns=\"urn:xmpp:archive\""
+ " with=\"juliet@capulet.com\""
+ " start=\"1469-07-21T02:56:15Z\""
+ " subject=\"She speaks!\""
+ " version=\"4\""
+ ">"
+ "<from secs=\"0\"><body>Art thou not Romeo, and a Montague?</body></from>"
+ "<to secs=\"11\"><body>Neither, fair saint, if either thee dislike.</body></to>"
+ "</chat>"
+ "</iq>");
+
+ QXmppArchiveChatIq iq;
+ parsePacket(iq, xml);
+ QCOMPARE(iq.type(), QXmppIq::Result);
+ QCOMPARE(iq.id(), QLatin1String("chat_1"));
+ QCOMPARE(iq.chat().with(), QLatin1String("juliet@capulet.com"));
+ QCOMPARE(iq.chat().messages().size(), 2);
+ QCOMPARE(iq.chat().messages()[0].isReceived(), true);
+ QCOMPARE(iq.chat().messages()[0].body(), QLatin1String("Art thou not Romeo, and a Montague?"));
+ QCOMPARE(iq.chat().messages()[0].date(), QDateTime(QDate(1469, 7, 21), QTime(2, 56, 15), Qt::UTC));
+ QCOMPARE(iq.chat().messages()[1].isReceived(), false);
+ QCOMPARE(iq.chat().messages()[1].date(), QDateTime(QDate(1469, 7, 21), QTime(2, 56, 26), Qt::UTC));
+ QCOMPARE(iq.chat().messages()[1].body(), QLatin1String("Neither, fair saint, if either thee dislike."));
+ serializePacket(iq, xml);
+}
+
void TestPackets::testArchiveRetrieve()
{
const QByteArray xml(