From 748ccb162f6fa9c595c07d4d0544945cdc601165 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 27 Sep 2012 15:23:42 +0200 Subject: split QXmppStreamInitiationIq tests --- tests/all/si.cpp | 126 ------------------- tests/all/tests.cpp | 5 - .../tst_qxmppstreaminitiationiq.cpp | 138 +++++++++++++++++++++ tests/tests.pro | 3 +- 4 files changed, 140 insertions(+), 132 deletions(-) delete mode 100644 tests/all/si.cpp create mode 100644 tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp (limited to 'tests') diff --git a/tests/all/si.cpp b/tests/all/si.cpp deleted file mode 100644 index cdfc4568..00000000 --- a/tests/all/si.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2008-2012 The QXmpp developers - * - * Authors: - * Olivier Goffart - * Jeremy Lainé - * - * Source: - * http://code.google.com/p/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - -#include "QXmppStreamInitiationIq_p.h" -#include "QXmppTransferManager.h" - -#include "si.h" -#include "util.h" - -void tst_QXmppStreamInitiationIq::testFileInfo_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("date"); - QTest::addColumn("description"); - QTest::addColumn("hash"); - QTest::addColumn("name"); - QTest::addColumn("size"); - - QTest::newRow("normal") - << QByteArray("") - << QDateTime() - << QString() - << QByteArray() - << QString("test.txt") - << qint64(1022); - - QTest::newRow("full") - << QByteArray("" - "This is a test. If this were a real 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( - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - ""); - - QXmppStreamInitiationIq iq; - parsePacket(iq, xml); - QVERIFY(!iq.fileInfo().isNull()); - QCOMPARE(iq.fileInfo().name(), QString("test.txt")); - QCOMPARE(iq.fileInfo().size(), qint64(1022)); - serializePacket(iq, xml); -} - -void tst_QXmppStreamInitiationIq::testResult() -{ - QByteArray xml( - "" - "" - "" - "" - "" - "http://jabber.org/protocol/bytestreams" - "" - "" - "" - "" - ""); - - QXmppStreamInitiationIq iq; - parsePacket(iq, xml); - QVERIFY(iq.fileInfo().isNull()); - serializePacket(iq, xml); -} diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp index 82f007f5..3375e15c 100644 --- a/tests/all/tests.cpp +++ b/tests/all/tests.cpp @@ -47,14 +47,12 @@ #include "codec.h" #include "dataform.h" #include "jingle.h" -#include "message.h" #include "register.h" #include "roster.h" #include "rpc.h" #include "rsm.h" #include "rtp.h" #include "sasl.h" -#include "si.h" #include "stanza.h" #include "stun.h" #include "tests.h" @@ -900,9 +898,6 @@ int main(int argc, char *argv[]) TestJingle testJingle; errors += QTest::qExec(&testJingle); - tst_QXmppMessage testMessage; - errors += QTest::qExec(&testMessage); - TestPubSub testPubSub; errors += QTest::qExec(&testPubSub); diff --git a/tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp b/tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp new file mode 100644 index 00000000..f80b0423 --- /dev/null +++ b/tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2008-2012 The QXmpp developers + * + * Authors: + * Olivier Goffart + * Jeremy Lainé + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include "QXmppStreamInitiationIq_p.h" +#include "QXmppTransferManager.h" +#include "util.h" + +class tst_QXmppStreamInitiationIq : public QObject +{ + Q_OBJECT + +private slots: + void testFileInfo_data(); + void testFileInfo(); + void testOffer(); + void testResult(); +}; + +void tst_QXmppStreamInitiationIq::testFileInfo_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("date"); + QTest::addColumn("description"); + QTest::addColumn("hash"); + QTest::addColumn("name"); + QTest::addColumn("size"); + + QTest::newRow("normal") + << QByteArray("") + << QDateTime() + << QString() + << QByteArray() + << QString("test.txt") + << qint64(1022); + + QTest::newRow("full") + << QByteArray("" + "This is a test. If this were a real 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( + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + ""); + + QXmppStreamInitiationIq iq; + parsePacket(iq, xml); + QVERIFY(!iq.fileInfo().isNull()); + QCOMPARE(iq.fileInfo().name(), QString("test.txt")); + QCOMPARE(iq.fileInfo().size(), qint64(1022)); + serializePacket(iq, xml); +} + +void tst_QXmppStreamInitiationIq::testResult() +{ + QByteArray xml( + "" + "" + "" + "" + "" + "http://jabber.org/protocol/bytestreams" + "" + "" + "" + "" + ""); + + QXmppStreamInitiationIq iq; + parsePacket(iq, xml); + QVERIFY(iq.fileInfo().isNull()); + serializePacket(iq, xml); +} + +QTEST_MAIN(tst_QXmppStreamInitiationIq) +#include "tst_qxmppstreaminitiationiq.moc" diff --git a/tests/tests.pro b/tests/tests.pro index 8bfcef6c..c7f6bcb8 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -3,4 +3,5 @@ SUBDIRS = \ all \ qxmppiq \ qxmppmessage \ - qxmpppresence + qxmpppresence \ + qxmppstreaminitiationiq -- cgit v1.2.3