From c09d5ee9926474526d91b7d7d3686c71bab8f26a Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 27 Sep 2012 15:41:13 +0200 Subject: split QXmppRtpPacket tests --- tests/all/all.pro | 2 - tests/all/rtp.cpp | 76 -------------------------- tests/all/rtp.h | 35 ------------ tests/all/tests.cpp | 4 -- tests/qxmpprtppacket/qxmpprtppacket.pro | 3 + tests/qxmpprtppacket/tst_qxmpprtppacket.cpp | 85 +++++++++++++++++++++++++++++ tests/tests.pro | 1 + 7 files changed, 89 insertions(+), 117 deletions(-) delete mode 100644 tests/all/rtp.cpp delete mode 100644 tests/all/rtp.h create mode 100644 tests/qxmpprtppacket/qxmpprtppacket.pro create mode 100644 tests/qxmpprtppacket/tst_qxmpprtppacket.cpp (limited to 'tests') diff --git a/tests/all/all.pro b/tests/all/all.pro index 68ebce94..334f40dd 100644 --- a/tests/all/all.pro +++ b/tests/all/all.pro @@ -9,7 +9,6 @@ SOURCES += \ roster.cpp \ rpc.cpp \ rsm.cpp \ - rtp.cpp \ stanza.cpp \ stun.cpp \ tests.cpp @@ -19,7 +18,6 @@ HEADERS += \ roster.h \ rpc.h \ rsm.h \ - rtp.h \ stanza.h \ stun.h \ tests.h diff --git a/tests/all/rtp.cpp b/tests/all/rtp.cpp deleted file mode 100644 index cc7ee112..00000000 --- a/tests/all/rtp.cpp +++ /dev/null @@ -1,76 +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 - -#include "QXmppRtpChannel.h" - -#include "rtp.h" - -void tst_QXmppRtpPacket::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 tst_QXmppRtpPacket::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()); - QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); - QCOMPARE(packet.encode(), data); -} - -void tst_QXmppRtpPacket::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(0xabcdef01) << quint32(0xdeadbeef)); - QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); - QCOMPARE(packet.encode(), data); -} - - diff --git a/tests/all/rtp.h b/tests/all/rtp.h deleted file mode 100644 index 479a1a87..00000000 --- a/tests/all/rtp.h +++ /dev/null @@ -1,35 +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 tst_QXmppRtpPacket : public QObject -{ - Q_OBJECT - -private slots: - void testBad(); - void testSimple(); - void testWithCsrc(); -}; - diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp index 36073a83..dd7bf82c 100644 --- a/tests/all/tests.cpp +++ b/tests/all/tests.cpp @@ -50,7 +50,6 @@ #include "roster.h" #include "rpc.h" #include "rsm.h" -#include "rtp.h" #include "sasl.h" #include "stanza.h" #include "stun.h" @@ -905,9 +904,6 @@ int main(int argc, char *argv[]) tst_QXmppRosterIq testRoster; errors += QTest::qExec(&testRoster); - tst_QXmppRtpPacket testRtp; - errors += QTest::qExec(&testRtp); - #ifdef QXMPP_AUTOTEST_INTERNAL tst_QXmppSasl testSasl; errors += QTest::qExec(&testSasl); diff --git a/tests/qxmpprtppacket/qxmpprtppacket.pro b/tests/qxmpprtppacket/qxmpprtppacket.pro new file mode 100644 index 00000000..afd4d804 --- /dev/null +++ b/tests/qxmpprtppacket/qxmpprtppacket.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +TARGET = tst_qxmpprtppacket +SOURCES += tst_qxmpprtppacket.cpp diff --git a/tests/qxmpprtppacket/tst_qxmpprtppacket.cpp b/tests/qxmpprtppacket/tst_qxmpprtppacket.cpp new file mode 100644 index 00000000..94f7d417 --- /dev/null +++ b/tests/qxmpprtppacket/tst_qxmpprtppacket.cpp @@ -0,0 +1,85 @@ +/* + * 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 +#include "QXmppRtpChannel.h" + +class tst_QXmppRtpPacket : public QObject +{ + Q_OBJECT + +private slots: + void testBad(); + void testSimple(); + void testWithCsrc(); +}; + +void tst_QXmppRtpPacket::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 tst_QXmppRtpPacket::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()); + QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); + QCOMPARE(packet.encode(), data); +} + +void tst_QXmppRtpPacket::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(0xabcdef01) << quint32(0xdeadbeef)); + QCOMPARE(packet.payload, QByteArray("\x12\x34\x56", 3)); + QCOMPARE(packet.encode(), data); +} + +QTEST_MAIN(tst_QXmppRtpPacket) +#include "tst_qxmpprtppacket.moc" diff --git a/tests/tests.pro b/tests/tests.pro index bcfe6825..188cffcb 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -5,6 +5,7 @@ SUBDIRS = \ qxmppiq \ qxmppmessage \ qxmpppresence \ + qxmpprtppacket \ qxmppvcardiq !isEmpty(QXMPP_AUTOTEST_INTERNAL) { -- cgit v1.2.3