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 24 matching lines...) Expand all Loading... | |
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 rtclog::BweProbeResult::ResultType ConvertProbeResultType( | |
47 ProbeFailureReason failure_reason) { | |
48 switch (failure_reason) { | |
49 case kInvalidSendReceiveInterval: | |
50 return rtclog::BweProbeResult::INVALID_SEND_RECEIVE_INTERVAL; | |
51 case kInvalidSendReceiveRatio: | |
52 return rtclog::BweProbeResult::INVALID_SEND_RECEIVE_RATIO; | |
53 case kTimeout: | |
54 return rtclog::BweProbeResult::TIMEOUT; | |
55 } | |
56 RTC_NOTREACHED(); | |
57 return rtclog::BweProbeResult::SUCCESS; | |
58 } | |
59 | |
45 } // namespace | 60 } // namespace |
46 | 61 |
47 // Checks that the event has a timestamp, a type and exactly the data field | 62 // Checks that the event has a timestamp, a type and exactly the data field |
48 // corresponding to the type. | 63 // corresponding to the type. |
49 ::testing::AssertionResult IsValidBasicEvent(const rtclog::Event& event) { | 64 ::testing::AssertionResult IsValidBasicEvent(const rtclog::Event& event) { |
50 if (!event.has_timestamp_us()) { | 65 if (!event.has_timestamp_us()) { |
51 return ::testing::AssertionFailure() << "Event has no timestamp"; | 66 return ::testing::AssertionFailure() << "Event has no timestamp"; |
52 } | 67 } |
53 if (!event.has_type()) { | 68 if (!event.has_type()) { |
54 return ::testing::AssertionFailure() << "Event has no event type"; | 69 return ::testing::AssertionFailure() << "Event has no event type"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 << (event.has_audio_receiver_config() ? "" : "no ") | 106 << (event.has_audio_receiver_config() ? "" : "no ") |
92 << "audio receiver config"; | 107 << "audio receiver config"; |
93 } | 108 } |
94 if ((type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT) != | 109 if ((type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT) != |
95 event.has_audio_sender_config()) { | 110 event.has_audio_sender_config()) { |
96 return ::testing::AssertionFailure() | 111 return ::testing::AssertionFailure() |
97 << "Event of type " << type << " has " | 112 << "Event of type " << type << " has " |
98 << (event.has_audio_sender_config() ? "" : "no ") | 113 << (event.has_audio_sender_config() ? "" : "no ") |
99 << "audio sender config"; | 114 << "audio sender config"; |
100 } | 115 } |
116 if ((type == rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT) != | |
117 event.has_probe_cluster()) { | |
118 return ::testing::AssertionFailure() | |
119 << "Event of type " << type << " has " | |
120 << (event.has_probe_cluster() ? "" : "no ") << "bwe probe cluster"; | |
121 } | |
122 if ((type == rtclog::Event::BWE_PROBE_RESULT_EVENT) != | |
123 event.has_probe_result()) { | |
124 return ::testing::AssertionFailure() | |
125 << "Event of type " << type << " has " | |
126 << (event.has_probe_result() ? "" : "no ") << "bwe probe result"; | |
127 } | |
128 | |
101 return ::testing::AssertionSuccess(); | 129 return ::testing::AssertionSuccess(); |
102 } | 130 } |
103 | 131 |
104 void RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig( | 132 void RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig( |
105 const ParsedRtcEventLog& parsed_log, | 133 const ParsedRtcEventLog& parsed_log, |
106 size_t index, | 134 size_t index, |
107 const VideoReceiveStream::Config& config) { | 135 const VideoReceiveStream::Config& config) { |
108 const rtclog::Event& event = parsed_log.events_[index]; | 136 const rtclog::Event& event = parsed_log.events_[index]; |
109 ASSERT_TRUE(IsValidBasicEvent(event)); | 137 ASSERT_TRUE(IsValidBasicEvent(event)); |
110 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type()); | 138 ASSERT_EQ(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT, event.type()); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 } | 513 } |
486 | 514 |
487 void RtcEventLogTestHelper::VerifyLogEndEvent( | 515 void RtcEventLogTestHelper::VerifyLogEndEvent( |
488 const ParsedRtcEventLog& parsed_log, | 516 const ParsedRtcEventLog& parsed_log, |
489 size_t index) { | 517 size_t index) { |
490 const rtclog::Event& event = parsed_log.events_[index]; | 518 const rtclog::Event& event = parsed_log.events_[index]; |
491 ASSERT_TRUE(IsValidBasicEvent(event)); | 519 ASSERT_TRUE(IsValidBasicEvent(event)); |
492 EXPECT_EQ(rtclog::Event::LOG_END, event.type()); | 520 EXPECT_EQ(rtclog::Event::LOG_END, event.type()); |
493 } | 521 } |
494 | 522 |
523 void RtcEventLogTestHelper::VerifyBweProbeCluster( | |
524 const ParsedRtcEventLog& parsed_log, | |
525 size_t index, | |
526 uint32_t id, | |
527 uint32_t bitrate_bps, | |
528 uint32_t min_probes, | |
terelius
2017/02/20 14:00:31
probes -> packets
| |
529 uint32_t min_bytes) { | |
530 const rtclog::Event& event = parsed_log.events_[index]; | |
531 ASSERT_TRUE(IsValidBasicEvent(event)); | |
532 EXPECT_EQ(rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT, event.type()); | |
533 | |
534 const rtclog::BweProbeCluster& bwe_event = event.probe_cluster(); | |
535 ASSERT_TRUE(bwe_event.has_id()); | |
536 EXPECT_EQ(id, bwe_event.id()); | |
537 ASSERT_TRUE(bwe_event.has_bitrate_bps()); | |
538 EXPECT_EQ(bitrate_bps, bwe_event.bitrate_bps()); | |
539 ASSERT_TRUE(bwe_event.has_min_packets()); | |
540 EXPECT_EQ(min_probes, bwe_event.min_packets()); | |
541 ASSERT_TRUE(bwe_event.has_min_bytes()); | |
542 EXPECT_EQ(min_bytes, bwe_event.min_bytes()); | |
543 | |
544 // TODO(philipel): Verify the parser when parsing has been implemented. | |
545 } | |
546 | |
547 void RtcEventLogTestHelper::VerifyProbeResultSuccess( | |
548 const ParsedRtcEventLog& parsed_log, | |
549 size_t index, | |
550 uint32_t id, | |
551 uint32_t bitrate_bps) { | |
552 const rtclog::Event& event = parsed_log.events_[index]; | |
553 ASSERT_TRUE(IsValidBasicEvent(event)); | |
554 EXPECT_EQ(rtclog::Event::BWE_PROBE_RESULT_EVENT, event.type()); | |
555 | |
556 const rtclog::BweProbeResult& bwe_event = event.probe_result(); | |
557 ASSERT_TRUE(bwe_event.has_id()); | |
558 EXPECT_EQ(id, bwe_event.id()); | |
559 ASSERT_TRUE(bwe_event.has_bitrate_bps()); | |
560 EXPECT_EQ(bitrate_bps, bwe_event.bitrate_bps()); | |
561 ASSERT_TRUE(bwe_event.has_result()); | |
562 EXPECT_EQ(rtclog::BweProbeResult::SUCCESS, bwe_event.result()); | |
563 | |
564 // TODO(philipel): Verify the parser when parsing has been implemented. | |
565 } | |
566 | |
567 void RtcEventLogTestHelper::VerifyProbeResultFailure( | |
568 const ParsedRtcEventLog& parsed_log, | |
569 size_t index, | |
570 uint32_t id, | |
571 ProbeFailureReason failure_reason) { | |
572 const rtclog::Event& event = parsed_log.events_[index]; | |
573 ASSERT_TRUE(IsValidBasicEvent(event)); | |
574 EXPECT_EQ(rtclog::Event::BWE_PROBE_RESULT_EVENT, event.type()); | |
575 | |
576 const rtclog::BweProbeResult& bwe_event = event.probe_result(); | |
577 ASSERT_TRUE(bwe_event.has_id()); | |
578 EXPECT_EQ(id, bwe_event.id()); | |
579 ASSERT_TRUE(bwe_event.has_result()); | |
580 EXPECT_EQ(ConvertProbeResultType(failure_reason), bwe_event.result()); | |
581 ASSERT_FALSE(bwe_event.has_bitrate_bps()); | |
582 | |
583 // TODO(philipel): Verify the parser when parsing has been implemented. | |
584 } | |
585 | |
495 } // namespace webrtc | 586 } // namespace webrtc |
OLD | NEW |