aboutsummaryrefslogtreecommitdiff
path: root/tests/all
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-27 21:12:51 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-27 21:12:51 +0200
commitcc1f3ccc6d8e60ce57f7bcb1340563d63f2f06a0 (patch)
treecb1407760047522dac6c24564d7d87386e58a5da /tests/all
parentf4dbb00a035eb4df8a12f5edaf53bb99a2bd435a (diff)
downloadqxmpp-cc1f3ccc6d8e60ce57f7bcb1340563d63f2f06a0.tar.gz
split pubsub tests
Diffstat (limited to 'tests/all')
-rw-r--r--tests/all/all.pro3
-rw-r--r--tests/all/tests.cpp232
-rw-r--r--tests/all/tests.h65
3 files changed, 28 insertions, 272 deletions
diff --git a/tests/all/all.pro b/tests/all/all.pro
index 13afe30f..ba6fd763 100644
--- a/tests/all/all.pro
+++ b/tests/all/all.pro
@@ -1,6 +1,3 @@
include(../tests.pri)
-
TARGET = tst_all
-
SOURCES += tests.cpp
-HEADERS += tests.h
diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp
index 322085e5..230fbf6f 100644
--- a/tests/all/tests.cpp
+++ b/tests/all/tests.cpp
@@ -22,11 +22,6 @@
*
*/
-#include <cstdlib>
-
-#include <QCoreApplication>
-#include <QtTest>
-
#include "QXmppArchiveIq.h"
#include "QXmppBindIq.h"
#include "QXmppDiscoveryIq.h"
@@ -37,10 +32,34 @@
#include "QXmppUtils.h"
#include "QXmppVersionIq.h"
#include "QXmppEntityTimeIq.h"
-
-#include "tests.h"
#include "util.h"
+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();
+ void testDiscovery();
+ void testDiscoveryWithForm();
+ void testNonSaslAuth();
+ void testSession();
+ void testStreamFeatures();
+ void testVersionGet();
+ void testVersionResult();
+ void testEntityTimeGet();
+ void testEntityTimeResult();
+};
+
void TestPackets::testArchiveList_data()
{
QTest::addColumn<QByteArray>("xml");
@@ -485,200 +504,5 @@ void TestPackets::testEntityTimeResult()
serializePacket(entityTime, xml);
}
-void TestPubSub::testItems()
-{
- const QByteArray xml(
- "<iq"
- " id=\"items1\""
- " to=\"pubsub.shakespeare.lit\""
- " from=\"francisco@denmark.lit/barracks\""
- " type=\"get\">"
- "<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<items node=\"storage:bookmarks\"/>"
- "</pubsub>"
- "</iq>");
-
- QXmppPubSubIq iq;
- parsePacket(iq, xml);
- QCOMPARE(iq.id(), QLatin1String("items1"));
- QCOMPARE(iq.to(), QLatin1String("pubsub.shakespeare.lit"));
- QCOMPARE(iq.from(), QLatin1String("francisco@denmark.lit/barracks"));
- QCOMPARE(iq.type(), QXmppIq::Get);
- QCOMPARE(iq.queryType(), QXmppPubSubIq::ItemsQuery);
- QCOMPARE(iq.queryJid(), QString());
- QCOMPARE(iq.queryNode(), QLatin1String("storage:bookmarks"));
- serializePacket(iq, xml);
-}
-
-void TestPubSub::testItemsResponse()
-{
- const QByteArray xml(
- "<iq"
- " id=\"items1\""
- " to=\"francisco@denmark.lit/barracks\""
- " from=\"pubsub.shakespeare.lit\""
- " type=\"result\">"
- "<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<items node=\"storage:bookmarks\">"
- "<item id=\"current\">"
- "<storage xmlns=\"storage:bookmarks\">"
- "<conference"
- " autojoin=\"true\""
- " jid=\"theplay@conference.shakespeare.lit\""
- " name=\"The Play's the Thing\">"
- "<nick>JC</nick>"
- "</conference>"
- "</storage>"
- "</item>"
- "</items>"
- "</pubsub>"
- "</iq>");
-
- QXmppPubSubIq iq;
- parsePacket(iq, xml);
- QCOMPARE(iq.id(), QLatin1String("items1"));
- QCOMPARE(iq.to(), QLatin1String("francisco@denmark.lit/barracks"));
- QCOMPARE(iq.from(), QLatin1String("pubsub.shakespeare.lit"));
- QCOMPARE(iq.type(), QXmppIq::Result);
- QCOMPARE(iq.queryType(), QXmppPubSubIq::ItemsQuery);
- QCOMPARE(iq.queryJid(), QString());
- QCOMPARE(iq.queryNode(), QLatin1String("storage:bookmarks"));
- serializePacket(iq, xml);
-}
-
-void TestPubSub::testPublish()
-{
- const QByteArray xml(
- "<iq"
- " id=\"items1\""
- " to=\"pubsub.shakespeare.lit\""
- " from=\"francisco@denmark.lit/barracks\""
- " type=\"result\">"
- "<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<publish node=\"storage:bookmarks\">"
- "<item id=\"current\">"
- "<storage xmlns=\"storage:bookmarks\">"
- "<conference"
- " autojoin=\"true\""
- " jid=\"theplay@conference.shakespeare.lit\""
- " name=\"The Play's the Thing\">"
- "<nick>JC</nick>"
- "</conference>"
- "</storage>"
- "</item>"
- "</publish>"
- "</pubsub>"
- "</iq>");
-
- QXmppPubSubIq iq;
- parsePacket(iq, xml);
- QCOMPARE(iq.id(), QLatin1String("items1"));
- QCOMPARE(iq.to(), QLatin1String("pubsub.shakespeare.lit"));
- QCOMPARE(iq.from(), QLatin1String("francisco@denmark.lit/barracks"));
- QCOMPARE(iq.type(), QXmppIq::Result);
- QCOMPARE(iq.queryType(), QXmppPubSubIq::PublishQuery);
- QCOMPARE(iq.queryJid(), QString());
- QCOMPARE(iq.queryNode(), QLatin1String("storage:bookmarks"));
- serializePacket(iq, xml);
-}
-
-void TestPubSub::testSubscribe()
-{
- const QByteArray xml(
- "<iq"
- " id=\"sub1\""
- " to=\"pubsub.shakespeare.lit\""
- " from=\"francisco@denmark.lit/barracks\""
- " type=\"set\">"
- "<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<subscribe jid=\"francisco@denmark.lit\" node=\"princely_musings\"/>"
- "</pubsub>"
- "</iq>");
-
- QXmppPubSubIq iq;
- parsePacket(iq, xml);
- QCOMPARE(iq.id(), QLatin1String("sub1"));
- QCOMPARE(iq.to(), QLatin1String("pubsub.shakespeare.lit"));
- QCOMPARE(iq.from(), QLatin1String("francisco@denmark.lit/barracks"));
- QCOMPARE(iq.type(), QXmppIq::Set);
- QCOMPARE(iq.queryType(), QXmppPubSubIq::SubscribeQuery);
- QCOMPARE(iq.queryJid(), QLatin1String("francisco@denmark.lit"));
- QCOMPARE(iq.queryNode(), QLatin1String("princely_musings"));
- serializePacket(iq, xml);
-}
-
-void TestPubSub::testSubscription()
-{
- const QByteArray xml(
- "<iq"
- " id=\"sub1\""
- " to=\"francisco@denmark.lit/barracks\""
- " from=\"pubsub.shakespeare.lit\""
- " type=\"result\">"
- "<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<subscription jid=\"francisco@denmark.lit\""
- " node=\"princely_musings\""
- " subid=\"ba49252aaa4f5d320c24d3766f0bdcade78c78d3\""
- " subscription=\"subscribed\"/>"
- "</pubsub>"
- "</iq>");
-
- QXmppPubSubIq iq;
- parsePacket(iq, xml);
- QCOMPARE(iq.id(), QLatin1String("sub1"));
- QCOMPARE(iq.to(), QLatin1String("francisco@denmark.lit/barracks"));
- QCOMPARE(iq.from(), QLatin1String("pubsub.shakespeare.lit"));
- QCOMPARE(iq.type(), QXmppIq::Result);
- QCOMPARE(iq.queryType(), QXmppPubSubIq::SubscriptionQuery);
- QCOMPARE(iq.queryJid(), QLatin1String("francisco@denmark.lit"));
- QCOMPARE(iq.queryNode(), QLatin1String("princely_musings"));
- QCOMPARE(iq.subscriptionId(), QLatin1String("ba49252aaa4f5d320c24d3766f0bdcade78c78d3"));
- serializePacket(iq, xml);
-}
-
-void TestPubSub::testSubscriptions()
-{
- const QByteArray xml(
- "<iq"
- " id=\"subscriptions1\""
- " to=\"pubsub.shakespeare.lit\""
- " from=\"francisco@denmark.lit/barracks\""
- " type=\"get\">"
- "<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">"
- "<subscriptions/>"
- "</pubsub>"
- "</iq>");
-
- QXmppPubSubIq iq;
- parsePacket(iq, xml);
- QCOMPARE(iq.id(), QLatin1String("subscriptions1"));
- QCOMPARE(iq.to(), QLatin1String("pubsub.shakespeare.lit"));
- QCOMPARE(iq.from(), QLatin1String("francisco@denmark.lit/barracks"));
- QCOMPARE(iq.type(), QXmppIq::Get);
- QCOMPARE(iq.queryType(), QXmppPubSubIq::SubscriptionsQuery);
- QCOMPARE(iq.queryJid(), QString());
- QCOMPARE(iq.queryNode(), QString());
- serializePacket(iq, xml);
-}
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
-
- // run tests
- int errors = 0;
-
- TestPackets testPackets;
- errors += QTest::qExec(&testPackets);
-
- TestPubSub testPubSub;
- errors += QTest::qExec(&testPubSub);
-
- if (errors)
- {
- qWarning() << "Total failed tests:" << errors;
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
-};
-
+QTEST_MAIN(TestPackets)
+#include "tests.moc"
diff --git a/tests/all/tests.h b/tests/all/tests.h
deleted file mode 100644
index 3bc8ad1e..00000000
--- a/tests/all/tests.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 <QObject>
-
-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();
- void testDiscovery();
- void testDiscoveryWithForm();
- void testNonSaslAuth();
- void testSession();
- void testStreamFeatures();
- void testVersionGet();
- void testVersionResult();
- void testEntityTimeGet();
- void testEntityTimeResult();
-};
-
-class TestPubSub : public QObject
-{
- Q_OBJECT
-
-private slots:
- void testItems();
- void testItemsResponse();
- void testPublish();
- void testSubscribe();
- void testSubscription();
- void testSubscriptions();
-};
-