Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc

Issue 2020203002: [rtcp] RapidResyncRequest::Parse updated not to use RTCPUtility (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix compile Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "webrtc/test/rtcp_packet_parser.h"
15 16
16 using testing::ElementsAreArray; 17 using testing::ElementsAreArray;
17 using testing::make_tuple; 18 using testing::make_tuple;
18 using webrtc::rtcp::RapidResyncRequest; 19 using webrtc::rtcp::RapidResyncRequest;
19 using webrtc::RTCPUtility::RtcpCommonHeader;
20 using webrtc::RTCPUtility::RtcpParseCommonHeader;
21 20
22 namespace webrtc { 21 namespace webrtc {
23 namespace { 22 namespace {
24 const uint32_t kSenderSsrc = 0x12345678; 23 const uint32_t kSenderSsrc = 0x12345678;
25 const uint32_t kRemoteSsrc = 0x23456789; 24 const uint32_t kRemoteSsrc = 0x23456789;
26 // Manually created packet matching constants above. 25 // Manually created packet matching constants above.
27 const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, 26 const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02,
28 0x12, 0x34, 0x56, 0x78, 27 0x12, 0x34, 0x56, 0x78,
29 0x23, 0x45, 0x67, 0x89}; 28 0x23, 0x45, 0x67, 0x89};
30 const size_t kPacketLength = sizeof(kPacket);
31 } // namespace 29 } // namespace
32 30
33 TEST(RtcpPacketRapidResyncRequestTest, Parse) { 31 TEST(RtcpPacketRapidResyncRequestTest, Parse) {
34 RtcpCommonHeader header;
35 ASSERT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header));
36 RapidResyncRequest mutable_parsed; 32 RapidResyncRequest mutable_parsed;
37 EXPECT_TRUE(mutable_parsed.Parse( 33 EXPECT_TRUE(test::ParseSinglePacket(kPacket, &mutable_parsed));
38 header, kPacket + RtcpCommonHeader::kHeaderSizeBytes));
39 const RapidResyncRequest& parsed = mutable_parsed; 34 const RapidResyncRequest& parsed = mutable_parsed;
40 35
41 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); 36 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
42 EXPECT_EQ(kRemoteSsrc, parsed.media_ssrc()); 37 EXPECT_EQ(kRemoteSsrc, parsed.media_ssrc());
43 } 38 }
44 39
45 TEST(RtcpPacketRapidResyncRequestTest, Create) { 40 TEST(RtcpPacketRapidResyncRequestTest, Create) {
46 RapidResyncRequest rrr; 41 RapidResyncRequest rrr;
47 rrr.From(kSenderSsrc); 42 rrr.From(kSenderSsrc);
48 rrr.To(kRemoteSsrc); 43 rrr.To(kRemoteSsrc);
49 44
50 rtc::Buffer packet = rrr.Build(); 45 rtc::Buffer packet = rrr.Build();
51 46
52 EXPECT_THAT(make_tuple(packet.data(), packet.size()), 47 EXPECT_THAT(make_tuple(packet.data(), packet.size()),
53 ElementsAreArray(kPacket)); 48 ElementsAreArray(kPacket));
54 } 49 }
55 50
56 TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnWrongSizePacket) { 51 TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnTooSmallPacket) {
52 const uint8_t kTooSmallPacket[] = {0x85, 205, 0x00, 0x01,
53 0x12, 0x34, 0x56, 0x78};
57 RapidResyncRequest parsed; 54 RapidResyncRequest parsed;
58 RtcpCommonHeader header; 55 EXPECT_FALSE(test::ParseSinglePacket(kTooSmallPacket, &parsed));
59 ASSERT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header)); 56 }
60 const size_t kCorrectPayloadSize = header.payload_size_bytes;
61 const uint8_t* payload = kPacket + RtcpCommonHeader::kHeaderSizeBytes;
62 57
63 header.payload_size_bytes = kCorrectPayloadSize - 1; 58 TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnTooLargePacket) {
64 EXPECT_FALSE(parsed.Parse(header, payload)); 59 const uint8_t kTooLargePacket[] = {0x85, 205, 0x00, 0x03,
65 60 0x12, 0x34, 0x56, 0x78,
66 header.payload_size_bytes = kCorrectPayloadSize + 1; 61 0x32, 0x21, 0x65, 0x87,
67 EXPECT_FALSE(parsed.Parse(header, payload)); 62 0x23, 0x45, 0x67, 0x89};
63 RapidResyncRequest parsed;
64 EXPECT_FALSE(test::ParseSinglePacket(kTooLargePacket, &parsed));
68 } 65 }
69 } // namespace webrtc 66 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698