From 49600c7d56b16d7b60705f170e9dff4daf58688c Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 27 Sep 2012 17:28:14 +0200 Subject: split QXmppJingleIq tests --- tests/all/all.pro | 2 - tests/all/jingle.cpp | 137 --------------------------- tests/all/jingle.h | 37 -------- tests/all/tests.cpp | 4 - tests/qxmppjingleiq/qxmppjingleiq.pro | 3 + tests/qxmppjingleiq/tst_qxmppjingleiq.cpp | 151 ++++++++++++++++++++++++++++++ tests/tests.pro | 1 + 7 files changed, 155 insertions(+), 180 deletions(-) delete mode 100644 tests/all/jingle.cpp delete mode 100644 tests/all/jingle.h create mode 100644 tests/qxmppjingleiq/qxmppjingleiq.pro create mode 100644 tests/qxmppjingleiq/tst_qxmppjingleiq.cpp (limited to 'tests') diff --git a/tests/all/all.pro b/tests/all/all.pro index d32e7f9b..5ba9e1f3 100644 --- a/tests/all/all.pro +++ b/tests/all/all.pro @@ -4,11 +4,9 @@ TARGET = tst_all RESOURCES += tests.qrc SOURCES += \ - jingle.cpp \ rpc.cpp \ tests.cpp HEADERS += \ - jingle.h \ rpc.h \ tests.h diff --git a/tests/all/jingle.cpp b/tests/all/jingle.cpp deleted file mode 100644 index 90aa3797..00000000 --- a/tests/all/jingle.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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 "QXmppJingleIq.h" - -#include "jingle.h" -#include "util.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/all/jingle.h b/tests/all/jingle.h deleted file mode 100644 index 9098e8da..00000000 --- a/tests/all/jingle.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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/all/tests.cpp b/tests/all/tests.cpp index d38d7db8..8fd2b806 100644 --- a/tests/all/tests.cpp +++ b/tests/all/tests.cpp @@ -44,7 +44,6 @@ #include "QXmppGlobal.h" #include "QXmppEntityTimeIq.h" -#include "jingle.h" #include "rpc.h" #include "sasl.h" #include "tests.h" @@ -878,9 +877,6 @@ int main(int argc, char *argv[]) TestPackets testPackets; errors += QTest::qExec(&testPackets); - TestJingle testJingle; - errors += QTest::qExec(&testJingle); - TestPubSub testPubSub; errors += QTest::qExec(&testPubSub); diff --git a/tests/qxmppjingleiq/qxmppjingleiq.pro b/tests/qxmppjingleiq/qxmppjingleiq.pro new file mode 100644 index 00000000..9518df55 --- /dev/null +++ b/tests/qxmppjingleiq/qxmppjingleiq.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +TARGET = tst_qxmppjingleiq +SOURCES += tst_qxmppjingleiq.cpp diff --git a/tests/qxmppjingleiq/tst_qxmppjingleiq.cpp b/tests/qxmppjingleiq/tst_qxmppjingleiq.cpp new file mode 100644 index 00000000..aca95867 --- /dev/null +++ b/tests/qxmppjingleiq/tst_qxmppjingleiq.cpp @@ -0,0 +1,151 @@ +/* + * 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 +#include "QXmppJingleIq.h" +#include "util.h" + +class tst_QXmppJingleIq : public QObject +{ + Q_OBJECT + +private slots: + void testSession(); + void testTerminate(); + void testAudioPayloadType(); + void testVideoPayloadType(); + void testRinging(); +}; + +void tst_QXmppJingleIq::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 tst_QXmppJingleIq::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 tst_QXmppJingleIq::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 tst_QXmppJingleIq::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 tst_QXmppJingleIq::testRinging() +{ + const QByteArray xml( + "" + "" + "" + "" + ""); + + QXmppJingleIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.ringing(), true); + serializePacket(iq, xml); +} + +QTEST_MAIN(tst_QXmppJingleIq) +#include "tst_qxmppjingleiq.moc" diff --git a/tests/tests.pro b/tests/tests.pro index e52216a7..47f6ff94 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -3,6 +3,7 @@ SUBDIRS = \ all \ qxmppdataform \ qxmppiq \ + qxmppjingleiq \ qxmppmessage \ qxmpppresence \ qxmppregisteriq \ -- cgit v1.2.3