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

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

Issue 2991623002: Add SetReportBlocks to rtcp Sender/Receive Report classes. (Closed)
Patch Set: fix typo Created 3 years, 4 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/sender_report.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/sender_report.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
12 12
13 #include <utility>
14
13 #include "webrtc/test/gmock.h" 15 #include "webrtc/test/gmock.h"
14 #include "webrtc/test/gtest.h" 16 #include "webrtc/test/gtest.h"
15 #include "webrtc/test/rtcp_packet_parser.h" 17 #include "webrtc/test/rtcp_packet_parser.h"
16 18
17 using testing::ElementsAreArray; 19 using testing::ElementsAreArray;
18 using testing::make_tuple; 20 using testing::make_tuple;
19 using webrtc::rtcp::ReportBlock; 21 using webrtc::rtcp::ReportBlock;
20 using webrtc::rtcp::SenderReport; 22 using webrtc::rtcp::SenderReport;
21 23
22 namespace webrtc { 24 namespace webrtc {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 96
95 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); 97 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
96 EXPECT_EQ(2u, parsed.report_blocks().size()); 98 EXPECT_EQ(2u, parsed.report_blocks().size());
97 EXPECT_EQ(kRemoteSsrc, parsed.report_blocks()[0].source_ssrc()); 99 EXPECT_EQ(kRemoteSsrc, parsed.report_blocks()[0].source_ssrc());
98 EXPECT_EQ(kRemoteSsrc + 1, parsed.report_blocks()[1].source_ssrc()); 100 EXPECT_EQ(kRemoteSsrc + 1, parsed.report_blocks()[1].source_ssrc());
99 } 101 }
100 102
101 TEST(RtcpPacketSenderReportTest, CreateWithTooManyReportBlocks) { 103 TEST(RtcpPacketSenderReportTest, CreateWithTooManyReportBlocks) {
102 SenderReport sr; 104 SenderReport sr;
103 sr.SetSenderSsrc(kSenderSsrc); 105 sr.SetSenderSsrc(kSenderSsrc);
104 const size_t kMaxReportBlocks = (1 << 5) - 1;
105 ReportBlock rb; 106 ReportBlock rb;
106 for (size_t i = 0; i < kMaxReportBlocks; ++i) { 107 for (size_t i = 0; i < SenderReport::kMaxNumberOfReportBlocks; ++i) {
107 rb.SetMediaSsrc(kRemoteSsrc + i); 108 rb.SetMediaSsrc(kRemoteSsrc + i);
108 EXPECT_TRUE(sr.AddReportBlock(rb)); 109 EXPECT_TRUE(sr.AddReportBlock(rb));
109 } 110 }
110 rb.SetMediaSsrc(kRemoteSsrc + kMaxReportBlocks); 111 rb.SetMediaSsrc(kRemoteSsrc + SenderReport::kMaxNumberOfReportBlocks);
111 EXPECT_FALSE(sr.AddReportBlock(rb)); 112 EXPECT_FALSE(sr.AddReportBlock(rb));
112 } 113 }
113 114
115 TEST(RtcpPacketSenderReportTest, SetReportBlocksOverwritesOldBlocks) {
116 SenderReport sr;
117 ReportBlock report_block;
118 // Use jitter field of the report blocks to distinguish them.
119 report_block.SetJitter(1001u);
120 sr.AddReportBlock(report_block);
121 ASSERT_EQ(sr.report_blocks().size(), 1u);
122 ASSERT_EQ(sr.report_blocks()[0].jitter(), 1001u);
123
124 std::vector<ReportBlock> blocks(3u);
125 blocks[0].SetJitter(2001u);
126 blocks[1].SetJitter(3001u);
127 blocks[2].SetJitter(4001u);
128 EXPECT_TRUE(sr.SetReportBlocks(blocks));
129 ASSERT_EQ(sr.report_blocks().size(), 3u);
130 EXPECT_EQ(sr.report_blocks()[0].jitter(), 2001u);
131 EXPECT_EQ(sr.report_blocks()[1].jitter(), 3001u);
132 EXPECT_EQ(sr.report_blocks()[2].jitter(), 4001u);
133 }
134
135 TEST(RtcpPacketSenderReportTest, SetReportBlocksMaxLimit) {
136 SenderReport sr;
137 std::vector<ReportBlock> max_blocks(SenderReport::kMaxNumberOfReportBlocks);
138 EXPECT_TRUE(sr.SetReportBlocks(std::move(max_blocks)));
139
140 std::vector<ReportBlock> one_too_many_blocks(
141 SenderReport::kMaxNumberOfReportBlocks + 1);
142 EXPECT_FALSE(sr.SetReportBlocks(std::move(one_too_many_blocks)));
143 }
144
114 } // namespace webrtc 145 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698