From 47bb20d2bd0493823b033c61a1d7f72d9521c94a Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Sat, 21 Jul 2012 10:28:40 +0200 Subject: split out jingle tests --- tests/jingle.cpp | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/jingle.h | 37 +++++++++++++++ tests/tests.cpp | 114 +-------------------------------------------- tests/tests.h | 12 ----- tests/tests.pro | 2 + 5 files changed, 178 insertions(+), 125 deletions(-) create mode 100644 tests/jingle.cpp create mode 100644 tests/jingle.h (limited to 'tests') diff --git a/tests/jingle.cpp b/tests/jingle.cpp new file mode 100644 index 00000000..a10e98d7 --- /dev/null +++ b/tests/jingle.cpp @@ -0,0 +1,138 @@ +/* + * 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 "QXmppJingleIq.h" + +#include "jingle.h" +#include "tests.h" + +void TestJingle::testSession() +{ + const QByteArray xml( + "" + "" + "" + "" + "" + "" + "" + ""); + + QXmppJingleIq session; + parsePacket(session, xml); + QCOMPARE(session.action(), QXmppJingleIq::SessionInitiate); + QCOMPARE(session.initiator(), QLatin1String("romeo@montague.lit/orchard")); + QCOMPARE(session.sid(), QLatin1String("a73sjjvkla37jfea")); + QCOMPARE(session.content().creator(), QLatin1String("initiator")); + QCOMPARE(session.content().name(), QLatin1String("this-is-a-stub")); + QCOMPARE(session.reason().text(), QString()); + QCOMPARE(session.reason().type(), QXmppJingleIq::Reason::None); + serializePacket(session, xml); +} + +void TestJingle::testTerminate() +{ + const QByteArray xml( + "" + "" + "" + "" + "" + "" + ""); + + QXmppJingleIq session; + parsePacket(session, xml); + QCOMPARE(session.action(), QXmppJingleIq::SessionTerminate); + QCOMPARE(session.initiator(), QString()); + QCOMPARE(session.sid(), QLatin1String("a73sjjvkla37jfea")); + QCOMPARE(session.reason().text(), QString()); + QCOMPARE(session.reason().type(), QXmppJingleIq::Reason::Success); + serializePacket(session, xml); +} + +void TestJingle::testAudioPayloadType() +{ + const QByteArray xml(""); + QXmppJinglePayloadType payload; + parsePacket(payload, xml); + QCOMPARE(payload.id(), static_cast(103)); + QCOMPARE(payload.name(), QLatin1String("L16")); + QCOMPARE(payload.channels(), static_cast(2)); + QCOMPARE(payload.clockrate(), 16000u); + serializePacket(payload, xml); +} + +void TestJingle::testVideoPayloadType() +{ + const QByteArray xml( + "" + "" + "" + ""); + QXmppJinglePayloadType payload; + parsePacket(payload, xml); + QCOMPARE(payload.id(), static_cast(98)); + QCOMPARE(payload.name(), QLatin1String("theora")); + QCOMPARE(payload.clockrate(), 90000u); + QCOMPARE(payload.parameters().size(), 2); + QCOMPARE(payload.parameters().value("height"), QLatin1String("768")); + QCOMPARE(payload.parameters().value("width"), QLatin1String("1024")); + serializePacket(payload, xml); +} + +void TestJingle::testRinging() +{ + const QByteArray xml( + "" + "" + "" + "" + ""); + + QXmppJingleIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.ringing(), true); + serializePacket(iq, xml); +} diff --git a/tests/jingle.h b/tests/jingle.h new file mode 100644 index 00000000..9098e8da --- /dev/null +++ b/tests/jingle.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2008-2012 The QXmpp developers + * + * Author: + * Jeremy Lainé + * + * 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 + +class TestJingle : public QObject +{ + Q_OBJECT + +private slots: + void testSession(); + void testTerminate(); + void testAudioPayloadType(); + void testVideoPayloadType(); + void testRinging(); +}; + diff --git a/tests/tests.cpp b/tests/tests.cpp index fff639ec..e08cfb8d 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -34,11 +34,8 @@ #include "QXmppBindIq.h" #include "QXmppClient.h" #include "QXmppDiscoveryIq.h" -#include "QXmppJingleIq.h" -#include "QXmppMessage.h" #include "QXmppNonSASLAuth.h" #include "QXmppPasswordChecker.h" -#include "QXmppPresence.h" #include "QXmppPubSubIq.h" #include "QXmppRpcIq.h" #include "QXmppSessionIq.h" @@ -53,6 +50,7 @@ #include "codec.h" #include "dataform.h" +#include "jingle.h" #include "message.h" #include "presence.h" #include "register.h" @@ -636,116 +634,6 @@ void TestPackets::testEntityTimeResult() serializePacket(entityTime, xml); } -void TestJingle::testSession() -{ - const QByteArray xml( - "" - "" - "" - "" - "" - "" - "" - ""); - - QXmppJingleIq session; - parsePacket(session, xml); - QCOMPARE(session.action(), QXmppJingleIq::SessionInitiate); - QCOMPARE(session.initiator(), QLatin1String("romeo@montague.lit/orchard")); - QCOMPARE(session.sid(), QLatin1String("a73sjjvkla37jfea")); - QCOMPARE(session.content().creator(), QLatin1String("initiator")); - QCOMPARE(session.content().name(), QLatin1String("this-is-a-stub")); - QCOMPARE(session.reason().text(), QString()); - QCOMPARE(session.reason().type(), QXmppJingleIq::Reason::None); - serializePacket(session, xml); -} - -void TestJingle::testTerminate() -{ - const QByteArray xml( - "" - "" - "" - "" - "" - "" - ""); - - QXmppJingleIq session; - parsePacket(session, xml); - QCOMPARE(session.action(), QXmppJingleIq::SessionTerminate); - QCOMPARE(session.initiator(), QString()); - QCOMPARE(session.sid(), QLatin1String("a73sjjvkla37jfea")); - QCOMPARE(session.reason().text(), QString()); - QCOMPARE(session.reason().type(), QXmppJingleIq::Reason::Success); - serializePacket(session, xml); -} - -void TestJingle::testAudioPayloadType() -{ - const QByteArray xml(""); - QXmppJinglePayloadType payload; - parsePacket(payload, xml); - QCOMPARE(payload.id(), static_cast(103)); - QCOMPARE(payload.name(), QLatin1String("L16")); - QCOMPARE(payload.channels(), static_cast(2)); - QCOMPARE(payload.clockrate(), 16000u); - serializePacket(payload, xml); -} - -void TestJingle::testVideoPayloadType() -{ - const QByteArray xml( - "" - "" - "" - ""); - QXmppJinglePayloadType payload; - parsePacket(payload, xml); - QCOMPARE(payload.id(), static_cast(98)); - QCOMPARE(payload.name(), QLatin1String("theora")); - QCOMPARE(payload.clockrate(), 90000u); - QCOMPARE(payload.parameters().size(), 2); - QCOMPARE(payload.parameters().value("height"), QLatin1String("768")); - QCOMPARE(payload.parameters().value("width"), QLatin1String("1024")); - serializePacket(payload, xml); -} - -void TestJingle::testRinging() -{ - const QByteArray xml( - "" - "" - "" - "" - ""); - - QXmppJingleIq iq; - parsePacket(iq, xml); - QCOMPARE(iq.ringing(), true); - serializePacket(iq, xml); -} - void TestPubSub::testItems() { const QByteArray xml( diff --git a/tests/tests.h b/tests/tests.h index b6f2eeab..78c87ae8 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -88,18 +88,6 @@ private slots: void testEntityTimeResult(); }; -class TestJingle : public QObject -{ - Q_OBJECT - -private slots: - void testSession(); - void testTerminate(); - void testAudioPayloadType(); - void testVideoPayloadType(); - void testRinging(); -}; - class TestPubSub : public QObject { Q_OBJECT diff --git a/tests/tests.pro b/tests/tests.pro index 36c52635..1362e9a4 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -8,6 +8,7 @@ RESOURCES += tests.qrc SOURCES += \ codec.cpp \ dataform.cpp \ + jingle.cpp \ message.cpp \ presence.cpp \ register.cpp \ @@ -18,6 +19,7 @@ SOURCES += \ HEADERS += \ codec.h \ dataform.h \ + jingle.h \ message.h \ presence.h \ register.h \ -- cgit v1.2.3