From 01a91df9fea68f55ae20b3ef8987002e00b622a5 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 1 Oct 2012 14:15:03 +0200 Subject: split QXmppStreamFeatures tests --- .../tst_qxmppstreamfeatures.cpp | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp (limited to 'tests/qxmppstreamfeatures/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(""); + + 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("" + "" + "" + "" + "" + "zlib" + "PLAIN" + ""); + + 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" -- cgit v1.2.3