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

Side by Side Diff: components/net_log/net_export_file_writer_unittest.cc

Issue 2966283002: Remove the file thread dependency from FileNetLogObserver. (Closed)
Patch Set: undo const-ref changes 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
« no previous file with comments | « components/net_log/net_export_file_writer.cc ('k') | net/log/file_net_log_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/net_log/net_export_file_writer.h" 5 #include "components/net_log/net_export_file_writer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/files/scoped_file.h" 15 #include "base/files/scoped_file.h"
16 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
17 #include "base/json/json_reader.h" 17 #include "base/json/json_reader.h"
18 #include "base/json/json_string_value_serializer.h" 18 #include "base/json/json_string_value_serializer.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/test/scoped_task_environment.h"
20 #include "base/run_loop.h"
21 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
22 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
23 #include "base/values.h" 22 #include "base/values.h"
24 #include "build/build_config.h" 23 #include "build/build_config.h"
25 #include "components/net_log/chrome_net_log.h" 24 #include "components/net_log/chrome_net_log.h"
26 #include "net/base/test_completion_callback.h" 25 #include "net/base/test_completion_callback.h"
27 #include "net/http/http_network_session.h" 26 #include "net/http/http_network_session.h"
28 #include "net/log/net_log_capture_mode.h" 27 #include "net/log/net_log_capture_mode.h"
29 #include "net/log/net_log_event_type.h" 28 #include "net/log/net_log_event_type.h"
30 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" 29 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 429
431 // The default log path that |file_writer_| will use is cached here. 430 // The default log path that |file_writer_| will use is cached here.
432 base::FilePath default_log_path_; 431 base::FilePath default_log_path_;
433 432
434 base::Thread file_thread_; 433 base::Thread file_thread_;
435 base::Thread net_thread_; 434 base::Thread net_thread_;
436 435
437 TestStateObserver test_state_observer_; 436 TestStateObserver test_state_observer_;
438 437
439 private: 438 private:
440 // Allows tasks to be posted to the main thread. 439 base::test::ScopedTaskEnvironment scoped_task_environment_;
441 base::MessageLoop message_loop_;
442 }; 440 };
443 441
444 TEST_F(NetExportFileWriterTest, InitFail) { 442 TEST_F(NetExportFileWriterTest, InitFail) {
445 // Override file_writer_'s default log base directory getter to always 443 // Override file_writer_'s default log base directory getter to always
446 // fail. 444 // fail.
447 file_writer_.SetDefaultLogBaseDirectoryGetterForTest( 445 file_writer_.SetDefaultLogBaseDirectoryGetterForTest(
448 base::Bind([](base::FilePath* path) -> bool { return false; })); 446 base::Bind([](base::FilePath* path) -> bool { return false; }));
449 447
450 // Initialization should fail due to the override. 448 // Initialization should fail due to the override.
451 ASSERT_TRUE(InitializeThenVerifyNewState(false, false)); 449 ASSERT_TRUE(InitializeThenVerifyNewState(false, false));
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 // StartNetLog() call (called by StartThenVerifyState()). 785 // StartNetLog() call (called by StartThenVerifyState()).
788 std::unique_ptr<base::DictionaryValue> state = 786 std::unique_ptr<base::DictionaryValue> state =
789 test_state_observer_.WaitForNewState(); 787 test_state_observer_.WaitForNewState();
790 ASSERT_TRUE(VerifyState(std::move(state), kStateStoppingLogString)); 788 ASSERT_TRUE(VerifyState(std::move(state), kStateStoppingLogString));
791 state = test_state_observer_.WaitForNewState(); 789 state = test_state_observer_.WaitForNewState();
792 ASSERT_TRUE(VerifyState(std::move(state), kStateNotLoggingString, true, true, 790 ASSERT_TRUE(VerifyState(std::move(state), kStateNotLoggingString, true, true,
793 kCaptureModeIncludeSocketBytesString)); 791 kCaptureModeIncludeSocketBytesString));
794 } 792 }
795 793
796 } // namespace net_log 794 } // namespace net_log
OLDNEW
« no previous file with comments | « components/net_log/net_export_file_writer.cc ('k') | net/log/file_net_log_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698