| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/log/write_to_file_net_log_observer.h" | 5 #include "net/log/write_to_file_net_log_observer.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_file.h" | 9 #include "base/files/scoped_file.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 base::DictionaryValue* constants; | 60 base::DictionaryValue* constants; |
| 61 ASSERT_TRUE(dict->GetDictionary("constants", &constants)); | 61 ASSERT_TRUE(dict->GetDictionary("constants", &constants)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 TEST_F(WriteToFileNetLogObserverTest, CaptureMode) { | 64 TEST_F(WriteToFileNetLogObserverTest, CaptureMode) { |
| 65 base::ScopedFILE file(base::OpenFile(log_path_, "w")); | 65 base::ScopedFILE file(base::OpenFile(log_path_, "w")); |
| 66 ASSERT_TRUE(file); | 66 ASSERT_TRUE(file); |
| 67 WriteToFileNetLogObserver logger; | 67 WriteToFileNetLogObserver logger; |
| 68 logger.StartObserving(&net_log_, file.Pass(), nullptr, nullptr); | 68 logger.StartObserving(&net_log_, file.Pass(), nullptr, nullptr); |
| 69 EXPECT_EQ(NetLogCaptureMode::Default(), logger.capture_mode()); | 69 EXPECT_EQ(NetLogCaptureMode::Default(), logger.capture_mode()); |
| 70 EXPECT_EQ(NetLogCaptureMode::Default(), net_log_.GetCaptureMode()); | |
| 71 logger.StopObserving(nullptr); | 70 logger.StopObserving(nullptr); |
| 72 | 71 |
| 73 file.reset(base::OpenFile(log_path_, "w")); | 72 file.reset(base::OpenFile(log_path_, "w")); |
| 74 ASSERT_TRUE(file); | 73 ASSERT_TRUE(file); |
| 75 logger.set_capture_mode(NetLogCaptureMode::IncludeCookiesAndCredentials()); | 74 logger.set_capture_mode(NetLogCaptureMode::IncludeCookiesAndCredentials()); |
| 76 logger.StartObserving(&net_log_, file.Pass(), nullptr, nullptr); | 75 logger.StartObserving(&net_log_, file.Pass(), nullptr, nullptr); |
| 77 EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(), | 76 EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(), |
| 78 logger.capture_mode()); | 77 logger.capture_mode()); |
| 79 EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(), | |
| 80 net_log_.GetCaptureMode()); | |
| 81 logger.StopObserving(nullptr); | 78 logger.StopObserving(nullptr); |
| 82 } | 79 } |
| 83 | 80 |
| 84 TEST_F(WriteToFileNetLogObserverTest, GeneratesValidJSONWithOneEvent) { | 81 TEST_F(WriteToFileNetLogObserverTest, GeneratesValidJSONWithOneEvent) { |
| 85 base::ScopedFILE file(base::OpenFile(log_path_, "w")); | 82 base::ScopedFILE file(base::OpenFile(log_path_, "w")); |
| 86 ASSERT_TRUE(file); | 83 ASSERT_TRUE(file); |
| 87 scoped_ptr<WriteToFileNetLogObserver> logger(new WriteToFileNetLogObserver()); | 84 scoped_ptr<WriteToFileNetLogObserver> logger(new WriteToFileNetLogObserver()); |
| 88 logger->StartObserving(&net_log_, file.Pass(), nullptr, nullptr); | 85 logger->StartObserving(&net_log_, file.Pass(), nullptr, nullptr); |
| 89 | 86 |
| 90 const int kDummyId = 1; | 87 const int kDummyId = 1; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 ASSERT_EQ(1u, events->GetSize()); | 232 ASSERT_EQ(1u, events->GetSize()); |
| 236 | 233 |
| 237 // Make sure additional information is present, but don't validate it. | 234 // Make sure additional information is present, but don't validate it. |
| 238 base::DictionaryValue* tab_info; | 235 base::DictionaryValue* tab_info; |
| 239 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); | 236 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); |
| 240 } | 237 } |
| 241 | 238 |
| 242 } // namespace | 239 } // namespace |
| 243 | 240 |
| 244 } // namespace net | 241 } // namespace net |
| OLD | NEW |