aboutsummaryrefslogtreecommitdiff
path: root/tests/si.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-12 15:29:18 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-12 15:29:18 +0200
commitf9b26e12f593b185a15674e3ddda0b56d05b43c6 (patch)
tree503d1c15099cea55536d9fb8d8a98d7fef576fa8 /tests/si.cpp
parentc9b81bc66f2449fe4ca1d55259d6f70178f1a91d (diff)
downloadqxmpp-f9b26e12f593b185a15674e3ddda0b56d05b43c6.tar.gz
add/test QXmppTransferFileInfo parsing/serialisation
Diffstat (limited to 'tests/si.cpp')
-rw-r--r--tests/si.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/si.cpp b/tests/si.cpp
index 7a77f3ca..09e8cf42 100644
--- a/tests/si.cpp
+++ b/tests/si.cpp
@@ -23,10 +23,62 @@
*/
#include "QXmppStreamInitiationIq.h"
+#include "QXmppTransferManager.h"
#include "si.h"
#include "tests.h"
+void tst_QXmppStreamInitiationIq::testFileInfo_data()
+{
+ QTest::addColumn<QByteArray>("xml");
+ QTest::addColumn<QDateTime>("date");
+ QTest::addColumn<QString>("description");
+ QTest::addColumn<QByteArray>("hash");
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<qint64>("size");
+
+ QTest::newRow("normal")
+ << QByteArray("<file xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\" name=\"test.txt\" size=\"1022\"/>")
+ << QDateTime()
+ << QString()
+ << QByteArray()
+ << QString("test.txt")
+ << qint64(1022);
+
+ QTest::newRow("full")
+ << QByteArray("<file xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\" "
+ "date=\"1969-07-21T02:56:15Z\" "
+ "hash=\"552da749930852c69ae5d2141d3766b1\" "
+ "name=\"test.txt\" "
+ "size=\"1022\">"
+ "<desc>This is a test. If this were a real file...</desc>"
+ "</file>")
+ << QDateTime(QDate(1969, 7, 21), QTime(2, 56, 15), Qt::UTC)
+ << QString("This is a test. If this were a real file...")
+ << QByteArray::fromHex("552da749930852c69ae5d2141d3766b1")
+ << QString("test.txt")
+ << qint64(1022);
+}
+
+void tst_QXmppStreamInitiationIq::testFileInfo()
+{
+ QFETCH(QByteArray, xml);
+ QFETCH(QDateTime, date);
+ QFETCH(QString, description);
+ QFETCH(QByteArray, hash);
+ QFETCH(QString, name);
+ QFETCH(qint64, size);
+
+ QXmppTransferFileInfo info;
+ parsePacket(info, xml);
+ QCOMPARE(info.date(), date);
+ QCOMPARE(info.description(), description);
+ QCOMPARE(info.hash(), hash);
+ QCOMPARE(info.name(), name);
+ QCOMPARE(info.size(), size);
+ serializePacket(info, xml);
+}
+
void tst_QXmppStreamInitiationIq::testOffer()
{
QByteArray xml(