| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" |
| 12 | 12 |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using testing::ElementsAreArray; | 16 using testing::ElementsAreArray; |
| 17 using testing::make_tuple; | 17 using testing::make_tuple; |
| 18 using webrtc::rtcp::RapidResyncRequest; | 18 using webrtc::rtcp::RapidResyncRequest; |
| 19 using webrtc::rtcp::RawPacket; | |
| 20 using webrtc::RTCPUtility::RtcpCommonHeader; | 19 using webrtc::RTCPUtility::RtcpCommonHeader; |
| 21 using webrtc::RTCPUtility::RtcpParseCommonHeader; | 20 using webrtc::RTCPUtility::RtcpParseCommonHeader; |
| 22 | 21 |
| 23 namespace webrtc { | 22 namespace webrtc { |
| 24 namespace { | 23 namespace { |
| 25 const uint32_t kSenderSsrc = 0x12345678; | 24 const uint32_t kSenderSsrc = 0x12345678; |
| 26 const uint32_t kRemoteSsrc = 0x23456789; | 25 const uint32_t kRemoteSsrc = 0x23456789; |
| 27 // Manually created packet matching constants above. | 26 // Manually created packet matching constants above. |
| 28 const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, | 27 const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, |
| 29 0x12, 0x34, 0x56, 0x78, | 28 0x12, 0x34, 0x56, 0x78, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 | 40 |
| 42 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); | 41 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); |
| 43 EXPECT_EQ(kRemoteSsrc, parsed.media_ssrc()); | 42 EXPECT_EQ(kRemoteSsrc, parsed.media_ssrc()); |
| 44 } | 43 } |
| 45 | 44 |
| 46 TEST(RtcpPacketRapidResyncRequestTest, Create) { | 45 TEST(RtcpPacketRapidResyncRequestTest, Create) { |
| 47 RapidResyncRequest rrr; | 46 RapidResyncRequest rrr; |
| 48 rrr.From(kSenderSsrc); | 47 rrr.From(kSenderSsrc); |
| 49 rrr.To(kRemoteSsrc); | 48 rrr.To(kRemoteSsrc); |
| 50 | 49 |
| 51 rtc::scoped_ptr<RawPacket> packet = rrr.Build(); | 50 rtc::Buffer packet = rrr.Build(); |
| 52 | 51 |
| 53 EXPECT_THAT(make_tuple(packet->Buffer(), packet->Length()), | 52 EXPECT_THAT(make_tuple(packet.data(), packet.size()), |
| 54 ElementsAreArray(kPacket)); | 53 ElementsAreArray(kPacket)); |
| 55 } | 54 } |
| 56 | 55 |
| 57 TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnWrongSizePacket) { | 56 TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnWrongSizePacket) { |
| 58 RapidResyncRequest parsed; | 57 RapidResyncRequest parsed; |
| 59 RtcpCommonHeader header; | 58 RtcpCommonHeader header; |
| 60 ASSERT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header)); | 59 ASSERT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header)); |
| 61 const size_t kCorrectPayloadSize = header.payload_size_bytes; | 60 const size_t kCorrectPayloadSize = header.payload_size_bytes; |
| 62 const uint8_t* payload = kPacket + RtcpCommonHeader::kHeaderSizeBytes; | 61 const uint8_t* payload = kPacket + RtcpCommonHeader::kHeaderSizeBytes; |
| 63 | 62 |
| 64 header.payload_size_bytes = kCorrectPayloadSize - 1; | 63 header.payload_size_bytes = kCorrectPayloadSize - 1; |
| 65 EXPECT_FALSE(parsed.Parse(header, payload)); | 64 EXPECT_FALSE(parsed.Parse(header, payload)); |
| 66 | 65 |
| 67 header.payload_size_bytes = kCorrectPayloadSize + 1; | 66 header.payload_size_bytes = kCorrectPayloadSize + 1; |
| 68 EXPECT_FALSE(parsed.Parse(header, payload)); | 67 EXPECT_FALSE(parsed.Parse(header, payload)); |
| 69 } | 68 } |
| 70 } // namespace webrtc | 69 } // namespace webrtc |
| OLD | NEW |