2014-02-21 08:14:45 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtcp_packet.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
|
|
|
|
#include "test/gmock.h"
|
|
|
|
|
#include "test/gtest.h"
|
2014-02-21 08:14:45 +00:00
|
|
|
|
2017-12-07 10:15:53 +01:00
|
|
|
namespace {
|
2014-02-21 08:14:45 +00:00
|
|
|
|
2017-12-07 10:15:53 +01:00
|
|
|
using ::testing::_;
|
|
|
|
|
using ::testing::MockFunction;
|
|
|
|
|
using ::webrtc::rtcp::ReceiverReport;
|
|
|
|
|
using ::webrtc::rtcp::ReportBlock;
|
2014-02-21 08:14:45 +00:00
|
|
|
|
|
|
|
|
const uint32_t kSenderSsrc = 0x12345678;
|
2014-06-16 14:09:28 +00:00
|
|
|
|
2014-02-21 08:14:45 +00:00
|
|
|
TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
|
|
|
|
|
ReportBlock rb;
|
|
|
|
|
ReceiverReport rr;
|
2016-09-27 09:27:47 -07:00
|
|
|
rr.SetSenderSsrc(kSenderSsrc);
|
|
|
|
|
EXPECT_TRUE(rr.AddReportBlock(rb));
|
2014-02-21 08:14:45 +00:00
|
|
|
|
2014-06-16 14:09:28 +00:00
|
|
|
const size_t kRrLength = 8;
|
|
|
|
|
const size_t kReportBlockLength = 24;
|
2014-02-21 08:14:45 +00:00
|
|
|
|
|
|
|
|
// No packet.
|
2017-12-07 10:15:53 +01:00
|
|
|
MockFunction<void(rtc::ArrayView<const uint8_t>)> callback;
|
|
|
|
|
EXPECT_CALL(callback, Call(_)).Times(0);
|
2015-06-08 09:54:14 +02:00
|
|
|
const size_t kBufferSize = kRrLength + kReportBlockLength - 1;
|
2017-12-07 10:15:53 +01:00
|
|
|
EXPECT_FALSE(rr.Build(kBufferSize, callback.AsStdFunction()));
|
2014-02-21 08:14:45 +00:00
|
|
|
}
|
2017-12-07 10:15:53 +01:00
|
|
|
|
|
|
|
|
} // namespace
|