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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 TEST(RtcEventLogTest, LogVideoSendConfig) { | 866 TEST(RtcEventLogTest, LogVideoSendConfig) { |
867 VideoSendConfigReadWriteTest test; | 867 VideoSendConfigReadWriteTest test; |
868 test.DoTest(); | 868 test.DoTest(); |
869 } | 869 } |
870 | 870 |
871 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { | 871 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { |
872 AudioNetworkAdaptationReadWriteTest test; | 872 AudioNetworkAdaptationReadWriteTest test; |
873 test.DoTest(); | 873 test.DoTest(); |
874 } | 874 } |
875 | 875 |
| 876 TEST(RtcEventLogTest, LogHostLookupResult) { |
| 877 unsigned int random_seed = 779911; |
| 878 Random prng(random_seed); |
| 879 |
| 880 // Find the name of the current test, in order to use it as a temporary |
| 881 // filename. |
| 882 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 883 const std::string temp_filename = |
| 884 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 885 |
| 886 // When log_dumper goes out of scope, it causes the log file to be flushed |
| 887 // to disk. |
| 888 { |
| 889 rtc::ScopedFakeClock fake_clock; |
| 890 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 891 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 892 log_dumper->StartLogging(temp_filename, 10000000); |
| 893 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 894 log_dumper->LogHostLookupResult(0, 123); |
| 895 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 896 log_dumper->LogHostLookupResult(1, 349); |
| 897 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 898 log_dumper->StopLogging(); |
| 899 } |
| 900 |
| 901 // Read the generated file from disk. |
| 902 ParsedRtcEventLog parsed_log; |
| 903 |
| 904 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 905 |
| 906 // Verify that what we read back from the event log is the same as |
| 907 // what we wrote down. For RTCP we log the full packets, but for |
| 908 // RTP we should only log the header. |
| 909 const size_t event_count = 4; |
| 910 EXPECT_EQ(event_count, parsed_log.GetNumberOfEvents()); |
| 911 if (event_count != parsed_log.GetNumberOfEvents()) { |
| 912 // Print the expected and actual event types for easier debugging. |
| 913 PrintActualEvents(parsed_log); |
| 914 } |
| 915 |
| 916 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 917 RtcEventLogTestHelper::VerifyLogHostLookupEvent(parsed_log, 1, 0, 123); |
| 918 RtcEventLogTestHelper::VerifyLogHostLookupEvent(parsed_log, 2, 1, 349); |
| 919 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); |
| 920 |
| 921 // Clean up temporary file - can be pretty slow. |
| 922 remove(temp_filename.c_str()); |
| 923 } |
| 924 |
876 } // namespace webrtc | 925 } // namespace webrtc |
OLD | NEW |