blob: dccd1354a9c6b30128830e1d003594c77f6e47c6 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/rtp_rtcp/source/rtcp_packet.h"
Jonas Olssona4d87372019-07-05 19:08:33 +020012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
14#include "test/gmock.h"
15#include "test/gtest.h"
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000016
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010017namespace {
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000018
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010019using ::testing::_;
20using ::testing::MockFunction;
21using ::webrtc::rtcp::ReceiverReport;
22using ::webrtc::rtcp::ReportBlock;
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000023
24const uint32_t kSenderSsrc = 0x12345678;
asapersson@webrtc.org4b12d402014-06-16 14:09:28 +000025
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000026TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
27 ReportBlock rb;
28 ReceiverReport rr;
danilchap822a16f2016-09-27 09:27:47 -070029 rr.SetSenderSsrc(kSenderSsrc);
30 EXPECT_TRUE(rr.AddReportBlock(rb));
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000031
asapersson@webrtc.org4b12d402014-06-16 14:09:28 +000032 const size_t kRrLength = 8;
33 const size_t kReportBlockLength = 24;
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000034
35 // No packet.
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010036 MockFunction<void(rtc::ArrayView<const uint8_t>)> callback;
37 EXPECT_CALL(callback, Call(_)).Times(0);
Erik Språngc1b9d4e2015-06-08 09:54:14 +020038 const size_t kBufferSize = kRrLength + kReportBlockLength - 1;
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010039 EXPECT_FALSE(rr.Build(kBufferSize, callback.AsStdFunction()));
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000040}
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010041
42} // namespace