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" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "chrome/browser/chrome_content_browser_client.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 21 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
21 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 22 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
22 #include "chrome/browser/chromeos/login/authenticator.h" | 23 #include "chrome/browser/chromeos/login/authenticator.h" |
23 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 24 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
24 #include "chrome/browser/chromeos/login/user_manager.h" | 25 #include "chrome/browser/chromeos/login/user_manager.h" |
25 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 26 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
26 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 27 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
27 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
28 #include "chrome/browser/chromeos/settings/cros_settings.h" | 29 #include "chrome/browser/chromeos/settings/cros_settings.h" |
29 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 30 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
30 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 31 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
31 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" | 32 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" |
32 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
33 #include "chrome/browser/net/predictor.h" | 34 #include "chrome/browser/net/predictor.h" |
34 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" | 35 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
35 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
36 #include "chrome/browser/rlz/rlz.h" | 37 #include "chrome/browser/rlz/rlz.h" |
| 38 #include "chrome/common/chrome_content_client.h" |
37 #include "chrome/common/chrome_paths.h" | 39 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
| 42 #include "chrome/test/base/chrome_unit_test_suite.h" |
40 #include "chrome/test/base/scoped_testing_local_state.h" | 43 #include "chrome/test/base/scoped_testing_local_state.h" |
41 #include "chrome/test/base/testing_browser_process.h" | 44 #include "chrome/test/base/testing_browser_process.h" |
42 #include "chromeos/chromeos_switches.h" | 45 #include "chromeos/chromeos_switches.h" |
43 #include "chromeos/cryptohome/mock_async_method_caller.h" | 46 #include "chromeos/cryptohome/mock_async_method_caller.h" |
44 #include "chromeos/cryptohome/system_salt_getter.h" | 47 #include "chromeos/cryptohome/system_salt_getter.h" |
45 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 48 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
46 #include "chromeos/disks/disk_mount_manager.h" | 49 #include "chromeos/disks/disk_mount_manager.h" |
47 #include "chromeos/disks/mock_disk_mount_manager.h" | 50 #include "chromeos/disks/mock_disk_mount_manager.h" |
48 #include "chromeos/login/login_state.h" | 51 #include "chromeos/login/login_state.h" |
49 #include "chromeos/network/network_handler.h" | 52 #include "chromeos/network/network_handler.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 local_state_(browser_process_), | 157 local_state_(browser_process_), |
155 ui_thread_(BrowserThread::UI, &loop_), | 158 ui_thread_(BrowserThread::UI, &loop_), |
156 db_thread_(BrowserThread::DB, &loop_), | 159 db_thread_(BrowserThread::DB, &loop_), |
157 file_thread_(BrowserThread::FILE, &loop_), | 160 file_thread_(BrowserThread::FILE, &loop_), |
158 mock_input_method_manager_(NULL), | 161 mock_input_method_manager_(NULL), |
159 mock_async_method_caller_(NULL), | 162 mock_async_method_caller_(NULL), |
160 connector_(NULL), | 163 connector_(NULL), |
161 prepared_profile_(NULL) {} | 164 prepared_profile_(NULL) {} |
162 | 165 |
163 virtual void SetUp() OVERRIDE { | 166 virtual void SetUp() OVERRIDE { |
| 167 ChromeUnitTestSuite::InitializeProviders(); |
| 168 ChromeUnitTestSuite::InitializeResourceBundle(); |
| 169 |
| 170 content_client_.reset(new ChromeContentClient); |
| 171 content::SetContentClient(content_client_.get()); |
| 172 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); |
| 173 content::SetBrowserClientForTesting(browser_content_client_.get()); |
| 174 |
164 // This test is not a full blown InProcessBrowserTest, and doesn't have | 175 // This test is not a full blown InProcessBrowserTest, and doesn't have |
165 // all the usual threads running. However a lot of subsystems pulled from | 176 // all the usual threads running. However a lot of subsystems pulled from |
166 // ProfileImpl post to IO (usually from ProfileIOData), and DCHECK that | 177 // ProfileImpl post to IO (usually from ProfileIOData), and DCHECK that |
167 // those tasks were posted. Those tasks in turn depend on a lot of other | 178 // those tasks were posted. Those tasks in turn depend on a lot of other |
168 // components that aren't there during this test, so this kludge is used to | 179 // components that aren't there during this test, so this kludge is used to |
169 // have a running IO loop that doesn't really execute any tasks. | 180 // have a running IO loop that doesn't really execute any tasks. |
170 // | 181 // |
171 // See InvokeOnIO() below for a way to perform specific tasks on IO, when | 182 // See InvokeOnIO() below for a way to perform specific tasks on IO, when |
172 // that's necessary. | 183 // that's necessary. |
173 | 184 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 LoginState::Shutdown(); | 289 LoginState::Shutdown(); |
279 SystemSaltGetter::Shutdown(); | 290 SystemSaltGetter::Shutdown(); |
280 | 291 |
281 // These trigger some tasks that have to run while BrowserThread::UI | 292 // These trigger some tasks that have to run while BrowserThread::UI |
282 // exists. Delete all the profiles before deleting the connector. | 293 // exists. Delete all the profiles before deleting the connector. |
283 browser_process_->SetProfileManager(NULL); | 294 browser_process_->SetProfileManager(NULL); |
284 connector_ = NULL; | 295 connector_ = NULL; |
285 browser_process_->SetBrowserPolicyConnector(NULL); | 296 browser_process_->SetBrowserPolicyConnector(NULL); |
286 QuitIOLoop(); | 297 QuitIOLoop(); |
287 RunUntilIdle(); | 298 RunUntilIdle(); |
| 299 |
| 300 browser_content_client_.reset(); |
| 301 content_client_.reset(); |
| 302 content::SetContentClient(NULL); |
288 } | 303 } |
289 | 304 |
290 void TearDownOnIO() { | 305 void TearDownOnIO() { |
291 // chrome_browser_net::Predictor usually skips its shutdown routines on | 306 // chrome_browser_net::Predictor usually skips its shutdown routines on |
292 // unit_tests, but does the full thing when | 307 // unit_tests, but does the full thing when |
293 // g_browser_process->profile_manager() is valid during initialization. | 308 // g_browser_process->profile_manager() is valid during initialization. |
294 // That includes a WaitableEvent on UI waiting for a task on IO, so that | 309 // That includes a WaitableEvent on UI waiting for a task on IO, so that |
295 // task must execute. Do it directly from here now. | 310 // task must execute. Do it directly from here now. |
296 std::vector<Profile*> profiles = | 311 std::vector<Profile*> profiles = |
297 browser_process_->profile_manager()->GetLoadedProfiles(); | 312 browser_process_->profile_manager()->GetLoadedProfiles(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 em::DeviceManagementResponse response; | 475 em::DeviceManagementResponse response; |
461 response.mutable_policy_response()->add_response(); | 476 response.mutable_policy_response()->add_response(); |
462 return PrepareDMServiceFetcher(kDMPolicyRequest, response); | 477 return PrepareDMServiceFetcher(kDMPolicyRequest, response); |
463 } | 478 } |
464 | 479 |
465 protected: | 480 protected: |
466 // Must be the first member variable as browser_process_ and local_state_ | 481 // Must be the first member variable as browser_process_ and local_state_ |
467 // rely on this being set up. | 482 // rely on this being set up. |
468 TestingBrowserProcessInitializer initializer_; | 483 TestingBrowserProcessInitializer initializer_; |
469 | 484 |
| 485 scoped_ptr<ChromeContentClient> content_client_; |
| 486 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; |
| 487 |
470 base::Closure fake_io_thread_work_; | 488 base::Closure fake_io_thread_work_; |
471 base::WaitableEvent fake_io_thread_completion_; | 489 base::WaitableEvent fake_io_thread_completion_; |
472 base::Thread fake_io_thread_; | 490 base::Thread fake_io_thread_; |
473 | 491 |
474 base::MessageLoopForIO loop_; | 492 base::MessageLoopForIO loop_; |
475 TestingBrowserProcess* browser_process_; | 493 TestingBrowserProcess* browser_process_; |
476 ScopedTestingLocalState local_state_; | 494 ScopedTestingLocalState local_state_; |
477 | 495 |
478 content::TestBrowserThread ui_thread_; | 496 content::TestBrowserThread ui_thread_; |
479 content::TestBrowserThread db_thread_; | 497 content::TestBrowserThread db_thread_; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 LoginUtilsBlockingLoginTest, | 723 LoginUtilsBlockingLoginTest, |
706 testing::Values(0, 1, 2, 3, 4, 5)); | 724 testing::Values(0, 1, 2, 3, 4, 5)); |
707 | 725 |
708 INSTANTIATE_TEST_CASE_P(LoginUtilsParamTestInstantiation, | 726 INSTANTIATE_TEST_CASE_P(LoginUtilsParamTestInstantiation, |
709 LoginUtilsParamTest, | 727 LoginUtilsParamTest, |
710 testing::Bool()); | 728 testing::Bool()); |
711 | 729 |
712 } // namespace | 730 } // namespace |
713 | 731 |
714 } // namespace chromeos | 732 } // namespace chromeos |
OLD | NEW |