Index: chrome/browser/net/net_log_temp_file_unittest.cc |
diff --git a/chrome/browser/net/net_log_temp_file_unittest.cc b/chrome/browser/net/net_log_temp_file_unittest.cc |
index 7d9065f031487c98a22fff602cd35aeb2a2aff1f..b3fce9e6bdbb81f0bc9b87305ae709d0593ebf9c 100644 |
--- a/chrome/browser/net/net_log_temp_file_unittest.cc |
+++ b/chrome/browser/net/net_log_temp_file_unittest.cc |
@@ -176,6 +176,22 @@ class NetLogTempFileTest : public ::testing::Test { |
VerifyNetExportLog(); |
} |
+ // Make sure the export file has been successfully initialized. |
+ void VerifyFileAndStateAfterDoStopWithStripPrivateData() { |
+ EXPECT_EQ("NOT_LOGGING", GetStateString()); |
+ EXPECT_EQ(NetLogTempFile::STATE_NOT_LOGGING, net_log_temp_file_->state()); |
+ EXPECT_EQ("STRIP_PRIVATE_DATA", GetLogTypeString()); |
+ EXPECT_EQ(NetLogTempFile::LOG_TYPE_STRIP_PRIVATE_DATA, |
+ net_log_temp_file_->log_type()); |
+ |
+ base::FilePath net_export_file_path; |
+ EXPECT_TRUE(net_log_temp_file_->GetFilePath(&net_export_file_path)); |
+ EXPECT_TRUE(base::PathExists(net_export_file_path)); |
+ EXPECT_EQ(net_export_log_, net_export_file_path); |
+ |
+ VerifyNetExportLog(); |
+ } |
+ |
scoped_ptr<ChromeNetLog> net_log_; |
// |net_log_temp_file_| is initialized after |net_log_| so that it can stop |
// obvserving on destruction. |
@@ -244,6 +260,25 @@ TEST_F(NetLogTempFileTest, ProcessCommandDoStartAndStop) { |
VerifyFileAndStateAfterDoStop(); |
} |
+TEST_F(NetLogTempFileTest, |
+ ProcessCommandDoStartAndStopWithPrivateDataStripping) { |
+ net_log_temp_file_->ProcessCommand( |
+ NetLogTempFile::DO_START_STRIP_PRIVATE_DATA); |
+ VerifyFileAndStateAfterDoStartStripPrivateData(); |
+ |
+ // Calling DO_START_STRIP_PRIVATE_DATA second time should be a no-op. |
+ net_log_temp_file_->ProcessCommand( |
+ NetLogTempFile::DO_START_STRIP_PRIVATE_DATA); |
+ VerifyFileAndStateAfterDoStartStripPrivateData(); |
+ |
+ net_log_temp_file_->ProcessCommand(NetLogTempFile::DO_STOP); |
+ VerifyFileAndStateAfterDoStopWithStripPrivateData(); |
+ |
+ // Calling DO_STOP second time should be a no-op. |
+ net_log_temp_file_->ProcessCommand(NetLogTempFile::DO_STOP); |
+ VerifyFileAndStateAfterDoStopWithStripPrivateData(); |
+} |
+ |
TEST_F(NetLogTempFileTest, DoStartClearsFile) { |
// Verify file sizes after two consecutives start/stop are the same (even if |
// we add some junk data in between). |