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 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/chromeos/login/authenticator.h" | 21 #include "chrome/browser/chromeos/login/authenticator.h" |
22 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 22 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
23 #include "chrome/browser/chromeos/login/user_manager.h" | 23 #include "chrome/browser/chromeos/login/user_manager.h" |
24 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 24 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
25 #include "chrome/browser/io_thread.h" | 25 #include "chrome/browser/io_thread.h" |
26 #include "chrome/browser/net/predictor.h" | 26 #include "chrome/browser/net/predictor.h" |
27 #include "chrome/browser/policy/browser_policy_connector.h" | 27 #include "chrome/browser/policy/browser_policy_connector.h" |
28 #include "chrome/browser/policy/policy_service.h" | 28 #include "chrome/browser/policy/policy_service.h" |
29 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 29 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/rlz/rlz.h" |
31 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
32 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
33 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
35 #include "chrome/test/base/testing_browser_process.h" | 36 #include "chrome/test/base/testing_browser_process.h" |
36 #include "chrome/test/base/testing_pref_service.h" | 37 #include "chrome/test/base/testing_pref_service.h" |
37 #include "chromeos/cryptohome/mock_async_method_caller.h" | 38 #include "chromeos/cryptohome/mock_async_method_caller.h" |
38 #include "chromeos/dbus/mock_cryptohome_client.h" | 39 #include "chromeos/dbus/mock_cryptohome_client.h" |
39 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 40 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
40 #include "chromeos/dbus/mock_session_manager_client.h" | 41 #include "chromeos/dbus/mock_session_manager_client.h" |
41 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/test/test_browser_thread.h" | 43 #include "content/public/test/test_browser_thread.h" |
43 #include "content/public/test/test_utils.h" | 44 #include "content/public/test/test_utils.h" |
44 #include "google_apis/gaia/gaia_auth_consumer.h" | 45 #include "google_apis/gaia/gaia_auth_consumer.h" |
45 #include "google_apis/gaia/gaia_urls.h" | 46 #include "google_apis/gaia/gaia_urls.h" |
46 #include "net/url_request/test_url_fetcher_factory.h" | 47 #include "net/url_request/test_url_fetcher_factory.h" |
47 #include "net/url_request/url_fetcher_delegate.h" | 48 #include "net/url_request/url_fetcher_delegate.h" |
48 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
49 #include "net/url_request/url_request_status.h" | 50 #include "net/url_request/url_request_status.h" |
50 #include "testing/gmock/include/gmock/gmock.h" | 51 #include "testing/gmock/include/gmock/gmock.h" |
51 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
52 | 53 |
| 54 #if defined(ENABLE_RLZ) |
| 55 #include "rlz/lib/rlz_value_store.h" |
| 56 #endif |
| 57 |
53 namespace chromeos { | 58 namespace chromeos { |
54 | 59 |
55 namespace { | 60 namespace { |
56 | 61 |
57 namespace em = enterprise_management; | 62 namespace em = enterprise_management; |
58 | 63 |
59 using ::testing::DoAll; | 64 using ::testing::DoAll; |
60 using ::testing::Return; | 65 using ::testing::Return; |
61 using ::testing::SaveArg; | 66 using ::testing::SaveArg; |
62 using ::testing::SetArgPointee; | 67 using ::testing::SetArgPointee; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 browser_process_->SetProfileManager( | 262 browser_process_->SetProfileManager( |
258 new ProfileManagerWithoutInit(scoped_temp_dir_.path())); | 263 new ProfileManagerWithoutInit(scoped_temp_dir_.path())); |
259 connector_ = browser_process_->browser_policy_connector(); | 264 connector_ = browser_process_->browser_policy_connector(); |
260 connector_->Init(); | 265 connector_->Init(); |
261 | 266 |
262 io_thread_state_.reset(new IOThread(local_state_.Get(), | 267 io_thread_state_.reset(new IOThread(local_state_.Get(), |
263 g_browser_process->policy_service(), | 268 g_browser_process->policy_service(), |
264 NULL, NULL)); | 269 NULL, NULL)); |
265 browser_process_->SetIOThread(io_thread_state_.get()); | 270 browser_process_->SetIOThread(io_thread_state_.get()); |
266 | 271 |
| 272 #if defined(ENABLE_RLZ) |
| 273 rlz_lib::testing::SetRlzStoreDirectory(scoped_temp_dir_.path()); |
| 274 RLZTracker::EnableZeroDelayForTesting(); |
| 275 #endif |
| 276 |
267 RunUntilIdle(); | 277 RunUntilIdle(); |
268 } | 278 } |
269 | 279 |
270 virtual void TearDown() OVERRIDE { | 280 virtual void TearDown() OVERRIDE { |
271 cryptohome::AsyncMethodCaller::Shutdown(); | 281 cryptohome::AsyncMethodCaller::Shutdown(); |
272 mock_async_method_caller_ = NULL; | 282 mock_async_method_caller_ = NULL; |
273 | 283 |
274 UserManager::Get()->Shutdown(); | 284 UserManager::Get()->Shutdown(); |
275 | 285 |
276 InvokeOnIO( | 286 InvokeOnIO( |
277 base::Bind(&LoginUtilsTest::TearDownOnIO, base::Unretained(this))); | 287 base::Bind(&LoginUtilsTest::TearDownOnIO, base::Unretained(this))); |
278 | 288 |
| 289 // LoginUtils instance must not outlive Profile instances. |
| 290 LoginUtils::Set(NULL); |
| 291 |
279 // These trigger some tasks that have to run while BrowserThread::UI | 292 // These trigger some tasks that have to run while BrowserThread::UI |
280 // exists. Delete all the profiles before deleting the connector. | 293 // exists. Delete all the profiles before deleting the connector. |
281 browser_process_->SetProfileManager(NULL); | 294 browser_process_->SetProfileManager(NULL); |
282 connector_ = NULL; | 295 connector_ = NULL; |
283 browser_process_->SetBrowserPolicyConnector(NULL); | 296 browser_process_->SetBrowserPolicyConnector(NULL); |
284 QuitIOLoop(); | 297 QuitIOLoop(); |
285 RunUntilIdle(); | 298 RunUntilIdle(); |
286 } | 299 } |
287 | 300 |
288 void TearDownOnIO() { | 301 void TearDownOnIO() { |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 } | 616 } |
604 | 617 |
605 INSTANTIATE_TEST_CASE_P( | 618 INSTANTIATE_TEST_CASE_P( |
606 LoginUtilsBlockingLoginTestInstance, | 619 LoginUtilsBlockingLoginTestInstance, |
607 LoginUtilsBlockingLoginTest, | 620 LoginUtilsBlockingLoginTest, |
608 testing::Values(0, 1, 2, 3, 4, 5)); | 621 testing::Values(0, 1, 2, 3, 4, 5)); |
609 | 622 |
610 } // namespace | 623 } // namespace |
611 | 624 |
612 } | 625 } |
OLD | NEW |