OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 RtcEventLogTestHelper::VerifyRtcpEvent(parsed_log, 2, kOutgoingPacket, | 493 RtcEventLogTestHelper::VerifyRtcpEvent(parsed_log, 2, kOutgoingPacket, |
494 MediaType::VIDEO, rtcp_packet.data(), | 494 MediaType::VIDEO, rtcp_packet.data(), |
495 rtcp_packet.size()); | 495 rtcp_packet.size()); |
496 | 496 |
497 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); | 497 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); |
498 | 498 |
499 // Clean up temporary file - can be pretty slow. | 499 // Clean up temporary file - can be pretty slow. |
500 remove(temp_filename.c_str()); | 500 remove(temp_filename.c_str()); |
501 } | 501 } |
502 | 502 |
503 TEST(RtcEventLogTest, LogProbeClusterCreatedAndReadBack) { | |
504 Random prng(794613); | |
505 | |
506 int bitrate_bps0 = prng.Rand(0, 10000000); | |
507 int bitrate_bps1 = prng.Rand(0, 10000000); | |
508 int bitrate_bps2 = prng.Rand(0, 10000000); | |
509 int min_probes0 = prng.Rand(0, 100); | |
terelius
2017/02/20 14:00:31
probes -> packets
| |
510 int min_probes1 = prng.Rand(0, 100); | |
511 int min_probes2 = prng.Rand(0, 100); | |
512 int min_bytes0 = prng.Rand(0, 10000); | |
513 int min_bytes1 = prng.Rand(0, 10000); | |
514 int min_bytes2 = prng.Rand(0, 10000); | |
515 | |
516 // Find the name of the current test, in order to use it as a temporary | |
517 // filename. | |
518 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); | |
519 const std::string temp_filename = | |
520 test::OutputPath() + test_info->test_case_name() + test_info->name(); | |
521 | |
522 rtc::ScopedFakeClock fake_clock; | |
523 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); | |
524 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); | |
525 | |
526 log_dumper->StartLogging(temp_filename, 10000000); | |
527 log_dumper->LogProbeClusterCreated(0, bitrate_bps0, min_probes0, min_bytes0); | |
528 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
529 log_dumper->LogProbeClusterCreated(1, bitrate_bps1, min_probes1, min_bytes1); | |
530 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
531 log_dumper->LogProbeClusterCreated(2, bitrate_bps2, min_probes2, min_bytes2); | |
532 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
533 log_dumper->StopLogging(); | |
534 | |
535 // Read the generated file from disk. | |
536 ParsedRtcEventLog parsed_log; | |
537 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); | |
538 | |
539 // Verify that what we read back from the event log is the same as | |
540 // what we wrote down. | |
541 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); | |
542 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); | |
543 RtcEventLogTestHelper::VerifyBweProbeCluster(parsed_log, 1, 0, bitrate_bps0, | |
544 min_probes0, min_bytes0); | |
545 RtcEventLogTestHelper::VerifyBweProbeCluster(parsed_log, 2, 1, bitrate_bps1, | |
546 min_probes1, min_bytes1); | |
547 RtcEventLogTestHelper::VerifyBweProbeCluster(parsed_log, 3, 2, bitrate_bps2, | |
548 min_probes2, min_bytes2); | |
549 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); | |
550 | |
551 // Clean up temporary file - can be pretty slow. | |
552 remove(temp_filename.c_str()); | |
553 } | |
554 | |
555 TEST(RtcEventLogTest, LogProbeResultSuccessAndReadBack) { | |
556 Random prng(192837); | |
557 | |
558 int bitrate_bps0 = prng.Rand(0, 10000000); | |
559 int bitrate_bps1 = prng.Rand(0, 10000000); | |
560 int bitrate_bps2 = prng.Rand(0, 10000000); | |
561 | |
562 // Find the name of the current test, in order to use it as a temporary | |
563 // filename. | |
564 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); | |
565 const std::string temp_filename = | |
566 test::OutputPath() + test_info->test_case_name() + test_info->name(); | |
567 | |
568 rtc::ScopedFakeClock fake_clock; | |
569 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); | |
570 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); | |
571 | |
572 log_dumper->StartLogging(temp_filename, 10000000); | |
573 log_dumper->LogProbeResultSuccess(0, bitrate_bps0); | |
574 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
575 log_dumper->LogProbeResultSuccess(1, bitrate_bps1); | |
576 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
577 log_dumper->LogProbeResultSuccess(2, bitrate_bps2); | |
578 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
579 log_dumper->StopLogging(); | |
580 | |
581 // Read the generated file from disk. | |
582 ParsedRtcEventLog parsed_log; | |
583 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); | |
584 | |
585 // Verify that what we read back from the event log is the same as | |
586 // what we wrote down. | |
587 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); | |
588 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); | |
589 RtcEventLogTestHelper::VerifyProbeResultSuccess(parsed_log, 1, 0, | |
590 bitrate_bps0); | |
591 RtcEventLogTestHelper::VerifyProbeResultSuccess(parsed_log, 2, 1, | |
592 bitrate_bps1); | |
593 RtcEventLogTestHelper::VerifyProbeResultSuccess(parsed_log, 3, 2, | |
594 bitrate_bps2); | |
595 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); | |
596 | |
597 // Clean up temporary file - can be pretty slow. | |
598 remove(temp_filename.c_str()); | |
599 } | |
600 | |
601 TEST(RtcEventLogTest, LogProbeResultFailureAndReadBack) { | |
602 Random prng(192837); | |
603 | |
604 // Find the name of the current test, in order to use it as a temporary | |
605 // filename. | |
606 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); | |
607 const std::string temp_filename = | |
608 test::OutputPath() + test_info->test_case_name() + test_info->name(); | |
609 | |
610 rtc::ScopedFakeClock fake_clock; | |
611 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); | |
612 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); | |
613 | |
614 log_dumper->StartLogging(temp_filename, 10000000); | |
615 log_dumper->LogProbeResultFailure( | |
616 0, ProbeFailureReason::kInvalidSendReceiveInterval); | |
617 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
618 log_dumper->LogProbeResultFailure( | |
619 1, ProbeFailureReason::kInvalidSendReceiveRatio); | |
620 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
621 log_dumper->LogProbeResultFailure(2, ProbeFailureReason::kTimeout); | |
622 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | |
623 log_dumper->StopLogging(); | |
624 | |
625 // Read the generated file from disk. | |
626 ParsedRtcEventLog parsed_log; | |
627 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); | |
628 | |
629 // Verify that what we read back from the event log is the same as | |
630 // what we wrote down. | |
631 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); | |
632 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); | |
633 RtcEventLogTestHelper::VerifyProbeResultFailure( | |
634 parsed_log, 1, 0, ProbeFailureReason::kInvalidSendReceiveInterval); | |
635 RtcEventLogTestHelper::VerifyProbeResultFailure( | |
636 parsed_log, 2, 1, ProbeFailureReason::kInvalidSendReceiveRatio); | |
637 RtcEventLogTestHelper::VerifyProbeResultFailure(parsed_log, 3, 2, | |
638 ProbeFailureReason::kTimeout); | |
639 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); | |
640 | |
641 // Clean up temporary file - can be pretty slow. | |
642 remove(temp_filename.c_str()); | |
643 } | |
644 | |
503 class ConfigReadWriteTest { | 645 class ConfigReadWriteTest { |
504 public: | 646 public: |
505 ConfigReadWriteTest() : prng(987654321) {} | 647 ConfigReadWriteTest() : prng(987654321) {} |
506 virtual ~ConfigReadWriteTest() {} | 648 virtual ~ConfigReadWriteTest() {} |
507 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; | 649 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; |
508 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, | 650 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, |
509 size_t index) = 0; | 651 size_t index) = 0; |
510 virtual void LogConfig(RtcEventLog* event_log) = 0; | 652 virtual void LogConfig(RtcEventLog* event_log) = 0; |
511 | 653 |
512 void DoTest() { | 654 void DoTest() { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 VideoSendConfigReadWriteTest test; | 793 VideoSendConfigReadWriteTest test; |
652 test.DoTest(); | 794 test.DoTest(); |
653 } | 795 } |
654 | 796 |
655 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { | 797 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { |
656 AudioNetworkAdaptationReadWriteTest test; | 798 AudioNetworkAdaptationReadWriteTest test; |
657 test.DoTest(); | 799 test.DoTest(); |
658 } | 800 } |
659 | 801 |
660 } // namespace webrtc | 802 } // namespace webrtc |
OLD | NEW |