diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-08-20 08:49:44 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-08-20 08:49:44 +0200 |
| commit | 3a51c38d120a30f717e8584a4502d3848a0e1ac5 (patch) | |
| tree | 79b7c84c7fe370e95e99ef922257a7789e1e35ef /tests/qxmpprtcppacket/tst_qxmpprtcppacket.cpp | |
| parent | 2b538aecb57dec32aacc27c8f23fd377b03991d4 (diff) | |
| download | qxmpp-3a51c38d120a30f717e8584a4502d3848a0e1ac5.tar.gz | |
add QXmppRtcpPacket class
Diffstat (limited to 'tests/qxmpprtcppacket/tst_qxmpprtcppacket.cpp')
| -rw-r--r-- | tests/qxmpprtcppacket/tst_qxmpprtcppacket.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/qxmpprtcppacket/tst_qxmpprtcppacket.cpp b/tests/qxmpprtcppacket/tst_qxmpprtcppacket.cpp new file mode 100644 index 00000000..94096c6a --- /dev/null +++ b/tests/qxmpprtcppacket/tst_qxmpprtcppacket.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2008-2014 The QXmpp developers + * + * Author: + * Jeremy Lainé + * + * Source: + * https://github.com/qxmpp-project/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> +#include <QtTest> +#include "QXmppRtcpPacket.h" + +class tst_QXmppRtcpPacket : public QObject +{ + Q_OBJECT + +private slots: + void testBad(); + void testSenderReport(); + void testSourceDescription(); +}; + +void tst_QXmppRtcpPacket::testBad() +{ + QXmppRtcpPacket packet; + + // too short + QCOMPARE(packet.decode(QByteArray()), false); +} + +void tst_QXmppRtcpPacket::testSenderReport() +{ + QByteArray data("\x80\xc8\x00\x06\x27\xa6\xe4\xc1\xd9\x7f\xec\x7d\x92\xac\xd9\xe8\xdd\x9e\x32\x57\x00\x00\x00\x74\x00\x00\x48\x80", 28); + + QXmppRtcpPacket packet; + QVERIFY(packet.decode(data)); + QCOMPARE(packet.count(), quint8(0)); + QCOMPARE(packet.type(), quint8(200)); + QCOMPARE(packet.encode(), data); +} + +void tst_QXmppRtcpPacket::testSourceDescription() +{ + QByteArray data("\x81\xca\x00\x0c\x27\xa6\xe4\xc1\x01\x26\x7b\x64\x30\x33\x61\x37\x63\x34\x38\x2d\x64\x39\x30\x36\x2d\x34\x62\x39\x61\x2d\x39\x38\x32\x30\x2d\x31\x31\x31\x38\x30\x32\x64\x63\x64\x35\x37\x38\x7d\x00\x00\x00\x00", 52); + + QXmppRtcpPacket packet; + QVERIFY(packet.decode(data)); + QCOMPARE(packet.count(), quint8(1)); + QCOMPARE(packet.type(), quint8(202)); + QCOMPARE(packet.encode(), data); +} + +QTEST_MAIN(tst_QXmppRtcpPacket) +#include "tst_qxmpprtcppacket.moc" |
