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

Side by Side Diff: webrtc/call/rtc_event_log_unittest_helper.cc

Issue 2253943006: Method to parse event log directly from a string. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Dont check for eof if checking bytes read anyway. Created 4 years, 3 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/call/rtc_event_log_parser.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
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 << (event.has_audio_sender_config() ? "" : "no ") 101 << (event.has_audio_sender_config() ? "" : "no ")
102 << "audio sender config"; 102 << "audio sender config";
103 } 103 }
104 return ::testing::AssertionSuccess(); 104 return ::testing::AssertionSuccess();
105 } 105 }
106 106
107 void RtcEventLogTestHelper::VerifyReceiveStreamConfig( 107 void RtcEventLogTestHelper::VerifyReceiveStreamConfig(
108 const ParsedRtcEventLog& parsed_log, 108 const ParsedRtcEventLog& parsed_log,
109 size_t index, 109 size_t index,
110 const VideoReceiveStream::Config& config) { 110 const VideoReceiveStream::Config& config) {
111 const rtclog::Event& event = parsed_log.stream_[index]; 111 const rtclog::Event& event = parsed_log.events_[index];
112 ASSERT_TRUE(IsValidBasicEvent(event)); 112 ASSERT_TRUE(IsValidBasicEvent(event));
113 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type()); 113 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type());
114 const rtclog::VideoReceiveConfig& receiver_config = 114 const rtclog::VideoReceiveConfig& receiver_config =
115 event.video_receiver_config(); 115 event.video_receiver_config();
116 // Check SSRCs. 116 // Check SSRCs.
117 ASSERT_TRUE(receiver_config.has_remote_ssrc()); 117 ASSERT_TRUE(receiver_config.has_remote_ssrc());
118 EXPECT_EQ(config.rtp.remote_ssrc, receiver_config.remote_ssrc()); 118 EXPECT_EQ(config.rtp.remote_ssrc, receiver_config.remote_ssrc());
119 ASSERT_TRUE(receiver_config.has_local_ssrc()); 119 ASSERT_TRUE(receiver_config.has_local_ssrc());
120 EXPECT_EQ(config.rtp.local_ssrc, receiver_config.local_ssrc()); 120 EXPECT_EQ(config.rtp.local_ssrc, receiver_config.local_ssrc());
121 // Check RTCP settings. 121 // Check RTCP settings.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 parsed_config.decoders[i].payload_name); 197 parsed_config.decoders[i].payload_name);
198 EXPECT_EQ(config.decoders[i].payload_type, 198 EXPECT_EQ(config.decoders[i].payload_type,
199 parsed_config.decoders[i].payload_type); 199 parsed_config.decoders[i].payload_type);
200 } 200 }
201 } 201 }
202 202
203 void RtcEventLogTestHelper::VerifySendStreamConfig( 203 void RtcEventLogTestHelper::VerifySendStreamConfig(
204 const ParsedRtcEventLog& parsed_log, 204 const ParsedRtcEventLog& parsed_log,
205 size_t index, 205 size_t index,
206 const VideoSendStream::Config& config) { 206 const VideoSendStream::Config& config) {
207 const rtclog::Event& event = parsed_log.stream_[index]; 207 const rtclog::Event& event = parsed_log.events_[index];
208 ASSERT_TRUE(IsValidBasicEvent(event)); 208 ASSERT_TRUE(IsValidBasicEvent(event));
209 ASSERT_EQ(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT, event.type()); 209 ASSERT_EQ(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT, event.type());
210 const rtclog::VideoSendConfig& sender_config = event.video_sender_config(); 210 const rtclog::VideoSendConfig& sender_config = event.video_sender_config();
211 // Check SSRCs. 211 // Check SSRCs.
212 ASSERT_EQ(static_cast<int>(config.rtp.ssrcs.size()), 212 ASSERT_EQ(static_cast<int>(config.rtp.ssrcs.size()),
213 sender_config.ssrcs_size()); 213 sender_config.ssrcs_size());
214 for (int i = 0; i < sender_config.ssrcs_size(); i++) { 214 for (int i = 0; i < sender_config.ssrcs_size(); i++) {
215 EXPECT_EQ(config.rtp.ssrcs[i], sender_config.ssrcs(i)); 215 EXPECT_EQ(config.rtp.ssrcs[i], sender_config.ssrcs(i));
216 } 216 }
217 // Check header extensions. 217 // Check header extensions.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 parsed_config.encoder_settings.payload_type); 272 parsed_config.encoder_settings.payload_type);
273 } 273 }
274 274
275 void RtcEventLogTestHelper::VerifyRtpEvent(const ParsedRtcEventLog& parsed_log, 275 void RtcEventLogTestHelper::VerifyRtpEvent(const ParsedRtcEventLog& parsed_log,
276 size_t index, 276 size_t index,
277 PacketDirection direction, 277 PacketDirection direction,
278 MediaType media_type, 278 MediaType media_type,
279 const uint8_t* header, 279 const uint8_t* header,
280 size_t header_size, 280 size_t header_size,
281 size_t total_size) { 281 size_t total_size) {
282 const rtclog::Event& event = parsed_log.stream_[index]; 282 const rtclog::Event& event = parsed_log.events_[index];
283 ASSERT_TRUE(IsValidBasicEvent(event)); 283 ASSERT_TRUE(IsValidBasicEvent(event));
284 ASSERT_EQ(rtclog::Event::RTP_EVENT, event.type()); 284 ASSERT_EQ(rtclog::Event::RTP_EVENT, event.type());
285 const rtclog::RtpPacket& rtp_packet = event.rtp_packet(); 285 const rtclog::RtpPacket& rtp_packet = event.rtp_packet();
286 ASSERT_TRUE(rtp_packet.has_incoming()); 286 ASSERT_TRUE(rtp_packet.has_incoming());
287 EXPECT_EQ(direction == kIncomingPacket, rtp_packet.incoming()); 287 EXPECT_EQ(direction == kIncomingPacket, rtp_packet.incoming());
288 ASSERT_TRUE(rtp_packet.has_type()); 288 ASSERT_TRUE(rtp_packet.has_type());
289 EXPECT_EQ(media_type, GetRuntimeMediaType(rtp_packet.type())); 289 EXPECT_EQ(media_type, GetRuntimeMediaType(rtp_packet.type()));
290 ASSERT_TRUE(rtp_packet.has_packet_length()); 290 ASSERT_TRUE(rtp_packet.has_packet_length());
291 EXPECT_EQ(total_size, rtp_packet.packet_length()); 291 EXPECT_EQ(total_size, rtp_packet.packet_length());
292 ASSERT_TRUE(rtp_packet.has_header()); 292 ASSERT_TRUE(rtp_packet.has_header());
(...skipping 16 matching lines...) Expand all
309 EXPECT_EQ(0, std::memcmp(header, parsed_header, header_size)); 309 EXPECT_EQ(0, std::memcmp(header, parsed_header, header_size));
310 EXPECT_EQ(total_size, parsed_total_size); 310 EXPECT_EQ(total_size, parsed_total_size);
311 } 311 }
312 312
313 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log, 313 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log,
314 size_t index, 314 size_t index,
315 PacketDirection direction, 315 PacketDirection direction,
316 MediaType media_type, 316 MediaType media_type,
317 const uint8_t* packet, 317 const uint8_t* packet,
318 size_t total_size) { 318 size_t total_size) {
319 const rtclog::Event& event = parsed_log.stream_[index]; 319 const rtclog::Event& event = parsed_log.events_[index];
320 ASSERT_TRUE(IsValidBasicEvent(event)); 320 ASSERT_TRUE(IsValidBasicEvent(event));
321 ASSERT_EQ(rtclog::Event::RTCP_EVENT, event.type()); 321 ASSERT_EQ(rtclog::Event::RTCP_EVENT, event.type());
322 const rtclog::RtcpPacket& rtcp_packet = event.rtcp_packet(); 322 const rtclog::RtcpPacket& rtcp_packet = event.rtcp_packet();
323 ASSERT_TRUE(rtcp_packet.has_incoming()); 323 ASSERT_TRUE(rtcp_packet.has_incoming());
324 EXPECT_EQ(direction == kIncomingPacket, rtcp_packet.incoming()); 324 EXPECT_EQ(direction == kIncomingPacket, rtcp_packet.incoming());
325 ASSERT_TRUE(rtcp_packet.has_type()); 325 ASSERT_TRUE(rtcp_packet.has_type());
326 EXPECT_EQ(media_type, GetRuntimeMediaType(rtcp_packet.type())); 326 EXPECT_EQ(media_type, GetRuntimeMediaType(rtcp_packet.type()));
327 ASSERT_TRUE(rtcp_packet.has_packet_data()); 327 ASSERT_TRUE(rtcp_packet.has_packet_data());
328 ASSERT_EQ(total_size, rtcp_packet.packet_data().size()); 328 ASSERT_EQ(total_size, rtcp_packet.packet_data().size());
329 for (size_t i = 0; i < total_size; i++) { 329 for (size_t i = 0; i < total_size; i++) {
(...skipping 10 matching lines...) Expand all
340 EXPECT_EQ(direction, parsed_direction); 340 EXPECT_EQ(direction, parsed_direction);
341 EXPECT_EQ(media_type, parsed_media_type); 341 EXPECT_EQ(media_type, parsed_media_type);
342 ASSERT_EQ(total_size, parsed_total_size); 342 ASSERT_EQ(total_size, parsed_total_size);
343 EXPECT_EQ(0, std::memcmp(packet, parsed_packet, total_size)); 343 EXPECT_EQ(0, std::memcmp(packet, parsed_packet, total_size));
344 } 344 }
345 345
346 void RtcEventLogTestHelper::VerifyPlayoutEvent( 346 void RtcEventLogTestHelper::VerifyPlayoutEvent(
347 const ParsedRtcEventLog& parsed_log, 347 const ParsedRtcEventLog& parsed_log,
348 size_t index, 348 size_t index,
349 uint32_t ssrc) { 349 uint32_t ssrc) {
350 const rtclog::Event& event = parsed_log.stream_[index]; 350 const rtclog::Event& event = parsed_log.events_[index];
351 ASSERT_TRUE(IsValidBasicEvent(event)); 351 ASSERT_TRUE(IsValidBasicEvent(event));
352 ASSERT_EQ(rtclog::Event::AUDIO_PLAYOUT_EVENT, event.type()); 352 ASSERT_EQ(rtclog::Event::AUDIO_PLAYOUT_EVENT, event.type());
353 const rtclog::AudioPlayoutEvent& playout_event = event.audio_playout_event(); 353 const rtclog::AudioPlayoutEvent& playout_event = event.audio_playout_event();
354 ASSERT_TRUE(playout_event.has_local_ssrc()); 354 ASSERT_TRUE(playout_event.has_local_ssrc());
355 EXPECT_EQ(ssrc, playout_event.local_ssrc()); 355 EXPECT_EQ(ssrc, playout_event.local_ssrc());
356 356
357 // Check consistency of the parser. 357 // Check consistency of the parser.
358 uint32_t parsed_ssrc; 358 uint32_t parsed_ssrc;
359 parsed_log.GetAudioPlayout(index, &parsed_ssrc); 359 parsed_log.GetAudioPlayout(index, &parsed_ssrc);
360 EXPECT_EQ(ssrc, parsed_ssrc); 360 EXPECT_EQ(ssrc, parsed_ssrc);
361 } 361 }
362 362
363 void RtcEventLogTestHelper::VerifyBweLossEvent( 363 void RtcEventLogTestHelper::VerifyBweLossEvent(
364 const ParsedRtcEventLog& parsed_log, 364 const ParsedRtcEventLog& parsed_log,
365 size_t index, 365 size_t index,
366 int32_t bitrate, 366 int32_t bitrate,
367 uint8_t fraction_loss, 367 uint8_t fraction_loss,
368 int32_t total_packets) { 368 int32_t total_packets) {
369 const rtclog::Event& event = parsed_log.stream_[index]; 369 const rtclog::Event& event = parsed_log.events_[index];
370 ASSERT_TRUE(IsValidBasicEvent(event)); 370 ASSERT_TRUE(IsValidBasicEvent(event));
371 ASSERT_EQ(rtclog::Event::BWE_PACKET_LOSS_EVENT, event.type()); 371 ASSERT_EQ(rtclog::Event::BWE_PACKET_LOSS_EVENT, event.type());
372 const rtclog::BwePacketLossEvent& bwe_event = event.bwe_packet_loss_event(); 372 const rtclog::BwePacketLossEvent& bwe_event = event.bwe_packet_loss_event();
373 ASSERT_TRUE(bwe_event.has_bitrate()); 373 ASSERT_TRUE(bwe_event.has_bitrate());
374 EXPECT_EQ(bitrate, bwe_event.bitrate()); 374 EXPECT_EQ(bitrate, bwe_event.bitrate());
375 ASSERT_TRUE(bwe_event.has_fraction_loss()); 375 ASSERT_TRUE(bwe_event.has_fraction_loss());
376 EXPECT_EQ(fraction_loss, bwe_event.fraction_loss()); 376 EXPECT_EQ(fraction_loss, bwe_event.fraction_loss());
377 ASSERT_TRUE(bwe_event.has_total_packets()); 377 ASSERT_TRUE(bwe_event.has_total_packets());
378 EXPECT_EQ(total_packets, bwe_event.total_packets()); 378 EXPECT_EQ(total_packets, bwe_event.total_packets());
379 379
380 // Check consistency of the parser. 380 // Check consistency of the parser.
381 int32_t parsed_bitrate; 381 int32_t parsed_bitrate;
382 uint8_t parsed_fraction_loss; 382 uint8_t parsed_fraction_loss;
383 int32_t parsed_total_packets; 383 int32_t parsed_total_packets;
384 parsed_log.GetBwePacketLossEvent( 384 parsed_log.GetBwePacketLossEvent(
385 index, &parsed_bitrate, &parsed_fraction_loss, &parsed_total_packets); 385 index, &parsed_bitrate, &parsed_fraction_loss, &parsed_total_packets);
386 EXPECT_EQ(bitrate, parsed_bitrate); 386 EXPECT_EQ(bitrate, parsed_bitrate);
387 EXPECT_EQ(fraction_loss, parsed_fraction_loss); 387 EXPECT_EQ(fraction_loss, parsed_fraction_loss);
388 EXPECT_EQ(total_packets, parsed_total_packets); 388 EXPECT_EQ(total_packets, parsed_total_packets);
389 } 389 }
390 390
391 void RtcEventLogTestHelper::VerifyLogStartEvent( 391 void RtcEventLogTestHelper::VerifyLogStartEvent(
392 const ParsedRtcEventLog& parsed_log, 392 const ParsedRtcEventLog& parsed_log,
393 size_t index) { 393 size_t index) {
394 const rtclog::Event& event = parsed_log.stream_[index]; 394 const rtclog::Event& event = parsed_log.events_[index];
395 ASSERT_TRUE(IsValidBasicEvent(event)); 395 ASSERT_TRUE(IsValidBasicEvent(event));
396 EXPECT_EQ(rtclog::Event::LOG_START, event.type()); 396 EXPECT_EQ(rtclog::Event::LOG_START, event.type());
397 } 397 }
398 398
399 void RtcEventLogTestHelper::VerifyLogEndEvent( 399 void RtcEventLogTestHelper::VerifyLogEndEvent(
400 const ParsedRtcEventLog& parsed_log, 400 const ParsedRtcEventLog& parsed_log,
401 size_t index) { 401 size_t index) {
402 const rtclog::Event& event = parsed_log.stream_[index]; 402 const rtclog::Event& event = parsed_log.events_[index];
403 ASSERT_TRUE(IsValidBasicEvent(event)); 403 ASSERT_TRUE(IsValidBasicEvent(event));
404 EXPECT_EQ(rtclog::Event::LOG_END, event.type()); 404 EXPECT_EQ(rtclog::Event::LOG_END, event.type());
405 } 405 }
406 406
407 } // namespace webrtc 407 } // namespace webrtc
408 408
409 #endif // ENABLE_RTC_EVENT_LOG 409 #endif // ENABLE_RTC_EVENT_LOG
OLDNEW
« no previous file with comments | « webrtc/call/rtc_event_log_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698