diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-07-18 11:53:40 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-07-18 11:53:40 +0200 |
| commit | 728901eab3d77595878ae1dc3defbcfbde6423a3 (patch) | |
| tree | 0b1c750d9776dcf206c4bb88987719e124cbe3ea | |
| parent | 4fb81e112fe2d334b0627359ff02015d514abae7 (diff) | |
| download | qxmpp-728901eab3d77595878ae1dc3defbcfbde6423a3.tar.gz | |
split RTP tests out
| -rw-r--r-- | tests/rtp.cpp | 76 | ||||
| -rw-r--r-- | tests/rtp.h | 35 | ||||
| -rw-r--r-- | tests/tests.cpp | 49 | ||||
| -rw-r--r-- | tests/tests.h | 10 | ||||
| -rw-r--r-- | tests/tests.pro | 8 |
5 files changed, 119 insertions, 59 deletions
diff --git a/tests/rtp.cpp b/tests/rtp.cpp new file mode 100644 index 00000000..8e62e075 --- /dev/null +++ b/tests/rtp.cpp @@ -0,0 +1,76 @@ +/* + * 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 <QtTest/QtTest> + +#include "QXmppRtpChannel.h" + +#include "rtp.h" + +void TestRtp::testBad() +{ + QXmppRtpPacket packet; + + // too short + QCOMPARE(packet.decode(QByteArray()), false); + QCOMPARE(packet.decode(QByteArray("\x80\x00\x3e", 3)), false); + QCOMPARE(packet.decode(QByteArray("\x84\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e", 12)), false); + + // wrong RTP version + QCOMPARE(packet.decode(QByteArray("\x40\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e", 12)), false); +} + +void TestRtp::testSimple() +{ + QByteArray data("\x80\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e\x12\x34\x56", 15); + QXmppRtpPacket packet; + QCOMPARE(packet.decode(data), true); + QCOMPARE(packet.version, quint8(2)); + QCOMPARE(packet.marker, false); + QCOMPARE(packet.type, quint8(0)); + QCOMPARE(packet.sequence, quint16(16082)); + QCOMPARE(packet.stamp, quint32(144)); + QCOMPARE(packet.ssrc, quint32(1606227614)); + QCOMPARE(packet.csrc, QList<quint32>()); + QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); + QCOMPARE(packet.encode(), data); +} + +void TestRtp::testWithCsrc() +{ + QByteArray data("\x84\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e\xab\xcd\xef\x01\xde\xad\xbe\xef\x12\x34\x56", 23); + QXmppRtpPacket packet; + QCOMPARE(packet.decode(data), true); + QCOMPARE(packet.version, quint8(2)); + QCOMPARE(packet.marker, false); + QCOMPARE(packet.type, quint8(0)); + QCOMPARE(packet.sequence, quint16(16082)); + QCOMPARE(packet.stamp, quint32(144)); + QCOMPARE(packet.ssrc, quint32(1606227614)); + qDebug() << packet.csrc; + QCOMPARE(packet.csrc, QList<quint32>() << quint32(0xabcdef01) << quint32(0xdeadbeef)); + QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); + QCOMPARE(packet.encode(), data); +} + + diff --git a/tests/rtp.h b/tests/rtp.h new file mode 100644 index 00000000..8d4f7497 --- /dev/null +++ b/tests/rtp.h @@ -0,0 +1,35 @@ +/* + * 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 <QObject> + +class TestRtp : public QObject +{ + Q_OBJECT + +private slots: + void testBad(); + void testSimple(); + void testWithCsrc(); +}; + diff --git a/tests/tests.cpp b/tests/tests.cpp index 008968f9..5790c290 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -42,7 +42,6 @@ #include "QXmppPresence.h" #include "QXmppPubSubIq.h" #include "QXmppRpcIq.h" -#include "QXmppRtpChannel.h" #include "QXmppSaslAuth.h" #include "QXmppSessionIq.h" #include "QXmppServer.h" @@ -53,6 +52,8 @@ #include "QXmppVersionIq.h" #include "QXmppGlobal.h" #include "QXmppEntityTimeIq.h" + +#include "rtp.h" #include "tests.h" void TestUtils::testCrc32() @@ -1347,52 +1348,6 @@ private: QString m_password; }; -void TestRtp::testBad() -{ - QXmppRtpPacket packet; - - // too short - QCOMPARE(packet.decode(QByteArray()), false); - QCOMPARE(packet.decode(QByteArray("\x80\x00\x3e", 3)), false); - QCOMPARE(packet.decode(QByteArray("\x84\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e", 12)), false); - - // wrong RTP version - QCOMPARE(packet.decode(QByteArray("\x40\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e", 12)), false); -} - -void TestRtp::testSimple() -{ - QByteArray data("\x80\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e\x12\x34\x56", 15); - QXmppRtpPacket packet; - QCOMPARE(packet.decode(data), true); - QCOMPARE(packet.version, quint8(2)); - QCOMPARE(packet.marker, false); - QCOMPARE(packet.type, quint8(0)); - QCOMPARE(packet.sequence, quint16(16082)); - QCOMPARE(packet.stamp, quint32(144)); - QCOMPARE(packet.ssrc, quint32(1606227614)); - QCOMPARE(packet.csrc, QList<quint32>()); - QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); - QCOMPARE(packet.encode(), data); -} - -void TestRtp::testWithCsrc() -{ - QByteArray data("\x84\x00\x3e\xd2\x00\x00\x00\x90\x5f\xbd\x16\x9e\xab\xcd\xef\x01\xde\xad\xbe\xef\x12\x34\x56", 23); - QXmppRtpPacket packet; - QCOMPARE(packet.decode(data), true); - QCOMPARE(packet.version, quint8(2)); - QCOMPARE(packet.marker, false); - QCOMPARE(packet.type, quint8(0)); - QCOMPARE(packet.sequence, quint16(16082)); - QCOMPARE(packet.stamp, quint32(144)); - QCOMPARE(packet.ssrc, quint32(1606227614)); - qDebug() << packet.csrc; - QCOMPARE(packet.csrc, QList<quint32>() << quint32(0xabcdef01) << quint32(0xdeadbeef)); - QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); - QCOMPARE(packet.encode(), data); -} - void TestRsm::testQuery_data() { QTest::addColumn<QByteArray>("xml"); diff --git a/tests/tests.h b/tests/tests.h index 5871a23a..ec902591 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -119,16 +119,6 @@ private slots: void testSubscriptions(); }; -class TestRtp : public QObject -{ - Q_OBJECT - -private slots: - void testBad(); - void testSimple(); - void testWithCsrc(); -}; - class TestRsm : public QObject { Q_OBJECT diff --git a/tests/tests.pro b/tests/tests.pro index 9486876d..e41696d9 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -5,8 +5,12 @@ QT += testlib TARGET = qxmpp-tests RESOURCES += tests.qrc -SOURCES += tests.cpp -HEADERS += tests.h +SOURCES += \ + rtp.cpp \ + tests.cpp +HEADERS += \ + rtp.h \ + tests.h INCLUDEPATH += $$QXMPP_INCLUDEPATH LIBS += -L../src $$QXMPP_LIBS |
