aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2015-08-16 16:28:36 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2015-08-16 16:28:36 +0200
commit789ec0d6d1fbf0f8973c153da18897cd1f2bc283 (patch)
tree343c02b167f4f06cc5123a56e74bd7c7827cdfcf /tests
parente4efb8b9e47249d914bc9bc9bb128c88087d93d1 (diff)
downloadqxmpp-789ec0d6d1fbf0f8973c153da18897cd1f2bc283.tar.gz
add a test for QXmppIceConnection
Diffstat (limited to 'tests')
-rw-r--r--tests/qxmppiceconnection/qxmppiceconnection.pro3
-rw-r--r--tests/qxmppiceconnection/tst_qxmppiceconnection.cpp81
-rw-r--r--tests/tests.pro1
3 files changed, 85 insertions, 0 deletions
diff --git a/tests/qxmppiceconnection/qxmppiceconnection.pro b/tests/qxmppiceconnection/qxmppiceconnection.pro
new file mode 100644
index 00000000..5f2eaeb9
--- /dev/null
+++ b/tests/qxmppiceconnection/qxmppiceconnection.pro
@@ -0,0 +1,3 @@
+include(../tests.pri)
+TARGET = tst_qxmppiceconnection
+SOURCES += tst_qxmppiceconnection.cpp
diff --git a/tests/qxmppiceconnection/tst_qxmppiceconnection.cpp b/tests/qxmppiceconnection/tst_qxmppiceconnection.cpp
new file mode 100644
index 00000000..08f37fc6
--- /dev/null
+++ b/tests/qxmppiceconnection/tst_qxmppiceconnection.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2008-2014 The QXmpp developers
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * https://github.com/qxmpp-project/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 "QXmppStun.h"
+#include "util.h"
+
+class tst_QXmppIceConnection : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testConnect();
+};
+
+void tst_QXmppIceConnection::testConnect()
+{
+ const int component = 1024;
+
+ QXmppIceConnection clientL;
+ clientL.setIceControlling(true);
+ clientL.addComponent(component);
+ clientL.bind(QXmppIceComponent::discoverAddresses());
+
+ QXmppIceConnection clientR;
+ clientR.setIceControlling(false);
+ clientR.addComponent(component);
+ clientR.bind(QXmppIceComponent::discoverAddresses());
+
+ // exchange credentials
+ clientL.setRemoteUser(clientR.localUser());
+ clientL.setRemotePassword(clientR.localPassword());
+ clientR.setRemoteUser(clientL.localUser());
+ clientR.setRemotePassword(clientL.localPassword());
+
+ // exchange candidates
+ foreach (const QXmppJingleCandidate &candidate, clientR.localCandidates())
+ clientL.addRemoteCandidate(candidate);
+ foreach (const QXmppJingleCandidate &candidate, clientL.localCandidates())
+ clientR.addRemoteCandidate(candidate);
+
+ // start ICE
+ QEventLoop loop;
+ connect(&clientL, SIGNAL(connected()), &loop, SLOT(quit()));
+ connect(&clientR, SIGNAL(connected()), &loop, SLOT(quit()));
+
+ clientL.connectToHost();
+ clientR.connectToHost();
+
+ // clientR completes first
+ loop.exec();
+ QVERIFY(!clientL.isConnected());
+ QVERIFY(clientR.isConnected());
+
+ // clientL completes second
+ loop.exec();
+ QVERIFY(clientL.isConnected());
+ QVERIFY(clientR.isConnected());
+}
+
+QTEST_MAIN(tst_QXmppIceConnection)
+#include "tst_qxmppiceconnection.moc"
diff --git a/tests/tests.pro b/tests/tests.pro
index ce0b5509..50a2ac93 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -5,6 +5,7 @@ SUBDIRS = \
qxmppdataform \
qxmppdiscoveryiq \
qxmppentitytimeiq \
+ qxmppiceconnection \
qxmppiq \
qxmppjingleiq \
qxmppmessage \