diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-27 21:21:16 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-27 21:21:16 +0200 |
| commit | 95a225b32b71fc84d9ace084427c9980d5908200 (patch) | |
| tree | 3377de11858cd139d25a5cd0d3eabc842d97ef7e /tests | |
| parent | 64ec2617e2c4e5b53ca1675a41ba98a281a549da (diff) | |
| download | qxmpp-95a225b32b71fc84d9ace084427c9980d5908200.tar.gz | |
split some more tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/all/tests.cpp | 170 | ||||
| -rw-r--r-- | tests/qxmpparchiveiq/qxmpparchiveiq.pro | 3 | ||||
| -rw-r--r-- | tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp | 203 | ||||
| -rw-r--r-- | tests/qxmppserver/tst_qxmppserver.cpp | 8 | ||||
| -rw-r--r-- | tests/tests.pro | 1 |
5 files changed, 212 insertions, 173 deletions
diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp index 230fbf6f..48f0480c 100644 --- a/tests/all/tests.cpp +++ b/tests/all/tests.cpp @@ -22,16 +22,15 @@ * */ -#include "QXmppArchiveIq.h" #include "QXmppBindIq.h" #include "QXmppDiscoveryIq.h" +#include "QXmppEntityTimeIq.h" #include "QXmppNonSASLAuth.h" #include "QXmppPubSubIq.h" #include "QXmppSessionIq.h" #include "QXmppStreamFeatures.h" #include "QXmppUtils.h" #include "QXmppVersionIq.h" -#include "QXmppEntityTimeIq.h" #include "util.h" class TestPackets : public QObject @@ -39,13 +38,6 @@ class TestPackets : public QObject Q_OBJECT private slots: - void testArchiveList_data(); - void testArchiveList(); - void testArchiveChat_data(); - void testArchiveChat(); - void testArchiveRemove(); - void testArchiveRetrieve_data(); - void testArchiveRetrieve(); void testBindNoResource(); void testBindResource(); void testBindResult(); @@ -60,166 +52,6 @@ private slots: void testEntityTimeResult(); }; -void TestPackets::testArchiveList_data() -{ - QTest::addColumn<QByteArray>("xml"); - QTest::addColumn<int>("max"); - - QTest::newRow("no rsm") << - QByteArray( - "<iq id=\"list_1\" type=\"get\">" - "<list xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" - " start=\"1469-07-21T02:00:00Z\" end=\"1479-07-21T04:00:00Z\"/>" - "</iq>") << -1; - - QTest::newRow("with rsm") << - QByteArray( - "<iq id=\"list_1\" type=\"get\">" - "<list xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" - " start=\"1469-07-21T02:00:00Z\" end=\"1479-07-21T04:00:00Z\">" - "<set xmlns=\"http://jabber.org/protocol/rsm\">" - "<max>30</max>" - "</set>" - "</list>" - "</iq>") << 30; -} - -void TestPackets::testArchiveList() -{ - QFETCH(QByteArray, xml); - QFETCH(int, max); - - QXmppArchiveListIq iq; - parsePacket(iq, xml); - QCOMPARE(iq.type(), QXmppIq::Get); - QCOMPARE(iq.id(), QLatin1String("list_1")); - QCOMPARE(iq.with(), QLatin1String("juliet@capulet.com")); - QCOMPARE(iq.start(), QDateTime(QDate(1469, 7, 21), QTime(2, 0, 0), Qt::UTC)); - QCOMPARE(iq.end(), QDateTime(QDate(1479, 7, 21), QTime(4, 0, 0), Qt::UTC)); - QCOMPARE(iq.resultSetQuery().max(), max); - serializePacket(iq, xml); -} - -void TestPackets::testArchiveChat_data() -{ - QTest::addColumn<QByteArray>("xml"); - QTest::addColumn<int>("count"); - - QTest::newRow("no rsm") << - QByteArray( - "<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>" - "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" - "</chat>" - "</iq>") << -1; - - QTest::newRow("with rsm") << - QByteArray( - "<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>" - "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" - "<set xmlns=\"http://jabber.org/protocol/rsm\">" - "<count>3</count>" - "</set>" - "</chat>" - "</iq>") << 3; -} - -void TestPackets::testArchiveChat() -{ - QFETCH(QByteArray, xml); - QFETCH(int, count); - - 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(), 3); - 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.")); - QCOMPARE(iq.chat().messages()[2].isReceived(), true); - QCOMPARE(iq.chat().messages()[2].date(), QDateTime(QDate(1469, 7, 21), QTime(2, 56, 33), Qt::UTC)); - QCOMPARE(iq.chat().messages()[2].body(), QLatin1String("How cam'st thou hither, tell me, and wherefore?")); - QCOMPARE(iq.resultSetReply().count(), count); - serializePacket(iq, xml); -} - -void TestPackets::testArchiveRemove() -{ - const QByteArray xml( - "<iq id=\"remove_1\" type=\"set\">" - "<remove xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" - " start=\"1469-07-21T02:00:00Z\" end=\"1479-07-21T04:00:00Z\"/>" - "</iq>"); - - QXmppArchiveRemoveIq iq; - parsePacket(iq, xml); - QCOMPARE(iq.type(), QXmppIq::Set); - QCOMPARE(iq.id(), QLatin1String("remove_1")); - QCOMPARE(iq.with(), QLatin1String("juliet@capulet.com")); - QCOMPARE(iq.start(), QDateTime(QDate(1469, 7, 21), QTime(2, 0, 0), Qt::UTC)); - QCOMPARE(iq.end(), QDateTime(QDate(1479, 7, 21), QTime(4, 0, 0), Qt::UTC)); - serializePacket(iq, xml); -} - -void TestPackets::testArchiveRetrieve_data() -{ - QTest::addColumn<QByteArray>("xml"); - QTest::addColumn<int>("max"); - - QTest::newRow("no rsm") << - QByteArray( - "<iq id=\"retrieve_1\" type=\"get\">" - "<retrieve xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" - " start=\"1469-07-21T02:00:00Z\"/>" - "</iq>") << -1; - - QTest::newRow("with rsm") << - QByteArray( - "<iq id=\"retrieve_1\" type=\"get\">" - "<retrieve xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" - " start=\"1469-07-21T02:00:00Z\">" - "<set xmlns=\"http://jabber.org/protocol/rsm\">" - "<max>30</max>" - "</set>" - "</retrieve>" - "</iq>") << 30; -} - -void TestPackets::testArchiveRetrieve() -{ - QFETCH(QByteArray, xml); - QFETCH(int, max); - - QXmppArchiveRetrieveIq iq; - parsePacket(iq, xml); - QCOMPARE(iq.type(), QXmppIq::Get); - QCOMPARE(iq.id(), QLatin1String("retrieve_1")); - QCOMPARE(iq.with(), QLatin1String("juliet@capulet.com")); - QCOMPARE(iq.start(), QDateTime(QDate(1469, 7, 21), QTime(2, 0, 0), Qt::UTC)); - QCOMPARE(iq.resultSetQuery().max(), max); - serializePacket(iq, xml); -} - void TestPackets::testBindNoResource() { const QByteArray xml( diff --git a/tests/qxmpparchiveiq/qxmpparchiveiq.pro b/tests/qxmpparchiveiq/qxmpparchiveiq.pro new file mode 100644 index 00000000..53b38e14 --- /dev/null +++ b/tests/qxmpparchiveiq/qxmpparchiveiq.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +TARGET = tst_qxmpparchiveiq +SOURCES += tst_qxmpparchiveiq.cpp diff --git a/tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp b/tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp new file mode 100644 index 00000000..4f5cb4b1 --- /dev/null +++ b/tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2008-2012 The QXmpp developers + * + * Authors: + * Jeremy Lainé + * Manjeet Dahiya + * + * 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 "QXmppArchiveIq.h" +#include "util.h" + +class tst_QXmppArchiveIq : public QObject +{ + Q_OBJECT + +private slots: + void testArchiveList_data(); + void testArchiveList(); + void testArchiveChat_data(); + void testArchiveChat(); + void testArchiveRemove(); + void testArchiveRetrieve_data(); + void testArchiveRetrieve(); +}; + +void tst_QXmppArchiveIq::testArchiveList_data() +{ + QTest::addColumn<QByteArray>("xml"); + QTest::addColumn<int>("max"); + + QTest::newRow("no rsm") << + QByteArray( + "<iq id=\"list_1\" type=\"get\">" + "<list xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" + " start=\"1469-07-21T02:00:00Z\" end=\"1479-07-21T04:00:00Z\"/>" + "</iq>") << -1; + + QTest::newRow("with rsm") << + QByteArray( + "<iq id=\"list_1\" type=\"get\">" + "<list xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" + " start=\"1469-07-21T02:00:00Z\" end=\"1479-07-21T04:00:00Z\">" + "<set xmlns=\"http://jabber.org/protocol/rsm\">" + "<max>30</max>" + "</set>" + "</list>" + "</iq>") << 30; +} + +void tst_QXmppArchiveIq::testArchiveList() +{ + QFETCH(QByteArray, xml); + QFETCH(int, max); + + QXmppArchiveListIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.type(), QXmppIq::Get); + QCOMPARE(iq.id(), QLatin1String("list_1")); + QCOMPARE(iq.with(), QLatin1String("juliet@capulet.com")); + QCOMPARE(iq.start(), QDateTime(QDate(1469, 7, 21), QTime(2, 0, 0), Qt::UTC)); + QCOMPARE(iq.end(), QDateTime(QDate(1479, 7, 21), QTime(4, 0, 0), Qt::UTC)); + QCOMPARE(iq.resultSetQuery().max(), max); + serializePacket(iq, xml); +} + +void tst_QXmppArchiveIq::testArchiveChat_data() +{ + QTest::addColumn<QByteArray>("xml"); + QTest::addColumn<int>("count"); + + QTest::newRow("no rsm") << + QByteArray( + "<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>" + "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" + "</chat>" + "</iq>") << -1; + + QTest::newRow("with rsm") << + QByteArray( + "<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>" + "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" + "<set xmlns=\"http://jabber.org/protocol/rsm\">" + "<count>3</count>" + "</set>" + "</chat>" + "</iq>") << 3; +} + +void tst_QXmppArchiveIq::testArchiveChat() +{ + QFETCH(QByteArray, xml); + QFETCH(int, count); + + 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(), 3); + 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.")); + QCOMPARE(iq.chat().messages()[2].isReceived(), true); + QCOMPARE(iq.chat().messages()[2].date(), QDateTime(QDate(1469, 7, 21), QTime(2, 56, 33), Qt::UTC)); + QCOMPARE(iq.chat().messages()[2].body(), QLatin1String("How cam'st thou hither, tell me, and wherefore?")); + QCOMPARE(iq.resultSetReply().count(), count); + serializePacket(iq, xml); +} + +void tst_QXmppArchiveIq::testArchiveRemove() +{ + const QByteArray xml( + "<iq id=\"remove_1\" type=\"set\">" + "<remove xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" + " start=\"1469-07-21T02:00:00Z\" end=\"1479-07-21T04:00:00Z\"/>" + "</iq>"); + + QXmppArchiveRemoveIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.type(), QXmppIq::Set); + QCOMPARE(iq.id(), QLatin1String("remove_1")); + QCOMPARE(iq.with(), QLatin1String("juliet@capulet.com")); + QCOMPARE(iq.start(), QDateTime(QDate(1469, 7, 21), QTime(2, 0, 0), Qt::UTC)); + QCOMPARE(iq.end(), QDateTime(QDate(1479, 7, 21), QTime(4, 0, 0), Qt::UTC)); + serializePacket(iq, xml); +} + +void tst_QXmppArchiveIq::testArchiveRetrieve_data() +{ + QTest::addColumn<QByteArray>("xml"); + QTest::addColumn<int>("max"); + + QTest::newRow("no rsm") << + QByteArray( + "<iq id=\"retrieve_1\" type=\"get\">" + "<retrieve xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" + " start=\"1469-07-21T02:00:00Z\"/>" + "</iq>") << -1; + + QTest::newRow("with rsm") << + QByteArray( + "<iq id=\"retrieve_1\" type=\"get\">" + "<retrieve xmlns=\"urn:xmpp:archive\" with=\"juliet@capulet.com\"" + " start=\"1469-07-21T02:00:00Z\">" + "<set xmlns=\"http://jabber.org/protocol/rsm\">" + "<max>30</max>" + "</set>" + "</retrieve>" + "</iq>") << 30; +} + +void tst_QXmppArchiveIq::testArchiveRetrieve() +{ + QFETCH(QByteArray, xml); + QFETCH(int, max); + + QXmppArchiveRetrieveIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.type(), QXmppIq::Get); + QCOMPARE(iq.id(), QLatin1String("retrieve_1")); + QCOMPARE(iq.with(), QLatin1String("juliet@capulet.com")); + QCOMPARE(iq.start(), QDateTime(QDate(1469, 7, 21), QTime(2, 0, 0), Qt::UTC)); + QCOMPARE(iq.resultSetQuery().max(), max); + serializePacket(iq, xml); +} + +QTEST_MAIN(tst_QXmppArchiveIq) +#include "tst_qxmpparchiveiq.moc" diff --git a/tests/qxmppserver/tst_qxmppserver.cpp b/tests/qxmppserver/tst_qxmppserver.cpp index 014a2c28..2384019d 100644 --- a/tests/qxmppserver/tst_qxmppserver.cpp +++ b/tests/qxmppserver/tst_qxmppserver.cpp @@ -64,7 +64,7 @@ private: QString m_password; }; -class TestServer : public QObject +class tst_QXmppServer : public QObject { Q_OBJECT @@ -73,7 +73,7 @@ private slots: void testConnect(); }; -void TestServer::testConnect_data() +void tst_QXmppServer::testConnect_data() { QTest::addColumn<QString>("username"); QTest::addColumn<QString>("password"); @@ -89,7 +89,7 @@ void TestServer::testConnect_data() QTest::newRow("digest-bad-password") << "testuser" << "badpwd" << "DIGEST-MD5" << false; } -void TestServer::testConnect() +void tst_QXmppServer::testConnect() { QFETCH(QString, username); QFETCH(QString, password); @@ -134,5 +134,5 @@ void TestServer::testConnect() QCOMPARE(client.isConnected(), connected); } -QTEST_MAIN(TestServer) +QTEST_MAIN(tst_QXmppServer) #include "tst_qxmppserver.moc" diff --git a/tests/tests.pro b/tests/tests.pro index 56276fc5..0577a333 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs SUBDIRS = \ all \ + qxmpparchiveiq \ qxmppdataform \ qxmppiq \ qxmppjingleiq \ |
