asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 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. |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #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.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 15 | |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 16 | using webrtc::rtcp::ReceiverReport; |
| 17 | using webrtc::rtcp::ReportBlock; |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | const uint32_t kSenderSsrc = 0x12345678; |
asapersson@webrtc.org | 4b12d40 | 2014-06-16 14:09:28 +0000 | [diff] [blame] | 22 | |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 23 | TEST(RtcpPacketTest, BuildWithTooSmallBuffer) { |
| 24 | ReportBlock rb; |
| 25 | ReceiverReport rr; |
danilchap | 822a16f | 2016-09-27 09:27:47 -0700 | [diff] [blame] | 26 | rr.SetSenderSsrc(kSenderSsrc); |
| 27 | EXPECT_TRUE(rr.AddReportBlock(rb)); |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 28 | |
asapersson@webrtc.org | 4b12d40 | 2014-06-16 14:09:28 +0000 | [diff] [blame] | 29 | const size_t kRrLength = 8; |
| 30 | const size_t kReportBlockLength = 24; |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 31 | |
| 32 | // No packet. |
Erik Språng | c1b9d4e | 2015-06-08 09:54:14 +0200 | [diff] [blame] | 33 | 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.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 41 | } |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 42 | } // namespace webrtc |