blob: f9544b3b6520b84bc1b6ba0891544451edd44f13 [file] [log] [blame]
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +00001/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +00009 */
10
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000011#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
Danil Chapovalov97f7e132015-12-04 16:13:30 +010012#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
kwibergac9f8762016-09-30 22:29:43 -070013#include "webrtc/test/gmock.h"
14#include "webrtc/test/gtest.h"
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000015
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000016using webrtc::rtcp::ReceiverReport;
17using webrtc::rtcp::ReportBlock;
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000018
19namespace webrtc {
20
21const uint32_t kSenderSsrc = 0x12345678;
asapersson@webrtc.org4b12d402014-06-16 14:09:28 +000022
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000023TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
24 ReportBlock rb;
25 ReceiverReport rr;
danilchap822a16f2016-09-27 09:27:47 -070026 rr.SetSenderSsrc(kSenderSsrc);
27 EXPECT_TRUE(rr.AddReportBlock(rb));
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000028
asapersson@webrtc.org4b12d402014-06-16 14:09:28 +000029 const size_t kRrLength = 8;
30 const size_t kReportBlockLength = 24;
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000031
32 // No packet.
Erik Språngc1b9d4e2015-06-08 09:54:14 +020033 class Verifier : public rtcp::RtcpPacket::PacketReadyCallback {
34 void OnPacketReady(uint8_t* data, size_t length) override {
35 ADD_FAILURE() << "Packet should not fit within max size.";
36 }
37 } verifier;
38 const size_t kBufferSize = kRrLength + kReportBlockLength - 1;
39 uint8_t buffer[kBufferSize];
40 EXPECT_FALSE(rr.BuildExternalBuffer(buffer, kBufferSize, &verifier));
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000041}
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000042} // namespace webrtc