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" |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
| 14 | #include "test/gmock.h" |
| 15 | #include "test/gtest.h" |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 16 | |
Danil Chapovalov | 5c3cc41 | 2017-12-07 10:15:53 +0100 | [diff] [blame] | 17 | namespace { |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 18 | |
Danil Chapovalov | 5c3cc41 | 2017-12-07 10:15:53 +0100 | [diff] [blame] | 19 | using ::testing::_; |
| 20 | using ::testing::MockFunction; |
| 21 | using ::webrtc::rtcp::ReceiverReport; |
| 22 | using ::webrtc::rtcp::ReportBlock; |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 23 | |
| 24 | const uint32_t kSenderSsrc = 0x12345678; |
asapersson@webrtc.org | 4b12d40 | 2014-06-16 14:09:28 +0000 | [diff] [blame] | 25 | |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 26 | TEST(RtcpPacketTest, BuildWithTooSmallBuffer) { |
| 27 | ReportBlock rb; |
| 28 | ReceiverReport rr; |
danilchap | 822a16f | 2016-09-27 09:27:47 -0700 | [diff] [blame] | 29 | rr.SetSenderSsrc(kSenderSsrc); |
| 30 | EXPECT_TRUE(rr.AddReportBlock(rb)); |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 31 | |
asapersson@webrtc.org | 4b12d40 | 2014-06-16 14:09:28 +0000 | [diff] [blame] | 32 | const size_t kRrLength = 8; |
| 33 | const size_t kReportBlockLength = 24; |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 34 | |
| 35 | // No packet. |
Danil Chapovalov | 5c3cc41 | 2017-12-07 10:15:53 +0100 | [diff] [blame] | 36 | MockFunction<void(rtc::ArrayView<const uint8_t>)> callback; |
| 37 | EXPECT_CALL(callback, Call(_)).Times(0); |
Erik Språng | c1b9d4e | 2015-06-08 09:54:14 +0200 | [diff] [blame] | 38 | const size_t kBufferSize = kRrLength + kReportBlockLength - 1; |
Danil Chapovalov | 5c3cc41 | 2017-12-07 10:15:53 +0100 | [diff] [blame] | 39 | EXPECT_FALSE(rr.Build(kBufferSize, callback.AsStdFunction())); |
asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 40 | } |
Danil Chapovalov | 5c3cc41 | 2017-12-07 10:15:53 +0100 | [diff] [blame] | 41 | |
| 42 | } // namespace |