diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-08-25 13:12:28 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-08-25 13:12:28 +0200 |
| commit | 233dbd11bb769d6ac2353eb28f58bc66f5ec0aa9 (patch) | |
| tree | 7e87234f1516835d5eca19ff7437a35984e89041 /tests | |
| parent | 65810f030b952d582737e9ff6c9582d3a60ba2b4 (diff) | |
| download | qxmpp-233dbd11bb769d6ac2353eb28f58bc66f5ec0aa9.tar.gz | |
ICE: test server-reflexive candidate gathering
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/qxmppiceconnection/tst_qxmppiceconnection.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/qxmppiceconnection/tst_qxmppiceconnection.cpp b/tests/qxmppiceconnection/tst_qxmppiceconnection.cpp index 6851bb58..4bdb9d13 100644 --- a/tests/qxmppiceconnection/tst_qxmppiceconnection.cpp +++ b/tests/qxmppiceconnection/tst_qxmppiceconnection.cpp @@ -21,6 +21,7 @@ * */ +#include <QHostInfo> #include "QXmppStun.h" #include "util.h" @@ -29,9 +30,75 @@ class tst_QXmppIceConnection : public QObject Q_OBJECT private slots: + void testBind(); + void testBindStun(); void testConnect(); }; +void tst_QXmppIceConnection::testBind() +{ + const int componentId = 1024; + + QXmppLogger logger; + logger.setLoggingType(QXmppLogger::StdoutLogging); + + QXmppIceConnection client; + connect(&client, SIGNAL(logMessage(QXmppLogger::MessageType,QString)), + &logger, SLOT(log(QXmppLogger::MessageType,QString))); + client.setIceControlling(true); + client.addComponent(componentId); + + QXmppIceComponent *component = client.component(componentId); + QVERIFY(component); + + client.bind(QXmppIceComponent::discoverAddresses()); + QCOMPARE(client.localCandidates().size(), component->localCandidates().size()); + QVERIFY(!client.localCandidates().isEmpty()); + foreach (const QXmppJingleCandidate &c, client.localCandidates()) { + QCOMPARE(c.component(), componentId); + QCOMPARE(c.type(), QXmppJingleCandidate::HostType); + } +} + +void tst_QXmppIceConnection::testBindStun() +{ + const int componentId = 1024; + + QXmppLogger logger; + logger.setLoggingType(QXmppLogger::StdoutLogging); + + QHostInfo stunInfo = QHostInfo::fromName("stun.l.google.com"); + QVERIFY(!stunInfo.addresses().isEmpty()); + + QXmppIceConnection client; + connect(&client, SIGNAL(logMessage(QXmppLogger::MessageType,QString)), + &logger, SLOT(log(QXmppLogger::MessageType,QString))); + client.setIceControlling(true); + client.setStunServer(stunInfo.addresses().first(), 19302); + client.addComponent(componentId); + + QXmppIceComponent *component = client.component(componentId); + QVERIFY(component); + + QEventLoop loop; + connect(&client, SIGNAL(localCandidatesChanged()), + &loop, SLOT(quit())); + client.bind(QXmppIceComponent::discoverAddresses()); + loop.exec(); + + bool foundReflexive = false; + QCOMPARE(client.localCandidates().size(), component->localCandidates().size()); + QVERIFY(!client.localCandidates().isEmpty()); + foreach (const QXmppJingleCandidate &c, client.localCandidates()) { + QCOMPARE(c.component(), componentId); + if (c.type() == QXmppJingleCandidate::ServerReflexiveType) + foundReflexive = true; + else + QCOMPARE(c.type(), QXmppJingleCandidate::HostType); + } + QVERIFY(foundReflexive); +} + void tst_QXmppIceConnection::testConnect() { const int component = 1024; |
