blob: 788028db90f1b1b9fcaa299b0073a9d8f89361c6 [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"
12#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
13#include "test/gmock.h"
14#include "test/gtest.h"
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000015
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010016namespace {
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000017
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010018using ::testing::_;
19using ::testing::MockFunction;
20using ::webrtc::rtcp::ReceiverReport;
21using ::webrtc::rtcp::ReportBlock;
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000022
23const uint32_t kSenderSsrc = 0x12345678;
asapersson@webrtc.org4b12d402014-06-16 14:09:28 +000024
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000025TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
26 ReportBlock rb;
27 ReceiverReport rr;
danilchap822a16f2016-09-27 09:27:47 -070028 rr.SetSenderSsrc(kSenderSsrc);
29 EXPECT_TRUE(rr.AddReportBlock(rb));
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000030
asapersson@webrtc.org4b12d402014-06-16 14:09:28 +000031 const size_t kRrLength = 8;
32 const size_t kReportBlockLength = 24;
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000033
34 // No packet.
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010035 MockFunction<void(rtc::ArrayView<const uint8_t>)> callback;
36 EXPECT_CALL(callback, Call(_)).Times(0);
Erik Språngc1b9d4e2015-06-08 09:54:14 +020037 const size_t kBufferSize = kRrLength + kReportBlockLength - 1;
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010038 EXPECT_FALSE(rr.Build(kBufferSize, callback.AsStdFunction()));
asapersson@webrtc.org0f2809a2014-02-21 08:14:45 +000039}
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010040
41} // namespace