• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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.
9  */
10 
11 #include "modules/rtp_rtcp/source/rtcp_packet.h"
12 
13 #include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
14 #include "test/gmock.h"
15 #include "test/gtest.h"
16 
17 namespace {
18 
19 using ::testing::_;
20 using ::testing::MockFunction;
21 using ::webrtc::rtcp::ReceiverReport;
22 using ::webrtc::rtcp::ReportBlock;
23 
24 const uint32_t kSenderSsrc = 0x12345678;
25 
TEST(RtcpPacketTest,BuildWithTooSmallBuffer)26 TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
27   ReportBlock rb;
28   ReceiverReport rr;
29   rr.SetSenderSsrc(kSenderSsrc);
30   EXPECT_TRUE(rr.AddReportBlock(rb));
31 
32   const size_t kRrLength = 8;
33   const size_t kReportBlockLength = 24;
34 
35   // No packet.
36   MockFunction<void(rtc::ArrayView<const uint8_t>)> callback;
37   EXPECT_CALL(callback, Call(_)).Times(0);
38   const size_t kBufferSize = kRrLength + kReportBlockLength - 1;
39   EXPECT_FALSE(rr.Build(kBufferSize, callback.AsStdFunction()));
40 }
41 
42 }  // namespace
43