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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 2, bitrate2, | 581 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 2, bitrate2, |
582 kBwOverusing); | 582 kBwOverusing); |
583 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 3, bitrate3, | 583 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 3, bitrate3, |
584 kBwUnderusing); | 584 kBwUnderusing); |
585 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); | 585 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); |
586 | 586 |
587 // Clean up temporary file - can be pretty slow. | 587 // Clean up temporary file - can be pretty slow. |
588 remove(temp_filename.c_str()); | 588 remove(temp_filename.c_str()); |
589 } | 589 } |
590 | 590 |
| 591 TEST(RtcEventLogTest, LogProbeClusterCreatedAndReadBack) { |
| 592 Random prng(794613); |
| 593 |
| 594 int bitrate_bps0 = prng.Rand(0, 10000000); |
| 595 int bitrate_bps1 = prng.Rand(0, 10000000); |
| 596 int bitrate_bps2 = prng.Rand(0, 10000000); |
| 597 int min_probes0 = prng.Rand(0, 100); |
| 598 int min_probes1 = prng.Rand(0, 100); |
| 599 int min_probes2 = prng.Rand(0, 100); |
| 600 int min_bytes0 = prng.Rand(0, 10000); |
| 601 int min_bytes1 = prng.Rand(0, 10000); |
| 602 int min_bytes2 = prng.Rand(0, 10000); |
| 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->LogProbeClusterCreated(0, bitrate_bps0, min_probes0, min_bytes0); |
| 616 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 617 log_dumper->LogProbeClusterCreated(1, bitrate_bps1, min_probes1, min_bytes1); |
| 618 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 619 log_dumper->LogProbeClusterCreated(2, bitrate_bps2, min_probes2, min_bytes2); |
| 620 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 621 log_dumper->StopLogging(); |
| 622 |
| 623 // Read the generated file from disk. |
| 624 ParsedRtcEventLog parsed_log; |
| 625 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 626 |
| 627 // Verify that what we read back from the event log is the same as |
| 628 // what we wrote down. |
| 629 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); |
| 630 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 631 RtcEventLogTestHelper::VerifyBweProbeCluster(parsed_log, 1, 0, bitrate_bps0, |
| 632 min_probes0, min_bytes0); |
| 633 RtcEventLogTestHelper::VerifyBweProbeCluster(parsed_log, 2, 1, bitrate_bps1, |
| 634 min_probes1, min_bytes1); |
| 635 RtcEventLogTestHelper::VerifyBweProbeCluster(parsed_log, 3, 2, bitrate_bps2, |
| 636 min_probes2, min_bytes2); |
| 637 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); |
| 638 |
| 639 // Clean up temporary file - can be pretty slow. |
| 640 remove(temp_filename.c_str()); |
| 641 } |
| 642 |
| 643 TEST(RtcEventLogTest, LogProbeResultSuccessAndReadBack) { |
| 644 Random prng(192837); |
| 645 |
| 646 int bitrate_bps0 = prng.Rand(0, 10000000); |
| 647 int bitrate_bps1 = prng.Rand(0, 10000000); |
| 648 int bitrate_bps2 = prng.Rand(0, 10000000); |
| 649 |
| 650 // Find the name of the current test, in order to use it as a temporary |
| 651 // filename. |
| 652 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 653 const std::string temp_filename = |
| 654 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 655 |
| 656 rtc::ScopedFakeClock fake_clock; |
| 657 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 658 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 659 |
| 660 log_dumper->StartLogging(temp_filename, 10000000); |
| 661 log_dumper->LogProbeResultSuccess(0, bitrate_bps0); |
| 662 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 663 log_dumper->LogProbeResultSuccess(1, bitrate_bps1); |
| 664 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 665 log_dumper->LogProbeResultSuccess(2, bitrate_bps2); |
| 666 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 667 log_dumper->StopLogging(); |
| 668 |
| 669 // Read the generated file from disk. |
| 670 ParsedRtcEventLog parsed_log; |
| 671 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 672 |
| 673 // Verify that what we read back from the event log is the same as |
| 674 // what we wrote down. |
| 675 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); |
| 676 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 677 RtcEventLogTestHelper::VerifyProbeResultSuccess(parsed_log, 1, 0, |
| 678 bitrate_bps0); |
| 679 RtcEventLogTestHelper::VerifyProbeResultSuccess(parsed_log, 2, 1, |
| 680 bitrate_bps1); |
| 681 RtcEventLogTestHelper::VerifyProbeResultSuccess(parsed_log, 3, 2, |
| 682 bitrate_bps2); |
| 683 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); |
| 684 |
| 685 // Clean up temporary file - can be pretty slow. |
| 686 remove(temp_filename.c_str()); |
| 687 } |
| 688 |
| 689 TEST(RtcEventLogTest, LogProbeResultFailureAndReadBack) { |
| 690 Random prng(192837); |
| 691 |
| 692 // Find the name of the current test, in order to use it as a temporary |
| 693 // filename. |
| 694 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 695 const std::string temp_filename = |
| 696 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 697 |
| 698 rtc::ScopedFakeClock fake_clock; |
| 699 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 700 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 701 |
| 702 log_dumper->StartLogging(temp_filename, 10000000); |
| 703 log_dumper->LogProbeResultFailure( |
| 704 0, ProbeFailureReason::kInvalidSendReceiveInterval); |
| 705 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 706 log_dumper->LogProbeResultFailure( |
| 707 1, ProbeFailureReason::kInvalidSendReceiveRatio); |
| 708 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 709 log_dumper->LogProbeResultFailure(2, ProbeFailureReason::kTimeout); |
| 710 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 711 log_dumper->StopLogging(); |
| 712 |
| 713 // Read the generated file from disk. |
| 714 ParsedRtcEventLog parsed_log; |
| 715 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 716 |
| 717 // Verify that what we read back from the event log is the same as |
| 718 // what we wrote down. |
| 719 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); |
| 720 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 721 RtcEventLogTestHelper::VerifyProbeResultFailure( |
| 722 parsed_log, 1, 0, ProbeFailureReason::kInvalidSendReceiveInterval); |
| 723 RtcEventLogTestHelper::VerifyProbeResultFailure( |
| 724 parsed_log, 2, 1, ProbeFailureReason::kInvalidSendReceiveRatio); |
| 725 RtcEventLogTestHelper::VerifyProbeResultFailure(parsed_log, 3, 2, |
| 726 ProbeFailureReason::kTimeout); |
| 727 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); |
| 728 |
| 729 // Clean up temporary file - can be pretty slow. |
| 730 remove(temp_filename.c_str()); |
| 731 } |
| 732 |
591 class ConfigReadWriteTest { | 733 class ConfigReadWriteTest { |
592 public: | 734 public: |
593 ConfigReadWriteTest() : prng(987654321) {} | 735 ConfigReadWriteTest() : prng(987654321) {} |
594 virtual ~ConfigReadWriteTest() {} | 736 virtual ~ConfigReadWriteTest() {} |
595 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; | 737 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; |
596 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, | 738 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, |
597 size_t index) = 0; | 739 size_t index) = 0; |
598 virtual void LogConfig(RtcEventLog* event_log) = 0; | 740 virtual void LogConfig(RtcEventLog* event_log) = 0; |
599 | 741 |
600 void DoTest() { | 742 void DoTest() { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 VideoSendConfigReadWriteTest test; | 881 VideoSendConfigReadWriteTest test; |
740 test.DoTest(); | 882 test.DoTest(); |
741 } | 883 } |
742 | 884 |
743 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { | 885 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { |
744 AudioNetworkAdaptationReadWriteTest test; | 886 AudioNetworkAdaptationReadWriteTest test; |
745 test.DoTest(); | 887 test.DoTest(); |
746 } | 888 } |
747 | 889 |
748 } // namespace webrtc | 890 } // namespace webrtc |
OLD | NEW |