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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet_unittest.cc

Issue 1434213004: rtcp::Ij renamed to rtcp::ExtendedJitterReport and moved into own file (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 * This file includes unit tests for the RtcpPacket. 10 * This file includes unit tests for the RtcpPacket.
11 */ 11 */
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 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
17 #include "webrtc/test/rtcp_packet_parser.h" 18 #include "webrtc/test/rtcp_packet_parser.h"
18 19
19 using ::testing::ElementsAre; 20 using ::testing::ElementsAre;
20 21
21 using webrtc::rtcp::App; 22 using webrtc::rtcp::App;
22 using webrtc::rtcp::Bye; 23 using webrtc::rtcp::Bye;
23 using webrtc::rtcp::Dlrr; 24 using webrtc::rtcp::Dlrr;
24 using webrtc::rtcp::Empty; 25 using webrtc::rtcp::Empty;
25 using webrtc::rtcp::Fir; 26 using webrtc::rtcp::Fir;
26 using webrtc::rtcp::Ij; 27 using webrtc::rtcp::ExtendedJitterReport;
27 using webrtc::rtcp::Nack; 28 using webrtc::rtcp::Nack;
28 using webrtc::rtcp::Pli; 29 using webrtc::rtcp::Pli;
29 using webrtc::rtcp::Sdes; 30 using webrtc::rtcp::Sdes;
30 using webrtc::rtcp::SenderReport; 31 using webrtc::rtcp::SenderReport;
31 using webrtc::rtcp::Sli; 32 using webrtc::rtcp::Sli;
32 using webrtc::rtcp::RawPacket; 33 using webrtc::rtcp::RawPacket;
33 using webrtc::rtcp::ReceiverReport; 34 using webrtc::rtcp::ReceiverReport;
34 using webrtc::rtcp::Remb; 35 using webrtc::rtcp::Remb;
35 using webrtc::rtcp::ReportBlock; 36 using webrtc::rtcp::ReportBlock;
36 using webrtc::rtcp::Rpsi; 37 using webrtc::rtcp::Rpsi;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const int kMaxReportBlocks = (1 << 5) - 1; 190 const int kMaxReportBlocks = (1 << 5) - 1;
190 ReportBlock rb; 191 ReportBlock rb;
191 for (int i = 0; i < kMaxReportBlocks; ++i) { 192 for (int i = 0; i < kMaxReportBlocks; ++i) {
192 rb.To(kRemoteSsrc + i); 193 rb.To(kRemoteSsrc + i);
193 EXPECT_TRUE(sr.WithReportBlock(rb)); 194 EXPECT_TRUE(sr.WithReportBlock(rb));
194 } 195 }
195 rb.To(kRemoteSsrc + kMaxReportBlocks); 196 rb.To(kRemoteSsrc + kMaxReportBlocks);
196 EXPECT_FALSE(sr.WithReportBlock(rb)); 197 EXPECT_FALSE(sr.WithReportBlock(rb));
197 } 198 }
198 199
199 TEST(RtcpPacketTest, IjNoItem) {
200 Ij ij;
201
202 rtc::scoped_ptr<RawPacket> packet(ij.Build());
203 RtcpPacketParser parser;
204 parser.Parse(packet->Buffer(), packet->Length());
205 EXPECT_EQ(1, parser.ij()->num_packets());
206 EXPECT_EQ(0, parser.ij_item()->num_packets());
207 }
208
209 TEST(RtcpPacketTest, IjOneItem) {
210 Ij ij;
211 EXPECT_TRUE(ij.WithJitterItem(0x11111111));
212
213 rtc::scoped_ptr<RawPacket> packet(ij.Build());
214 RtcpPacketParser parser;
215 parser.Parse(packet->Buffer(), packet->Length());
216 EXPECT_EQ(1, parser.ij()->num_packets());
217 EXPECT_EQ(1, parser.ij_item()->num_packets());
218 EXPECT_EQ(0x11111111U, parser.ij_item()->Jitter());
219 }
220
221 TEST(RtcpPacketTest, IjTwoItems) {
222 Ij ij;
223 EXPECT_TRUE(ij.WithJitterItem(0x11111111));
224 EXPECT_TRUE(ij.WithJitterItem(0x22222222));
225
226 rtc::scoped_ptr<RawPacket> packet(ij.Build());
227 RtcpPacketParser parser;
228 parser.Parse(packet->Buffer(), packet->Length());
229 EXPECT_EQ(1, parser.ij()->num_packets());
230 EXPECT_EQ(2, parser.ij_item()->num_packets());
231 EXPECT_EQ(0x22222222U, parser.ij_item()->Jitter());
232 }
233
234 TEST(RtcpPacketTest, IjTooManyItems) {
235 Ij ij;
236 const int kMaxIjItems = (1 << 5) - 1;
237 for (int i = 0; i < kMaxIjItems; ++i) {
238 EXPECT_TRUE(ij.WithJitterItem(i));
239 }
240 EXPECT_FALSE(ij.WithJitterItem(kMaxIjItems));
241 }
242
243 TEST(RtcpPacketTest, AppWithNoData) { 200 TEST(RtcpPacketTest, AppWithNoData) {
244 App app; 201 App app;
245 app.WithSubType(30); 202 app.WithSubType(30);
246 uint32_t name = 'n' << 24; 203 uint32_t name = 'n' << 24;
247 name += 'a' << 16; 204 name += 'a' << 16;
248 name += 'm' << 8; 205 name += 'm' << 8;
249 name += 'e'; 206 name += 'e';
250 app.WithName(name); 207 app.WithName(name);
251 208
252 rtc::scoped_ptr<RawPacket> packet(app.Build()); 209 rtc::scoped_ptr<RawPacket> packet(app.Build());
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 EXPECT_TRUE(xr.WithDlrr(&dlrr)); 1036 EXPECT_TRUE(xr.WithDlrr(&dlrr));
1080 EXPECT_FALSE(xr.WithDlrr(&dlrr)); 1037 EXPECT_FALSE(xr.WithDlrr(&dlrr));
1081 1038
1082 VoipMetric voip_metric; 1039 VoipMetric voip_metric;
1083 for (int i = 0; i < kMaxBlocks; ++i) 1040 for (int i = 0; i < kMaxBlocks; ++i)
1084 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); 1041 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric));
1085 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); 1042 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric));
1086 } 1043 }
1087 1044
1088 } // namespace webrtc 1045 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698