Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc

Issue 2996933003: Add logging of host lookups made by TurnPort to the RtcEventLog. (Closed)
Patch Set: review Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc
diff --git a/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc b/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc
index e908ccd5fb1bdfb4ff93665119dac1d056acc438..7c661fa35a11c32526210a0e96c8498ffd58243a 100644
--- a/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc
+++ b/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc
@@ -873,4 +873,53 @@ TEST(RtcEventLogTest, LogAudioNetworkAdaptation) {
test.DoTest();
}
+TEST(RtcEventLogTest, LogHostLookupResult) {
+ unsigned int random_seed = 779911;
+ Random prng(random_seed);
+
+ // Find the name of the current test, in order to use it as a temporary
+ // filename.
+ auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
+ const std::string temp_filename =
+ test::OutputPath() + test_info->test_case_name() + test_info->name();
+
+ // When log_dumper goes out of scope, it causes the log file to be flushed
+ // to disk.
+ {
+ rtc::ScopedFakeClock fake_clock;
+ fake_clock.SetTimeMicros(prng.Rand<uint32_t>());
+ std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
+ log_dumper->StartLogging(temp_filename, 10000000);
+ fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
+ log_dumper->LogHostLookupResult(0, 123);
+ fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
+ log_dumper->LogHostLookupResult(1, 349);
+ fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
+ log_dumper->StopLogging();
+ }
+
+ // Read the generated file from disk.
+ ParsedRtcEventLog parsed_log;
+
+ ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
+
+ // Verify that what we read back from the event log is the same as
+ // what we wrote down. For RTCP we log the full packets, but for
+ // RTP we should only log the header.
+ const size_t event_count = 4;
+ EXPECT_EQ(event_count, parsed_log.GetNumberOfEvents());
+ if (event_count != parsed_log.GetNumberOfEvents()) {
+ // Print the expected and actual event types for easier debugging.
+ PrintActualEvents(parsed_log);
+ }
+
+ RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0);
+ RtcEventLogTestHelper::VerifyLogHostLookupEvent(parsed_log, 1, 0, 123);
+ RtcEventLogTestHelper::VerifyLogHostLookupEvent(parsed_log, 2, 1, 349);
+ RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3);
+
+ // Clean up temporary file - can be pretty slow.
+ remove(temp_filename.c_str());
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log_parser.cc ('k') | webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698