| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/file_net_log_observer.h" | 5 #include "net/log/file_net_log_observer.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // The log files should have been started. | 280 // The log files should have been started. |
| 281 ASSERT_TRUE(LogFilesExist()); | 281 ASSERT_TRUE(LogFilesExist()); |
| 282 | 282 |
| 283 logger_.reset(); | 283 logger_.reset(); |
| 284 | 284 |
| 285 // When the logger is re-set without having called StopObserving(), the | 285 // When the logger is re-set without having called StopObserving(), the |
| 286 // partially written log files are deleted. | 286 // partially written log files are deleted. |
| 287 ASSERT_FALSE(LogFilesExist()); | 287 ASSERT_FALSE(LogFilesExist()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 // Tests calling StopObserving() with a null closure. |
| 291 TEST_P(FileNetLogObserverTest, StopObservingNullClosure) { |
| 292 CreateAndStartObserving(nullptr); |
| 293 |
| 294 // Send dummy event |
| 295 AddEntries(logger_.get(), 1, kDummyEventSize); |
| 296 |
| 297 // The log files should have been started. |
| 298 ASSERT_TRUE(LogFilesExist()); |
| 299 |
| 300 logger_->StopObserving(nullptr, base::OnceClosure()); |
| 301 |
| 302 logger_.reset(); |
| 303 |
| 304 // Since the logger was explicitly stopped, its files should still exist. |
| 305 ASSERT_TRUE(LogFilesExist()); |
| 306 } |
| 307 |
| 290 TEST_P(FileNetLogObserverTest, GeneratesValidJSONWithNoEvents) { | 308 TEST_P(FileNetLogObserverTest, GeneratesValidJSONWithNoEvents) { |
| 291 TestClosure closure; | 309 TestClosure closure; |
| 292 | 310 |
| 293 CreateAndStartObserving(nullptr); | 311 CreateAndStartObserving(nullptr); |
| 294 | 312 |
| 295 logger_->StopObserving(nullptr, closure.closure()); | 313 logger_->StopObserving(nullptr, closure.closure()); |
| 296 | 314 |
| 297 closure.WaitForResult(); | 315 closure.WaitForResult(); |
| 298 | 316 |
| 299 std::unique_ptr<base::Value> root; | 317 std::unique_ptr<base::Value> root; |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 // Join all the threads. | 879 // Join all the threads. |
| 862 threads.clear(); | 880 threads.clear(); |
| 863 | 881 |
| 864 // The log file doesn't exist since StopObserving() was not called. | 882 // The log file doesn't exist since StopObserving() was not called. |
| 865 ASSERT_FALSE(LogFilesExist()); | 883 ASSERT_FALSE(LogFilesExist()); |
| 866 } | 884 } |
| 867 | 885 |
| 868 } // namespace | 886 } // namespace |
| 869 | 887 |
| 870 } // namespace net | 888 } // namespace net |
| OLD | NEW |