| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 14 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 15 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" | 15 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" |
| 16 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 16 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
| 17 #include "chrome/browser/chromeos/login/authenticator.h" | 17 #include "chrome/browser/chromeos/login/authenticator.h" |
| 18 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 18 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
| 19 #include "chrome/browser/chromeos/login/user_manager.h" | 19 #include "chrome/browser/chromeos/login/user_manager.h" |
| 20 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 20 #include "chrome/browser/io_thread.h" | 21 #include "chrome/browser/io_thread.h" |
| 21 #include "chrome/browser/net/predictor.h" | 22 #include "chrome/browser/net/predictor.h" |
| 22 #include "chrome/browser/policy/browser_policy_connector.h" | 23 #include "chrome/browser/policy/browser_policy_connector.h" |
| 23 #include "chrome/browser/policy/cloud_policy_data_store.h" | 24 #include "chrome/browser/policy/cloud_policy_data_store.h" |
| 24 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 25 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 29 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 29 #include "chrome/common/net/gaia/gaia_urls.h" | 30 #include "chrome/common/net/gaia/gaia_urls.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 policy::CloudPolicyDataStore* device_data_store = | 281 policy::CloudPolicyDataStore* device_data_store = |
| 281 connector_->GetDeviceCloudPolicyDataStore(); | 282 connector_->GetDeviceCloudPolicyDataStore(); |
| 282 device_data_store->set_device_mode(policy::DEVICE_MODE_ENTERPRISE); | 283 device_data_store->set_device_mode(policy::DEVICE_MODE_ENTERPRISE); |
| 283 device_data_store->set_device_id(kDeviceId); | 284 device_data_store->set_device_id(kDeviceId); |
| 284 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, | 285 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, |
| 285 connector_->LockDevice(username)); | 286 connector_->LockDevice(username)); |
| 286 RunAllPending(); | 287 RunAllPending(); |
| 287 } | 288 } |
| 288 | 289 |
| 289 void PrepareProfile(const std::string& username) { | 290 void PrepareProfile(const std::string& username) { |
| 290 MockSessionManagerClient* session_managed_client = | 291 ScopedDeviceSettingsTestHelper device_settings_test_helper; |
| 292 MockSessionManagerClient* session_manager_client = |
| 291 mock_dbus_thread_manager_.mock_session_manager_client(); | 293 mock_dbus_thread_manager_.mock_session_manager_client(); |
| 292 EXPECT_CALL(*session_managed_client, StartSession(_)); | 294 EXPECT_CALL(*session_manager_client, StartSession(_)); |
| 293 EXPECT_CALL(*cryptohome_, GetSystemSalt()) | 295 EXPECT_CALL(*cryptohome_, GetSystemSalt()) |
| 294 .WillRepeatedly(Return(std::string("stub_system_salt"))); | 296 .WillRepeatedly(Return(std::string("stub_system_salt"))); |
| 295 EXPECT_CALL(*mock_async_method_caller_, AsyncMount(_, _, _, _)) | 297 EXPECT_CALL(*mock_async_method_caller_, AsyncMount(_, _, _, _)) |
| 296 .WillRepeatedly(Return()); | 298 .WillRepeatedly(Return()); |
| 297 | 299 |
| 298 scoped_refptr<Authenticator> authenticator = | 300 scoped_refptr<Authenticator> authenticator = |
| 299 LoginUtils::Get()->CreateAuthenticator(this); | 301 LoginUtils::Get()->CreateAuthenticator(this); |
| 300 authenticator->CompleteLogin(ProfileManager::GetDefaultProfile(), | 302 authenticator->CompleteLogin(ProfileManager::GetDefaultProfile(), |
| 301 username, | 303 username, |
| 302 "password"); | 304 "password"); |
| 303 | 305 |
| 304 LoginUtils::Get()->PrepareProfile(username, std::string(), "password", | 306 LoginUtils::Get()->PrepareProfile(username, std::string(), "password", |
| 305 false, true, false, this); | 307 false, true, false, this); |
| 308 device_settings_test_helper.Flush(); |
| 306 RunAllPending(); | 309 RunAllPending(); |
| 307 } | 310 } |
| 308 | 311 |
| 309 net::TestURLFetcher* PrepareOAuthFetcher(const std::string& expected_url) { | 312 net::TestURLFetcher* PrepareOAuthFetcher(const std::string& expected_url) { |
| 310 net::TestURLFetcher* fetcher = test_url_fetcher_factory_.GetFetcherByID(0); | 313 net::TestURLFetcher* fetcher = test_url_fetcher_factory_.GetFetcherByID(0); |
| 311 EXPECT_TRUE(fetcher); | 314 EXPECT_TRUE(fetcher); |
| 312 EXPECT_TRUE(fetcher->delegate()); | 315 EXPECT_TRUE(fetcher->delegate()); |
| 313 EXPECT_TRUE(StartsWithASCII(fetcher->GetOriginalURL().spec(), | 316 EXPECT_TRUE(StartsWithASCII(fetcher->GetOriginalURL().spec(), |
| 314 expected_url, | 317 expected_url, |
| 315 true)); | 318 true)); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 } | 514 } |
| 512 | 515 |
| 513 INSTANTIATE_TEST_CASE_P( | 516 INSTANTIATE_TEST_CASE_P( |
| 514 LoginUtilsBlockingLoginTestInstance, | 517 LoginUtilsBlockingLoginTestInstance, |
| 515 LoginUtilsBlockingLoginTest, | 518 LoginUtilsBlockingLoginTest, |
| 516 testing::Values(0, 1, 2, 3, 4, 5)); | 519 testing::Values(0, 1, 2, 3, 4, 5)); |
| 517 | 520 |
| 518 } // namespace | 521 } // namespace |
| 519 | 522 |
| 520 } | 523 } |
| OLD | NEW |