aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-10-01 14:15:03 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-10-01 14:15:03 +0200
commit01a91df9fea68f55ae20b3ef8987002e00b622a5 (patch)
tree040ec818b3fcfffb52fdc11d42bb0d6d105215bc /tests
parent44cc908b9cd4a469c30420dc329a3448fb4f20c4 (diff)
downloadqxmpp-01a91df9fea68f55ae20b3ef8987002e00b622a5.tar.gz
split QXmppStreamFeatures tests
Diffstat (limited to 'tests')
-rw-r--r--tests/all/tests.cpp34
-rw-r--r--tests/qxmppstreamfeatures/qxmppstreamfeatures.pro3
-rw-r--r--tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp74
-rw-r--r--tests/tests.pro1
4 files changed, 78 insertions, 34 deletions
diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp
index fdfbbd16..3253ba4a 100644
--- a/tests/all/tests.cpp
+++ b/tests/all/tests.cpp
@@ -23,7 +23,6 @@
*/
#include "QXmppSessionIq.h"
-#include "QXmppStreamFeatures.h"
#include "util.h"
class TestPackets : public QObject
@@ -32,7 +31,6 @@ class TestPackets : public QObject
private slots:
void testSession();
- void testStreamFeatures();
};
void TestPackets::testSession()
@@ -50,37 +48,5 @@ void TestPackets::testSession()
serializePacket(session, xml);
}
-void TestPackets::testStreamFeatures()
-{
- const QByteArray xml("<stream:features/>");
- QXmppStreamFeatures features;
- parsePacket(features, xml);
- QCOMPARE(features.bindMode(), QXmppStreamFeatures::Disabled);
- QCOMPARE(features.sessionMode(), QXmppStreamFeatures::Disabled);
- QCOMPARE(features.nonSaslAuthMode(), QXmppStreamFeatures::Disabled);
- QCOMPARE(features.tlsMode(), QXmppStreamFeatures::Disabled);
- QCOMPARE(features.authMechanisms(), QStringList());
- QCOMPARE(features.compressionMethods(), QStringList());
- serializePacket(features, xml);
-
- const QByteArray xml2("<stream:features>"
- "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
- "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
- "<auth xmlns=\"http://jabber.org/features/iq-auth\"/>"
- "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
- "<compression xmlns=\"http://jabber.org/features/compress\"><method>zlib</method></compression>"
- "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><mechanism>PLAIN</mechanism></mechanisms>"
- "</stream:features>");
- QXmppStreamFeatures features2;
- parsePacket(features2, xml2);
- QCOMPARE(features2.bindMode(), QXmppStreamFeatures::Enabled);
- QCOMPARE(features2.sessionMode(), QXmppStreamFeatures::Enabled);
- QCOMPARE(features2.nonSaslAuthMode(), QXmppStreamFeatures::Enabled);
- QCOMPARE(features2.tlsMode(), QXmppStreamFeatures::Enabled);
- QCOMPARE(features2.authMechanisms(), QStringList() << "PLAIN");
- QCOMPARE(features2.compressionMethods(), QStringList() << "zlib");
- serializePacket(features2, xml2);
-}
-
QTEST_MAIN(TestPackets)
#include "tests.moc"
diff --git a/tests/qxmppstreamfeatures/qxmppstreamfeatures.pro b/tests/qxmppstreamfeatures/qxmppstreamfeatures.pro
new file mode 100644
index 00000000..62b50008
--- /dev/null
+++ b/tests/qxmppstreamfeatures/qxmppstreamfeatures.pro
@@ -0,0 +1,3 @@
+include(../tests.pri)
+TARGET = tst_qxmppstreamfeatures
+SOURCES += tst_qxmppstreamfeatures.cpp
diff --git a/tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp b/tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp
new file mode 100644
index 00000000..544c8416
--- /dev/null
+++ b/tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2008-2012 The QXmpp developers
+ *
+ * Authors:
+ * 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 "QXmppStreamFeatures.h"
+#include "util.h"
+
+class tst_QXmppStreamFeatures : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testEmpty();
+ void testFull();
+};
+
+void tst_QXmppStreamFeatures::testEmpty()
+{
+ const QByteArray xml("<stream:features/>");
+
+ QXmppStreamFeatures features;
+ parsePacket(features, xml);
+ QCOMPARE(features.bindMode(), QXmppStreamFeatures::Disabled);
+ QCOMPARE(features.sessionMode(), QXmppStreamFeatures::Disabled);
+ QCOMPARE(features.nonSaslAuthMode(), QXmppStreamFeatures::Disabled);
+ QCOMPARE(features.tlsMode(), QXmppStreamFeatures::Disabled);
+ QCOMPARE(features.authMechanisms(), QStringList());
+ QCOMPARE(features.compressionMethods(), QStringList());
+ serializePacket(features, xml);
+}
+
+void tst_QXmppStreamFeatures::testFull()
+{
+ const QByteArray xml("<stream:features>"
+ "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
+ "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
+ "<auth xmlns=\"http://jabber.org/features/iq-auth\"/>"
+ "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
+ "<compression xmlns=\"http://jabber.org/features/compress\"><method>zlib</method></compression>"
+ "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><mechanism>PLAIN</mechanism></mechanisms>"
+ "</stream:features>");
+
+ QXmppStreamFeatures features;
+ parsePacket(features, xml);
+ QCOMPARE(features.bindMode(), QXmppStreamFeatures::Enabled);
+ QCOMPARE(features.sessionMode(), QXmppStreamFeatures::Enabled);
+ QCOMPARE(features.nonSaslAuthMode(), QXmppStreamFeatures::Enabled);
+ QCOMPARE(features.tlsMode(), QXmppStreamFeatures::Enabled);
+ QCOMPARE(features.authMechanisms(), QStringList() << "PLAIN");
+ QCOMPARE(features.compressionMethods(), QStringList() << "zlib");
+ serializePacket(features, xml);
+}
+
+QTEST_MAIN(tst_QXmppStreamFeatures)
+#include "tst_qxmppstreamfeatures.moc"
diff --git a/tests/tests.pro b/tests/tests.pro
index ee3756ae..80cfd245 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -19,6 +19,7 @@ SUBDIRS = \
qxmpprtppacket \
qxmppserver \
qxmppstanza \
+ qxmppstreamfeatures \
qxmppstunmessage \
qxmpputils \
qxmppvcardiq \