OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 31 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
32 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" | 32 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" |
33 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
34 #include "chrome/browser/net/predictor.h" | 34 #include "chrome/browser/net/predictor.h" |
35 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" | 35 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
36 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
37 #include "chrome/browser/profiles/profiles_state.h" | 37 #include "chrome/browser/profiles/profiles_state.h" |
38 #include "chrome/browser/rlz/rlz.h" | 38 #include "chrome/browser/rlz/rlz.h" |
39 #include "chrome/common/chrome_content_client.h" | 39 #include "chrome/common/chrome_content_client.h" |
40 #include "chrome/common/chrome_paths.h" | 40 #include "chrome/common/chrome_paths.h" |
| 41 #include "chrome/common/chrome_switches.h" |
41 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
42 #include "chrome/test/base/chrome_unit_test_suite.h" | 43 #include "chrome/test/base/chrome_unit_test_suite.h" |
43 #include "chrome/test/base/scoped_testing_local_state.h" | 44 #include "chrome/test/base/scoped_testing_local_state.h" |
44 #include "chrome/test/base/testing_browser_process.h" | 45 #include "chrome/test/base/testing_browser_process.h" |
45 #include "chromeos/chromeos_switches.h" | 46 #include "chromeos/chromeos_switches.h" |
46 #include "chromeos/cryptohome/mock_async_method_caller.h" | 47 #include "chromeos/cryptohome/mock_async_method_caller.h" |
47 #include "chromeos/cryptohome/system_salt_getter.h" | 48 #include "chromeos/cryptohome/system_salt_getter.h" |
48 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 49 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
49 #include "chromeos/disks/disk_mount_manager.h" | 50 #include "chromeos/disks/disk_mount_manager.h" |
50 #include "chromeos/disks/mock_disk_mount_manager.h" | 51 #include "chromeos/disks/mock_disk_mount_manager.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // will be executed. | 204 // will be executed. |
204 io_thread_.reset( | 205 io_thread_.reset( |
205 new content::TestBrowserThread(BrowserThread::IO, fake_io_loop)); | 206 new content::TestBrowserThread(BrowserThread::IO, fake_io_loop)); |
206 | 207 |
207 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); | 208 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); |
208 | 209 |
209 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 210 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
210 command_line->AppendSwitchASCII( | 211 command_line->AppendSwitchASCII( |
211 policy::switches::kDeviceManagementUrl, kDMServer); | 212 policy::switches::kDeviceManagementUrl, kDMServer); |
212 | 213 |
| 214 // Disable prefetch so that Predictor can peacefully shut down without a |
| 215 // running IO thread. |
| 216 command_line->AppendSwitch(::switches::kDnsPrefetchDisable); |
| 217 |
213 // DBusThreadManager should be initialized before io_thread_state_, as | 218 // DBusThreadManager should be initialized before io_thread_state_, as |
214 // DBusThreadManager is used from chromeos::ProxyConfigServiceImpl, | 219 // DBusThreadManager is used from chromeos::ProxyConfigServiceImpl, |
215 // which is part of io_thread_state_. | 220 // which is part of io_thread_state_. |
216 DBusThreadManager::InitializeWithStub(); | 221 DBusThreadManager::InitializeWithStub(); |
217 | 222 |
218 SystemSaltGetter::Initialize(); | 223 SystemSaltGetter::Initialize(); |
219 LoginState::Initialize(); | 224 LoginState::Initialize(); |
220 DeviceOAuth2TokenServiceFactory::Initialize(); | 225 DeviceOAuth2TokenServiceFactory::Initialize(); |
221 | 226 |
222 EXPECT_CALL(mock_statistics_provider_, GetMachineStatistic(_, _)) | 227 EXPECT_CALL(mock_statistics_provider_, GetMachineStatistic(_, _)) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // chrome_browser_net::Predictor usually skips its shutdown routines on | 317 // chrome_browser_net::Predictor usually skips its shutdown routines on |
313 // unit_tests, but does the full thing when | 318 // unit_tests, but does the full thing when |
314 // g_browser_process->profile_manager() is valid during initialization. | 319 // g_browser_process->profile_manager() is valid during initialization. |
315 // That includes a WaitableEvent on UI waiting for a task on IO, so that | 320 // That includes a WaitableEvent on UI waiting for a task on IO, so that |
316 // task must execute. Do it directly from here now. | 321 // task must execute. Do it directly from here now. |
317 std::vector<Profile*> profiles = | 322 std::vector<Profile*> profiles = |
318 browser_process_->profile_manager()->GetLoadedProfiles(); | 323 browser_process_->profile_manager()->GetLoadedProfiles(); |
319 for (size_t i = 0; i < profiles.size(); ++i) { | 324 for (size_t i = 0; i < profiles.size(); ++i) { |
320 chrome_browser_net::Predictor* predictor = | 325 chrome_browser_net::Predictor* predictor = |
321 profiles[i]->GetNetworkPredictor(); | 326 profiles[i]->GetNetworkPredictor(); |
322 if (predictor) { | 327 if (predictor) |
323 predictor->EnablePredictorOnIOThread(false); | |
324 predictor->Shutdown(); | 328 predictor->Shutdown(); |
325 } | |
326 } | 329 } |
327 } | 330 } |
328 | 331 |
329 void RunUntilIdle() { | 332 void RunUntilIdle() { |
330 loop_.RunUntilIdle(); | 333 loop_.RunUntilIdle(); |
331 BrowserThread::GetBlockingPool()->FlushForTesting(); | 334 BrowserThread::GetBlockingPool()->FlushForTesting(); |
332 loop_.RunUntilIdle(); | 335 loop_.RunUntilIdle(); |
333 } | 336 } |
334 | 337 |
335 // Invokes |task| on the IO loop and returns after it has executed. | 338 // Invokes |task| on the IO loop and returns after it has executed. |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 } | 707 } |
705 | 708 |
706 INSTANTIATE_TEST_CASE_P( | 709 INSTANTIATE_TEST_CASE_P( |
707 LoginUtilsBlockingLoginTestInstance, | 710 LoginUtilsBlockingLoginTestInstance, |
708 LoginUtilsBlockingLoginTest, | 711 LoginUtilsBlockingLoginTest, |
709 testing::Values(0, 1, 2, 3, 4, 5)); | 712 testing::Values(0, 1, 2, 3, 4, 5)); |
710 | 713 |
711 } // namespace | 714 } // namespace |
712 | 715 |
713 } // namespace chromeos | 716 } // namespace chromeos |
OLD | NEW |