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

Side by Side Diff: net/log/file_net_log_observer_unittest.cc

Issue 2973673003: Use FileNetLogObserver for implementing --log-net-log. (Closed)
Patch Set: check for null Created 3 years, 5 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 unified diff | Download patch
OLDNEW
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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Send dummy event 277 // Send dummy event
278 AddEntries(logger_.get(), 1, kDummyEventSize); 278 AddEntries(logger_.get(), 1, kDummyEventSize);
279 279
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());
mmenke 2017/07/06 21:31:29 How is this guaranteed? Deletion occurs on anothe
eroman 2017/07/06 21:57:54 This is guaranteed by the changes I made in the de
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());
mmenke 2017/07/06 21:31:29 How is this guaranteed? The file is created on an
eroman 2017/07/06 21:57:54 same explanation as above.
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
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
OLDNEW
« components/net_log/chrome_net_log.cc ('K') | « net/log/file_net_log_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698