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

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

Issue 2372713005: Revert of Unify rtcp packet setters (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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
(...skipping 17 matching lines...) Expand all
28 } // namespace 28 } // namespace
29 29
30 TEST(RtcpPacketDlrrTest, Empty) { 30 TEST(RtcpPacketDlrrTest, Empty) {
31 Dlrr dlrr; 31 Dlrr dlrr;
32 32
33 EXPECT_EQ(0u, dlrr.BlockLength()); 33 EXPECT_EQ(0u, dlrr.BlockLength());
34 } 34 }
35 35
36 TEST(RtcpPacketDlrrTest, Create) { 36 TEST(RtcpPacketDlrrTest, Create) {
37 Dlrr dlrr; 37 Dlrr dlrr;
38 EXPECT_TRUE(dlrr.AddDlrrItem(kSsrc, kLastRR, kDelay)); 38 EXPECT_TRUE(dlrr.WithDlrrItem(kSsrc, kLastRR, kDelay));
39 39
40 ASSERT_EQ(kBlockSizeBytes, dlrr.BlockLength()); 40 ASSERT_EQ(kBlockSizeBytes, dlrr.BlockLength());
41 uint8_t buffer[kBlockSizeBytes]; 41 uint8_t buffer[kBlockSizeBytes];
42 42
43 dlrr.Create(buffer); 43 dlrr.Create(buffer);
44 EXPECT_EQ(0, memcmp(buffer, kBlock, kBlockSizeBytes)); 44 EXPECT_EQ(0, memcmp(buffer, kBlock, kBlockSizeBytes));
45 } 45 }
46 46
47 TEST(RtcpPacketDlrrTest, Parse) { 47 TEST(RtcpPacketDlrrTest, Parse) {
48 Dlrr dlrr; 48 Dlrr dlrr;
(...skipping 17 matching lines...) Expand all
66 buffer[3] = size; 66 buffer[3] = size;
67 Dlrr dlrr; 67 Dlrr dlrr;
68 // Parse should be successful only when size is multiple of 3. 68 // Parse should be successful only when size is multiple of 3.
69 EXPECT_EQ(size % 3 == 0, dlrr.Parse(buffer, static_cast<uint16_t>(size))); 69 EXPECT_EQ(size % 3 == 0, dlrr.Parse(buffer, static_cast<uint16_t>(size)));
70 } 70 }
71 } 71 }
72 72
73 TEST(RtcpPacketDlrrTest, FailsOnTooManySubBlocks) { 73 TEST(RtcpPacketDlrrTest, FailsOnTooManySubBlocks) {
74 Dlrr dlrr; 74 Dlrr dlrr;
75 for (size_t i = 1; i <= Dlrr::kMaxNumberOfDlrrItems; ++i) { 75 for (size_t i = 1; i <= Dlrr::kMaxNumberOfDlrrItems; ++i) {
76 EXPECT_TRUE(dlrr.AddDlrrItem(kSsrc + i, kLastRR + i, kDelay + i)); 76 EXPECT_TRUE(dlrr.WithDlrrItem(kSsrc + i, kLastRR + i, kDelay + i));
77 } 77 }
78 EXPECT_FALSE(dlrr.AddDlrrItem(kSsrc, kLastRR, kDelay)); 78 EXPECT_FALSE(dlrr.WithDlrrItem(kSsrc, kLastRR, kDelay));
79 } 79 }
80 80
81 TEST(RtcpPacketDlrrTest, CreateAndParseMaxSubBlocks) { 81 TEST(RtcpPacketDlrrTest, CreateAndParseMaxSubBlocks) {
82 const size_t kBufferSize = 0x1000; // More than enough. 82 const size_t kBufferSize = 0x1000; // More than enough.
83 uint8_t buffer[kBufferSize]; 83 uint8_t buffer[kBufferSize];
84 84
85 // Create. 85 // Create.
86 Dlrr dlrr; 86 Dlrr dlrr;
87 for (size_t i = 1; i <= Dlrr::kMaxNumberOfDlrrItems; ++i) { 87 for (size_t i = 1; i <= Dlrr::kMaxNumberOfDlrrItems; ++i) {
88 EXPECT_TRUE(dlrr.AddDlrrItem(kSsrc + i, kLastRR + i, kDelay + i)); 88 EXPECT_TRUE(dlrr.WithDlrrItem(kSsrc + i, kLastRR + i, kDelay + i));
89 } 89 }
90 size_t used_buffer_size = dlrr.BlockLength(); 90 size_t used_buffer_size = dlrr.BlockLength();
91 ASSERT_LE(used_buffer_size, kBufferSize); 91 ASSERT_LE(used_buffer_size, kBufferSize);
92 dlrr.Create(buffer); 92 dlrr.Create(buffer);
93 93
94 // Parse. 94 // Parse.
95 Dlrr parsed; 95 Dlrr parsed;
96 uint16_t block_length = ByteReader<uint16_t>::ReadBigEndian(&buffer[2]); 96 uint16_t block_length = ByteReader<uint16_t>::ReadBigEndian(&buffer[2]);
97 EXPECT_EQ(used_buffer_size, (block_length + 1) * 4u); 97 EXPECT_EQ(used_buffer_size, (block_length + 1) * 4u);
98 EXPECT_TRUE(parsed.Parse(buffer, block_length)); 98 EXPECT_TRUE(parsed.Parse(buffer, block_length));
99 EXPECT_TRUE(parsed.sub_blocks().size() == Dlrr::kMaxNumberOfDlrrItems); 99 EXPECT_TRUE(parsed.sub_blocks().size() == Dlrr::kMaxNumberOfDlrrItems);
100 } 100 }
101 } // namespace webrtc 101 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698