aboutsummaryrefslogtreecommitdiff
path: root/tests/qxmppbindiq
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qxmppbindiq')
-rw-r--r--tests/qxmppbindiq/qxmppbindiq.pro3
-rw-r--r--tests/qxmppbindiq/tst_qxmppbindiq.cpp92
2 files changed, 95 insertions, 0 deletions
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"