OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 case rtclog::DelayBasedBweUpdate::BWE_NORMAL: | 49 case rtclog::DelayBasedBweUpdate::BWE_NORMAL: |
50 return kBwNormal; | 50 return kBwNormal; |
51 case rtclog::DelayBasedBweUpdate::BWE_UNDERUSING: | 51 case rtclog::DelayBasedBweUpdate::BWE_UNDERUSING: |
52 return kBwUnderusing; | 52 return kBwUnderusing; |
53 case rtclog::DelayBasedBweUpdate::BWE_OVERUSING: | 53 case rtclog::DelayBasedBweUpdate::BWE_OVERUSING: |
54 return kBwOverusing; | 54 return kBwOverusing; |
55 } | 55 } |
56 RTC_NOTREACHED(); | 56 RTC_NOTREACHED(); |
57 return kBwNormal; | 57 return kBwNormal; |
58 } | 58 } |
| 59 |
| 60 rtclog::BweProbeResult::ResultType GetProbeResultType( |
| 61 ProbeFailureReason failure_reason) { |
| 62 switch (failure_reason) { |
| 63 case kInvalidSendReceiveInterval: |
| 64 return rtclog::BweProbeResult::INVALID_SEND_RECEIVE_INTERVAL; |
| 65 case kInvalidSendReceiveRatio: |
| 66 return rtclog::BweProbeResult::INVALID_SEND_RECEIVE_RATIO; |
| 67 case kTimeout: |
| 68 return rtclog::BweProbeResult::TIMEOUT; |
| 69 } |
| 70 RTC_NOTREACHED(); |
| 71 return rtclog::BweProbeResult::SUCCESS; |
| 72 } |
59 } // namespace | 73 } // namespace |
60 | 74 |
61 // Checks that the event has a timestamp, a type and exactly the data field | 75 // Checks that the event has a timestamp, a type and exactly the data field |
62 // corresponding to the type. | 76 // corresponding to the type. |
63 ::testing::AssertionResult IsValidBasicEvent(const rtclog::Event& event) { | 77 ::testing::AssertionResult IsValidBasicEvent(const rtclog::Event& event) { |
64 if (!event.has_timestamp_us()) { | 78 if (!event.has_timestamp_us()) { |
65 return ::testing::AssertionFailure() << "Event has no timestamp"; | 79 return ::testing::AssertionFailure() << "Event has no timestamp"; |
66 } | 80 } |
67 if (!event.has_type()) { | 81 if (!event.has_type()) { |
68 return ::testing::AssertionFailure() << "Event has no event type"; | 82 return ::testing::AssertionFailure() << "Event has no event type"; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 << (event.has_audio_sender_config() ? "" : "no ") | 139 << (event.has_audio_sender_config() ? "" : "no ") |
126 << "audio sender config"; | 140 << "audio sender config"; |
127 } | 141 } |
128 if ((type == rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT) != | 142 if ((type == rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT) != |
129 event.has_audio_network_adaptation()) { | 143 event.has_audio_network_adaptation()) { |
130 return ::testing::AssertionFailure() | 144 return ::testing::AssertionFailure() |
131 << "Event of type " << type << " has " | 145 << "Event of type " << type << " has " |
132 << (event.has_audio_network_adaptation() ? "" : "no ") | 146 << (event.has_audio_network_adaptation() ? "" : "no ") |
133 << "audio network adaptation"; | 147 << "audio network adaptation"; |
134 } | 148 } |
| 149 if ((type == rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT) != |
| 150 event.has_probe_cluster()) { |
| 151 return ::testing::AssertionFailure() |
| 152 << "Event of type " << type << " has " |
| 153 << (event.has_probe_cluster() ? "" : "no ") << "bwe probe cluster"; |
| 154 } |
| 155 if ((type == rtclog::Event::BWE_PROBE_RESULT_EVENT) != |
| 156 event.has_probe_result()) { |
| 157 return ::testing::AssertionFailure() |
| 158 << "Event of type " << type << " has " |
| 159 << (event.has_probe_result() ? "" : "no ") << "bwe probe result"; |
| 160 } |
135 return ::testing::AssertionSuccess(); | 161 return ::testing::AssertionSuccess(); |
136 } | 162 } |
137 | 163 |
138 void RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig( | 164 void RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig( |
139 const ParsedRtcEventLog& parsed_log, | 165 const ParsedRtcEventLog& parsed_log, |
140 size_t index, | 166 size_t index, |
141 const VideoReceiveStream::Config& config) { | 167 const VideoReceiveStream::Config& config) { |
142 const rtclog::Event& event = parsed_log.events_[index]; | 168 const rtclog::Event& event = parsed_log.events_[index]; |
143 ASSERT_TRUE(IsValidBasicEvent(event)); | 169 ASSERT_TRUE(IsValidBasicEvent(event)); |
144 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type()); | 170 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type()); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 } | 569 } |
544 | 570 |
545 void RtcEventLogTestHelper::VerifyLogEndEvent( | 571 void RtcEventLogTestHelper::VerifyLogEndEvent( |
546 const ParsedRtcEventLog& parsed_log, | 572 const ParsedRtcEventLog& parsed_log, |
547 size_t index) { | 573 size_t index) { |
548 const rtclog::Event& event = parsed_log.events_[index]; | 574 const rtclog::Event& event = parsed_log.events_[index]; |
549 ASSERT_TRUE(IsValidBasicEvent(event)); | 575 ASSERT_TRUE(IsValidBasicEvent(event)); |
550 EXPECT_EQ(rtclog::Event::LOG_END, event.type()); | 576 EXPECT_EQ(rtclog::Event::LOG_END, event.type()); |
551 } | 577 } |
552 | 578 |
| 579 void RtcEventLogTestHelper::VerifyBweProbeCluster( |
| 580 const ParsedRtcEventLog& parsed_log, |
| 581 size_t index, |
| 582 uint32_t id, |
| 583 uint32_t bitrate_bps, |
| 584 uint32_t min_probes, |
| 585 uint32_t min_bytes) { |
| 586 const rtclog::Event& event = parsed_log.events_[index]; |
| 587 ASSERT_TRUE(IsValidBasicEvent(event)); |
| 588 EXPECT_EQ(rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT, event.type()); |
| 589 |
| 590 const rtclog::BweProbeCluster& bwe_event = event.probe_cluster(); |
| 591 ASSERT_TRUE(bwe_event.has_id()); |
| 592 EXPECT_EQ(id, bwe_event.id()); |
| 593 ASSERT_TRUE(bwe_event.has_bitrate_bps()); |
| 594 EXPECT_EQ(bitrate_bps, bwe_event.bitrate_bps()); |
| 595 ASSERT_TRUE(bwe_event.has_min_packets()); |
| 596 EXPECT_EQ(min_probes, bwe_event.min_packets()); |
| 597 ASSERT_TRUE(bwe_event.has_min_bytes()); |
| 598 EXPECT_EQ(min_bytes, bwe_event.min_bytes()); |
| 599 |
| 600 // TODO(philipel): Verify the parser when parsing has been implemented. |
| 601 } |
| 602 |
| 603 void RtcEventLogTestHelper::VerifyProbeResultSuccess( |
| 604 const ParsedRtcEventLog& parsed_log, |
| 605 size_t index, |
| 606 uint32_t id, |
| 607 uint32_t bitrate_bps) { |
| 608 const rtclog::Event& event = parsed_log.events_[index]; |
| 609 ASSERT_TRUE(IsValidBasicEvent(event)); |
| 610 EXPECT_EQ(rtclog::Event::BWE_PROBE_RESULT_EVENT, event.type()); |
| 611 |
| 612 const rtclog::BweProbeResult& bwe_event = event.probe_result(); |
| 613 ASSERT_TRUE(bwe_event.has_id()); |
| 614 EXPECT_EQ(id, bwe_event.id()); |
| 615 ASSERT_TRUE(bwe_event.has_bitrate_bps()); |
| 616 EXPECT_EQ(bitrate_bps, bwe_event.bitrate_bps()); |
| 617 ASSERT_TRUE(bwe_event.has_result()); |
| 618 EXPECT_EQ(rtclog::BweProbeResult::SUCCESS, bwe_event.result()); |
| 619 |
| 620 // TODO(philipel): Verify the parser when parsing has been implemented. |
| 621 } |
| 622 |
| 623 void RtcEventLogTestHelper::VerifyProbeResultFailure( |
| 624 const ParsedRtcEventLog& parsed_log, |
| 625 size_t index, |
| 626 uint32_t id, |
| 627 ProbeFailureReason failure_reason) { |
| 628 const rtclog::Event& event = parsed_log.events_[index]; |
| 629 ASSERT_TRUE(IsValidBasicEvent(event)); |
| 630 EXPECT_EQ(rtclog::Event::BWE_PROBE_RESULT_EVENT, event.type()); |
| 631 |
| 632 const rtclog::BweProbeResult& bwe_event = event.probe_result(); |
| 633 ASSERT_TRUE(bwe_event.has_id()); |
| 634 EXPECT_EQ(id, bwe_event.id()); |
| 635 ASSERT_TRUE(bwe_event.has_result()); |
| 636 EXPECT_EQ(GetProbeResultType(failure_reason), bwe_event.result()); |
| 637 ASSERT_FALSE(bwe_event.has_bitrate_bps()); |
| 638 |
| 639 // TODO(philipel): Verify the parser when parsing has been implemented. |
| 640 } |
| 641 |
553 } // namespace webrtc | 642 } // namespace webrtc |
OLD | NEW |