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

Side by Side Diff: webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc

Issue 2693213005: Rename some variables and methods in RTC event log. (Closed)
Patch Set: Unset-upstream Created 3 years, 10 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) 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 24 matching lines...) Expand all
35 case rtclog::MediaType::AUDIO: 35 case rtclog::MediaType::AUDIO:
36 return MediaType::AUDIO; 36 return MediaType::AUDIO;
37 case rtclog::MediaType::VIDEO: 37 case rtclog::MediaType::VIDEO:
38 return MediaType::VIDEO; 38 return MediaType::VIDEO;
39 case rtclog::MediaType::DATA: 39 case rtclog::MediaType::DATA:
40 return MediaType::DATA; 40 return MediaType::DATA;
41 } 41 }
42 RTC_NOTREACHED(); 42 RTC_NOTREACHED();
43 return MediaType::ANY; 43 return MediaType::ANY;
44 } 44 }
45
46 BandwidthUsage GetRuntimeDetectorState(
47 rtclog::DelayBasedBweUpdate::DetectorState detector_state) {
48 switch (detector_state) {
49 case rtclog::DelayBasedBweUpdate::BWE_NORMAL:
50 return kBwNormal;
51 case rtclog::DelayBasedBweUpdate::BWE_UNDERUSING:
52 return kBwUnderusing;
53 case rtclog::DelayBasedBweUpdate::BWE_OVERUSING:
54 return kBwOverusing;
55 }
56 RTC_NOTREACHED();
57 return kBwNormal;
58 }
45 } // namespace 59 } // namespace
46 60
47 // Checks that the event has a timestamp, a type and exactly the data field 61 // Checks that the event has a timestamp, a type and exactly the data field
48 // corresponding to the type. 62 // corresponding to the type.
49 ::testing::AssertionResult IsValidBasicEvent(const rtclog::Event& event) { 63 ::testing::AssertionResult IsValidBasicEvent(const rtclog::Event& event) {
50 if (!event.has_timestamp_us()) { 64 if (!event.has_timestamp_us()) {
51 return ::testing::AssertionFailure() << "Event has no timestamp"; 65 return ::testing::AssertionFailure() << "Event has no timestamp";
52 } 66 }
53 if (!event.has_type()) { 67 if (!event.has_type()) {
54 return ::testing::AssertionFailure() << "Event has no event type"; 68 return ::testing::AssertionFailure() << "Event has no event type";
55 } 69 }
56 rtclog::Event_EventType type = event.type(); 70 rtclog::Event_EventType type = event.type();
57 if ((type == rtclog::Event::RTP_EVENT) != event.has_rtp_packet()) { 71 if ((type == rtclog::Event::RTP_EVENT) != event.has_rtp_packet()) {
58 return ::testing::AssertionFailure() 72 return ::testing::AssertionFailure()
59 << "Event of type " << type << " has " 73 << "Event of type " << type << " has "
60 << (event.has_rtp_packet() ? "" : "no ") << "RTP packet"; 74 << (event.has_rtp_packet() ? "" : "no ") << "RTP packet";
61 } 75 }
62 if ((type == rtclog::Event::RTCP_EVENT) != event.has_rtcp_packet()) { 76 if ((type == rtclog::Event::RTCP_EVENT) != event.has_rtcp_packet()) {
63 return ::testing::AssertionFailure() 77 return ::testing::AssertionFailure()
64 << "Event of type " << type << " has " 78 << "Event of type " << type << " has "
65 << (event.has_rtcp_packet() ? "" : "no ") << "RTCP packet"; 79 << (event.has_rtcp_packet() ? "" : "no ") << "RTCP packet";
66 } 80 }
81 if ((type == rtclog::Event::LOSS_BASED_BWE_UPDATE) !=
82 event.has_loss_based_bwe_update()) {
83 return ::testing::AssertionFailure()
84 << "Event of type " << type << " has "
85 << (event.has_loss_based_bwe_update() ? "" : "no ") << "loss update";
86 }
87 if ((type == rtclog::Event::DELAY_BASED_BWE_UPDATE) !=
88 event.has_delay_based_bwe_update()) {
89 return ::testing::AssertionFailure()
90 << "Event of type " << type << " has "
91 << (event.has_delay_based_bwe_update() ? "" : "no ")
92 << "delay update";
93 }
67 if ((type == rtclog::Event::AUDIO_PLAYOUT_EVENT) != 94 if ((type == rtclog::Event::AUDIO_PLAYOUT_EVENT) !=
68 event.has_audio_playout_event()) { 95 event.has_audio_playout_event()) {
69 return ::testing::AssertionFailure() 96 return ::testing::AssertionFailure()
70 << "Event of type " << type << " has " 97 << "Event of type " << type << " has "
71 << (event.has_audio_playout_event() ? "" : "no ") 98 << (event.has_audio_playout_event() ? "" : "no ")
72 << "audio_playout event"; 99 << "audio_playout event";
73 } 100 }
74 if ((type == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT) != 101 if ((type == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT) !=
75 event.has_video_receiver_config()) { 102 event.has_video_receiver_config()) {
76 return ::testing::AssertionFailure() 103 return ::testing::AssertionFailure()
(...skipping 14 matching lines...) Expand all
91 << (event.has_audio_receiver_config() ? "" : "no ") 118 << (event.has_audio_receiver_config() ? "" : "no ")
92 << "audio receiver config"; 119 << "audio receiver config";
93 } 120 }
94 if ((type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT) != 121 if ((type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT) !=
95 event.has_audio_sender_config()) { 122 event.has_audio_sender_config()) {
96 return ::testing::AssertionFailure() 123 return ::testing::AssertionFailure()
97 << "Event of type " << type << " has " 124 << "Event of type " << type << " has "
98 << (event.has_audio_sender_config() ? "" : "no ") 125 << (event.has_audio_sender_config() ? "" : "no ")
99 << "audio sender config"; 126 << "audio sender config";
100 } 127 }
128 if ((type == rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT) !=
129 event.has_audio_network_adaptation()) {
130 return ::testing::AssertionFailure()
131 << "Event of type " << type << " has "
132 << (event.has_audio_network_adaptation() ? "" : "no ")
133 << "audio network adaptation";
134 }
101 return ::testing::AssertionSuccess(); 135 return ::testing::AssertionSuccess();
102 } 136 }
103 137
104 void RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig( 138 void RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig(
105 const ParsedRtcEventLog& parsed_log, 139 const ParsedRtcEventLog& parsed_log,
106 size_t index, 140 size_t index,
107 const VideoReceiveStream::Config& config) { 141 const VideoReceiveStream::Config& config) {
108 const rtclog::Event& event = parsed_log.events_[index]; 142 const rtclog::Event& event = parsed_log.events_[index];
109 ASSERT_TRUE(IsValidBasicEvent(event)); 143 ASSERT_TRUE(IsValidBasicEvent(event));
110 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type()); 144 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type());
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 468 }
435 469
436 void RtcEventLogTestHelper::VerifyBweLossEvent( 470 void RtcEventLogTestHelper::VerifyBweLossEvent(
437 const ParsedRtcEventLog& parsed_log, 471 const ParsedRtcEventLog& parsed_log,
438 size_t index, 472 size_t index,
439 int32_t bitrate, 473 int32_t bitrate,
440 uint8_t fraction_loss, 474 uint8_t fraction_loss,
441 int32_t total_packets) { 475 int32_t total_packets) {
442 const rtclog::Event& event = parsed_log.events_[index]; 476 const rtclog::Event& event = parsed_log.events_[index];
443 ASSERT_TRUE(IsValidBasicEvent(event)); 477 ASSERT_TRUE(IsValidBasicEvent(event));
444 ASSERT_EQ(rtclog::Event::BWE_PACKET_LOSS_EVENT, event.type()); 478 ASSERT_EQ(rtclog::Event::LOSS_BASED_BWE_UPDATE, event.type());
445 const rtclog::BwePacketLossEvent& bwe_event = event.bwe_packet_loss_event(); 479 const rtclog::LossBasedBweUpdate& bwe_event = event.loss_based_bwe_update();
446 ASSERT_TRUE(bwe_event.has_bitrate()); 480 ASSERT_TRUE(bwe_event.has_bitrate_bps());
447 EXPECT_EQ(bitrate, bwe_event.bitrate()); 481 EXPECT_EQ(bitrate, bwe_event.bitrate_bps());
448 ASSERT_TRUE(bwe_event.has_fraction_loss()); 482 ASSERT_TRUE(bwe_event.has_fraction_loss());
449 EXPECT_EQ(fraction_loss, bwe_event.fraction_loss()); 483 EXPECT_EQ(fraction_loss, bwe_event.fraction_loss());
450 ASSERT_TRUE(bwe_event.has_total_packets()); 484 ASSERT_TRUE(bwe_event.has_total_packets());
451 EXPECT_EQ(total_packets, bwe_event.total_packets()); 485 EXPECT_EQ(total_packets, bwe_event.total_packets());
452 486
453 // Check consistency of the parser. 487 // Check consistency of the parser.
454 int32_t parsed_bitrate; 488 int32_t parsed_bitrate;
455 uint8_t parsed_fraction_loss; 489 uint8_t parsed_fraction_loss;
456 int32_t parsed_total_packets; 490 int32_t parsed_total_packets;
457 parsed_log.GetBwePacketLossEvent( 491 parsed_log.GetLossBasedBweUpdate(
458 index, &parsed_bitrate, &parsed_fraction_loss, &parsed_total_packets); 492 index, &parsed_bitrate, &parsed_fraction_loss, &parsed_total_packets);
459 EXPECT_EQ(bitrate, parsed_bitrate); 493 EXPECT_EQ(bitrate, parsed_bitrate);
460 EXPECT_EQ(fraction_loss, parsed_fraction_loss); 494 EXPECT_EQ(fraction_loss, parsed_fraction_loss);
461 EXPECT_EQ(total_packets, parsed_total_packets); 495 EXPECT_EQ(total_packets, parsed_total_packets);
462 } 496 }
463 497
498 void RtcEventLogTestHelper::VerifyBweDelayEvent(
499 const ParsedRtcEventLog& parsed_log,
500 size_t index,
501 int32_t bitrate,
502 BandwidthUsage detector_state) {
503 const rtclog::Event& event = parsed_log.events_[index];
504 ASSERT_TRUE(IsValidBasicEvent(event));
505 ASSERT_EQ(rtclog::Event::DELAY_BASED_BWE_UPDATE, event.type());
506 const rtclog::DelayBasedBweUpdate& bwe_event = event.delay_based_bwe_update();
507 ASSERT_TRUE(bwe_event.has_bitrate_bps());
508 EXPECT_EQ(bitrate, bwe_event.bitrate_bps());
509 ASSERT_TRUE(bwe_event.has_detector_state());
510 EXPECT_EQ(detector_state,
511 GetRuntimeDetectorState(bwe_event.detector_state()));
512
513 // Check consistency of the parser.
514 int32_t parsed_bitrate;
515 BandwidthUsage parsed_detector_state;
516 parsed_log.GetDelayBasedBweUpdate(index, &parsed_bitrate,
517 &parsed_detector_state);
518 EXPECT_EQ(bitrate, parsed_bitrate);
519 EXPECT_EQ(detector_state, parsed_detector_state);
520 }
521
464 void RtcEventLogTestHelper::VerifyAudioNetworkAdaptation( 522 void RtcEventLogTestHelper::VerifyAudioNetworkAdaptation(
465 const ParsedRtcEventLog& parsed_log, 523 const ParsedRtcEventLog& parsed_log,
466 size_t index, 524 size_t index,
467 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) { 525 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) {
468 AudioNetworkAdaptor::EncoderRuntimeConfig parsed_config; 526 AudioNetworkAdaptor::EncoderRuntimeConfig parsed_config;
469 parsed_log.GetAudioNetworkAdaptation(index, &parsed_config); 527 parsed_log.GetAudioNetworkAdaptation(index, &parsed_config);
470 EXPECT_EQ(config.bitrate_bps, parsed_config.bitrate_bps); 528 EXPECT_EQ(config.bitrate_bps, parsed_config.bitrate_bps);
471 EXPECT_EQ(config.enable_dtx, parsed_config.enable_dtx); 529 EXPECT_EQ(config.enable_dtx, parsed_config.enable_dtx);
472 EXPECT_EQ(config.enable_fec, parsed_config.enable_fec); 530 EXPECT_EQ(config.enable_fec, parsed_config.enable_fec);
473 EXPECT_EQ(config.frame_length_ms, parsed_config.frame_length_ms); 531 EXPECT_EQ(config.frame_length_ms, parsed_config.frame_length_ms);
(...skipping 12 matching lines...) Expand all
486 544
487 void RtcEventLogTestHelper::VerifyLogEndEvent( 545 void RtcEventLogTestHelper::VerifyLogEndEvent(
488 const ParsedRtcEventLog& parsed_log, 546 const ParsedRtcEventLog& parsed_log,
489 size_t index) { 547 size_t index) {
490 const rtclog::Event& event = parsed_log.events_[index]; 548 const rtclog::Event& event = parsed_log.events_[index];
491 ASSERT_TRUE(IsValidBasicEvent(event)); 549 ASSERT_TRUE(IsValidBasicEvent(event));
492 EXPECT_EQ(rtclog::Event::LOG_END, event.type()); 550 EXPECT_EQ(rtclog::Event::LOG_END, event.type());
493 } 551 }
494 552
495 } // namespace webrtc 553 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698