diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/all/tests.cpp | 56 | ||||
| -rw-r--r-- | tests/qxmppbindiq/qxmppbindiq.pro | 3 | ||||
| -rw-r--r-- | tests/qxmppbindiq/tst_qxmppbindiq.cpp | 92 | ||||
| -rw-r--r-- | tests/tests.pro | 1 |
4 files changed, 96 insertions, 56 deletions
diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp index f2c4e0fd..2731ea9c 100644 --- a/tests/all/tests.cpp +++ b/tests/all/tests.cpp @@ -22,7 +22,6 @@ * */ -#include "QXmppBindIq.h" #include "QXmppDiscoveryIq.h" #include "QXmppEntityTimeIq.h" #include "QXmppNonSASLAuth.h" @@ -37,9 +36,6 @@ class TestPackets : public QObject Q_OBJECT private slots: - void testBindNoResource(); - void testBindResource(); - void testBindResult(); void testDiscovery(); void testDiscoveryWithForm(); void testNonSaslAuth(); @@ -51,58 +47,6 @@ private slots: void testEntityTimeResult(); }; -void TestPackets::testBindNoResource() -{ - const QByteArray xml( - "<iq id=\"bind_1\" type=\"set\">" - "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>" - "</iq>"); - - QXmppBindIq bind; - parsePacket(bind, xml); - QCOMPARE(bind.type(), QXmppIq::Set); - QCOMPARE(bind.id(), QString("bind_1")); - QCOMPARE(bind.jid(), QString()); - QCOMPARE(bind.resource(), QString()); - serializePacket(bind, xml); -} - -void TestPackets::testBindResource() -{ - const QByteArray xml( - "<iq id=\"bind_2\" type=\"set\">" - "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" - "<resource>someresource</resource>" - "</bind>" - "</iq>"); - - QXmppBindIq bind; - parsePacket(bind, xml); - QCOMPARE(bind.type(), QXmppIq::Set); - QCOMPARE(bind.id(), QString("bind_2")); - QCOMPARE(bind.jid(), QString()); - QCOMPARE(bind.resource(), QString("someresource")); - serializePacket(bind, xml); -} - -void TestPackets::testBindResult() -{ - const QByteArray xml( - "<iq id=\"bind_2\" type=\"result\">" - "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" - "<jid>somenode@example.com/someresource</jid>" - "</bind>" - "</iq>"); - - QXmppBindIq bind; - parsePacket(bind, xml); - QCOMPARE(bind.type(), QXmppIq::Result); - QCOMPARE(bind.id(), QString("bind_2")); - QCOMPARE(bind.jid(), QString("somenode@example.com/someresource")); - QCOMPARE(bind.resource(), QString()); - serializePacket(bind, xml); -} - void TestPackets::testDiscovery() { const QByteArray xml( diff --git a/tests/qxmppbindiq/qxmppbindiq.pro b/tests/qxmppbindiq/qxmppbindiq.pro new file mode 100644 index 00000000..8e5d580f --- /dev/null +++ b/tests/qxmppbindiq/qxmppbindiq.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +TARGET = tst_qxmppbindiq +SOURCES += tst_qxmppbindiq.cpp diff --git a/tests/qxmppbindiq/tst_qxmppbindiq.cpp b/tests/qxmppbindiq/tst_qxmppbindiq.cpp new file mode 100644 index 00000000..8256ac4c --- /dev/null +++ b/tests/qxmppbindiq/tst_qxmppbindiq.cpp @@ -0,0 +1,92 @@ +/* + * 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> +#include "QXmppBindIq.h" +#include "util.h" + +class tst_QXmppBindIq : public QObject +{ + Q_OBJECT + +private slots: + void testNoResource(); + void testResource(); + void testResult(); +}; + +void tst_QXmppBindIq::testNoResource() +{ + const QByteArray xml( + "<iq id=\"bind_1\" type=\"set\">" + "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>" + "</iq>"); + + QXmppBindIq bind; + parsePacket(bind, xml); + QCOMPARE(bind.type(), QXmppIq::Set); + QCOMPARE(bind.id(), QString("bind_1")); + QCOMPARE(bind.jid(), QString()); + QCOMPARE(bind.resource(), QString()); + serializePacket(bind, xml); +} + +void tst_QXmppBindIq::testResource() +{ + const QByteArray xml( + "<iq id=\"bind_2\" type=\"set\">" + "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" + "<resource>someresource</resource>" + "</bind>" + "</iq>"); + + QXmppBindIq bind; + parsePacket(bind, xml); + QCOMPARE(bind.type(), QXmppIq::Set); + QCOMPARE(bind.id(), QString("bind_2")); + QCOMPARE(bind.jid(), QString()); + QCOMPARE(bind.resource(), QString("someresource")); + serializePacket(bind, xml); +} + +void tst_QXmppBindIq::testResult() +{ + const QByteArray xml( + "<iq id=\"bind_2\" type=\"result\">" + "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" + "<jid>somenode@example.com/someresource</jid>" + "</bind>" + "</iq>"); + + QXmppBindIq bind; + parsePacket(bind, xml); + QCOMPARE(bind.type(), QXmppIq::Result); + QCOMPARE(bind.id(), QString("bind_2")); + QCOMPARE(bind.jid(), QString("somenode@example.com/someresource")); + QCOMPARE(bind.resource(), QString()); + serializePacket(bind, xml); +} + +QTEST_MAIN(tst_QXmppBindIq) +#include "tst_qxmppbindiq.moc" diff --git a/tests/tests.pro b/tests/tests.pro index 0577a333..3958e705 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -2,6 +2,7 @@ TEMPLATE = subdirs SUBDIRS = \ all \ qxmpparchiveiq \ + qxmppbindiq \ qxmppdataform \ qxmppiq \ qxmppjingleiq \ |
