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

Unified Diff: components/net_log/net_log_file_writer_unittest.cc

Issue 2698143004: Add ongoing events to net-export log when logging starts (Closed)
Patch Set: Forgot to update comment for StopNetLog() Created 3 years, 10 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: components/net_log/net_log_file_writer_unittest.cc
diff --git a/components/net_log/net_log_file_writer_unittest.cc b/components/net_log/net_log_file_writer_unittest.cc
index bca94fb5843021f83177173007bab2b79b9795cb..725c1264f272b4d4fe111c8268604e88a2635cc8 100644
--- a/components/net_log/net_log_file_writer_unittest.cc
+++ b/components/net_log/net_log_file_writer_unittest.cc
@@ -46,6 +46,7 @@ const char kCaptureModeIncludeSocketBytesString[] = "LOG_BYTES";
const char kStateUninitializedString[] = "UNINITIALIZED";
const char kStateInitializingString[] = "INITIALIZING";
const char kStateNotLoggingString[] = "NOT_LOGGING";
+const char kStateStartingLogString[] = "STARTING_LOG";
const char kStateLoggingString[] = "LOGGING";
const char kStateStoppingLogString[] = "STOPPING_LOG";
} // namespace
@@ -312,12 +313,11 @@ class NetLogFileWriterTest : public ::testing::Test {
const base::FilePath& custom_log_path,
net::NetLogCaptureMode capture_mode,
const std::string& expected_capture_mode_string) {
- net_log_file_writer_.StartNetLog(custom_log_path, capture_mode);
+ net_log_file_writer_.StartNetLog(custom_log_path, capture_mode, {});
std::unique_ptr<base::DictionaryValue> state =
test_state_observer_.WaitForNewState();
::testing::AssertionResult result =
- VerifyState(std::move(state), kStateLoggingString, true, true,
- expected_capture_mode_string);
+ VerifyState(std::move(state), kStateStartingLogString);
if (!result) {
return ::testing::AssertionFailure()
<< "First state after StartNetLog() does not match expected:"
@@ -325,6 +325,16 @@ class NetLogFileWriterTest : public ::testing::Test {
<< result.message();
}
+ state = test_state_observer_.WaitForNewState();
+ result = VerifyState(std::move(state), kStateLoggingString, true, true,
+ expected_capture_mode_string);
+ if (!result) {
+ return ::testing::AssertionFailure()
+ << "Second state after StartNetLog() does not match expected:"
+ << std::endl
+ << result.message();
+ }
+
// Make sure GetFilePath() returns empty path when logging.
base::FilePath actual_log_path = FileWriterGetFilePathToCompletedLog();
if (!actual_log_path.empty()) {
@@ -468,11 +478,11 @@ TEST_F(NetLogFileWriterTest, StartAndStopWithAllCaptureModes) {
// Calling StartNetLog() again should be a no-op. Try doing StartNetLog()
// with various capture modes; they should all be ignored and result in no
// state change.
- net_log_file_writer_.StartNetLog(base::FilePath(), capture_modes[i]);
+ net_log_file_writer_.StartNetLog(base::FilePath(), capture_modes[i], {});
net_log_file_writer_.StartNetLog(base::FilePath(),
- capture_modes[(i + 1) % 3]);
+ capture_modes[(i + 1) % 3], {});
net_log_file_writer_.StartNetLog(base::FilePath(),
- capture_modes[(i + 2) % 3]);
+ capture_modes[(i + 2) % 3], {});
// StopNetLog(), should result in state change. The capture mode should
// match that of the first StartNetLog() call (called by
@@ -663,7 +673,7 @@ TEST_F(NetLogFileWriterTest, ReceiveStartWhileInitializing) {
// before |net_log_file_writer_| finishes initialization, which means this
// should be a no-op.
net_log_file_writer_.StartNetLog(base::FilePath(),
- net::NetLogCaptureMode::Default());
+ net::NetLogCaptureMode::Default(), {});
// Now run the main message loop. Make sure StartNetLog() was ignored by
// checking that the next two states are "initializing" followed by
@@ -693,7 +703,7 @@ TEST_F(NetLogFileWriterTest, ReceiveStartWhileStoppingLog) {
// |net_log_file_writer_| finishes stopping, which means this should be a
// no-op.
net_log_file_writer_.StartNetLog(base::FilePath(),
- net::NetLogCaptureMode::Default());
+ net::NetLogCaptureMode::Default(), {});
// Now run the main message loop. Make sure the last StartNetLog() was
// ignored by checking that the next two states are "stopping-log" followed by

Powered by Google App Engine
This is Rietveld 408576698