| 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, LogPacketLossEventAndReadBack) { |
| 504 Random prng(1234); |
| 505 |
| 506 // Generate a random packet loss event. |
| 507 int32_t bitrate = prng.Rand(0, 10000000); |
| 508 uint8_t fraction_lost = prng.Rand<uint8_t>(); |
| 509 int32_t total_packets = prng.Rand(1, 1000); |
| 510 |
| 511 // Find the name of the current test, in order to use it as a temporary |
| 512 // filename. |
| 513 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 514 const std::string temp_filename = |
| 515 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 516 |
| 517 // Start logging, add the packet loss event and then stop logging. |
| 518 rtc::ScopedFakeClock fake_clock; |
| 519 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 520 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 521 log_dumper->StartLogging(temp_filename, 10000000); |
| 522 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 523 log_dumper->LogBwePacketLossEvent(bitrate, fraction_lost, total_packets); |
| 524 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 525 log_dumper->StopLogging(); |
| 526 |
| 527 // Read the generated file from disk. |
| 528 ParsedRtcEventLog parsed_log; |
| 529 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 530 |
| 531 // Verify that what we read back from the event log is the same as |
| 532 // what we wrote down. |
| 533 EXPECT_EQ(3u, parsed_log.GetNumberOfEvents()); |
| 534 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 535 RtcEventLogTestHelper::VerifyBweLossEvent(parsed_log, 1, bitrate, |
| 536 fraction_lost, total_packets); |
| 537 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 2); |
| 538 |
| 539 // Clean up temporary file - can be pretty slow. |
| 540 remove(temp_filename.c_str()); |
| 541 } |
| 542 |
| 543 TEST(RtcEventLogTest, LogPacketDelayEventAndReadBack) { |
| 544 Random prng(1234); |
| 545 |
| 546 // Generate 3 random packet delay event. |
| 547 int32_t bitrate1 = prng.Rand(0, 10000000); |
| 548 int32_t bitrate2 = prng.Rand(0, 10000000); |
| 549 int32_t bitrate3 = prng.Rand(0, 10000000); |
| 550 |
| 551 // Find the name of the current test, in order to use it as a temporary |
| 552 // filename. |
| 553 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 554 const std::string temp_filename = |
| 555 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 556 |
| 557 // Start logging, add the packet delay events and then stop logging. |
| 558 rtc::ScopedFakeClock fake_clock; |
| 559 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 560 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 561 log_dumper->StartLogging(temp_filename, 10000000); |
| 562 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 563 log_dumper->LogBwePacketDelayEvent(bitrate1, kBwNormal); |
| 564 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 565 log_dumper->LogBwePacketDelayEvent(bitrate2, kBwOverusing); |
| 566 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 567 log_dumper->LogBwePacketDelayEvent(bitrate3, kBwUnderusing); |
| 568 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 569 log_dumper->StopLogging(); |
| 570 |
| 571 // Read the generated file from disk. |
| 572 ParsedRtcEventLog parsed_log; |
| 573 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 574 |
| 575 // Verify that what we read back from the event log is the same as |
| 576 // what we wrote down. |
| 577 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); |
| 578 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 579 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 1, bitrate1, |
| 580 kBwNormal); |
| 581 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 2, bitrate2, |
| 582 kBwOverusing); |
| 583 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 3, bitrate3, |
| 584 kBwUnderusing); |
| 585 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); |
| 586 |
| 587 // Clean up temporary file - can be pretty slow. |
| 588 remove(temp_filename.c_str()); |
| 589 } |
| 590 |
| 503 class ConfigReadWriteTest { | 591 class ConfigReadWriteTest { |
| 504 public: | 592 public: |
| 505 ConfigReadWriteTest() : prng(987654321) {} | 593 ConfigReadWriteTest() : prng(987654321) {} |
| 506 virtual ~ConfigReadWriteTest() {} | 594 virtual ~ConfigReadWriteTest() {} |
| 507 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; | 595 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; |
| 508 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, | 596 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, |
| 509 size_t index) = 0; | 597 size_t index) = 0; |
| 510 virtual void LogConfig(RtcEventLog* event_log) = 0; | 598 virtual void LogConfig(RtcEventLog* event_log) = 0; |
| 511 | 599 |
| 512 void DoTest() { | 600 void DoTest() { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 VideoSendConfigReadWriteTest test; | 739 VideoSendConfigReadWriteTest test; |
| 652 test.DoTest(); | 740 test.DoTest(); |
| 653 } | 741 } |
| 654 | 742 |
| 655 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { | 743 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { |
| 656 AudioNetworkAdaptationReadWriteTest test; | 744 AudioNetworkAdaptationReadWriteTest test; |
| 657 test.DoTest(); | 745 test.DoTest(); |
| 658 } | 746 } |
| 659 | 747 |
| 660 } // namespace webrtc | 748 } // namespace webrtc |
| OLD | NEW |