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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/file_path.h" | |
13 #include "base/files/scoped_temp_dir.h" | |
14 #include "base/location.h" | 12 #include "base/location.h" |
15 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
16 #include "base/path_service.h" | |
17 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
18 #include "base/stl_util.h" | |
19 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | |
20 #include "chrome/browser/chromeos/cros/cros_mock.h" | 15 #include "chrome/browser/chromeos/cros/cros_mock.h" |
21 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 16 #include "chrome/browser/chromeos/cros/mock_network_library.h" |
22 #include "chrome/browser/chromeos/login/authenticator.h" | 17 #include "chrome/browser/chromeos/login/authenticator.h" |
23 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 18 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
24 #include "chrome/browser/chromeos/login/helper.h" | 19 #include "chrome/browser/chromeos/login/helper.h" |
25 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 20 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
26 #include "chrome/browser/chromeos/login/mock_authenticator.h" | 21 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
27 #include "chrome/browser/chromeos/login/mock_login_display.h" | 22 #include "chrome/browser/chromeos/login/mock_login_display.h" |
28 #include "chrome/browser/chromeos/login/mock_login_display_host.h" | 23 #include "chrome/browser/chromeos/login/mock_login_display_host.h" |
29 #include "chrome/browser/chromeos/login/mock_login_utils.h" | 24 #include "chrome/browser/chromeos/login/mock_login_utils.h" |
30 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" | 25 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" |
31 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 26 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
32 #include "chrome/browser/chromeos/login/user_manager.h" | 27 #include "chrome/browser/chromeos/login/user_manager.h" |
33 #include "chrome/browser/chromeos/login/wizard_controller.h" | 28 #include "chrome/browser/chromeos/login/wizard_controller.h" |
34 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 29 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
35 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 30 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
36 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | |
37 #include "chrome/browser/chromeos/settings/cros_settings.h" | 31 #include "chrome/browser/chromeos/settings/cros_settings.h" |
38 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 32 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
39 #include "chrome/browser/policy/browser_policy_connector.h" | 33 #include "chrome/browser/policy/browser_policy_connector.h" |
40 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 34 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
41 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | 35 #include "chrome/browser/policy/cloud/cloud_policy_core.h" |
42 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | 36 #include "chrome/browser/policy/cloud/cloud_policy_store.h" |
43 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" | 37 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" |
44 #include "chrome/browser/policy/cloud/policy_builder.h" | 38 #include "chrome/browser/policy/cloud/policy_builder.h" |
45 #include "chrome/common/chrome_notification_types.h" | 39 #include "chrome/common/chrome_notification_types.h" |
46 #include "chrome/common/chrome_paths.h" | |
47 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
48 #include "chrome/test/base/testing_browser_process.h" | 41 #include "chrome/test/base/testing_browser_process.h" |
49 #include "chrome/test/base/testing_profile.h" | 42 #include "chrome/test/base/testing_profile.h" |
50 #include "chrome/test/base/ui_test_utils.h" | 43 #include "chrome/test/base/ui_test_utils.h" |
51 #include "chromeos/chromeos_switches.h" | 44 #include "chromeos/chromeos_switches.h" |
52 #include "chromeos/dbus/fake_session_manager_client.h" | 45 #include "chromeos/dbus/fake_session_manager_client.h" |
53 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 46 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
54 #include "chromeos/dbus/mock_session_manager_client.h" | |
55 #include "chromeos/dbus/mock_shill_manager_client.h" | 47 #include "chromeos/dbus/mock_shill_manager_client.h" |
56 #include "chromeos/dbus/mock_update_engine_client.h" | 48 #include "chromeos/dbus/mock_update_engine_client.h" |
57 #include "content/public/browser/notification_details.h" | 49 #include "content/public/browser/notification_details.h" |
58 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" |
59 #include "content/public/test/mock_notification_observer.h" | 51 #include "content/public/test/mock_notification_observer.h" |
60 #include "crypto/rsa_private_key.h" | |
61 #include "google_apis/gaia/mock_url_fetcher_factory.h" | 52 #include "google_apis/gaia/mock_url_fetcher_factory.h" |
62 #include "grit/generated_resources.h" | 53 #include "grit/generated_resources.h" |
63 #include "testing/gmock/include/gmock/gmock.h" | 54 #include "testing/gmock/include/gmock/gmock.h" |
64 #include "testing/gtest/include/gtest/gtest.h" | 55 #include "testing/gtest/include/gtest/gtest.h" |
65 #include "ui/base/l10n/l10n_util.h" | 56 #include "ui/base/l10n/l10n_util.h" |
66 | 57 |
67 using ::testing::_; | 58 using ::testing::_; |
68 using ::testing::AnyNumber; | 59 using ::testing::AnyNumber; |
69 using ::testing::Invoke; | 60 using ::testing::Invoke; |
70 using ::testing::InvokeWithoutArgs; | 61 using ::testing::InvokeWithoutArgs; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 private: | 127 private: |
137 int type_; | 128 int type_; |
138 ConditionTestCallback callback_; | 129 ConditionTestCallback callback_; |
139 base::RunLoop run_loop_; | 130 base::RunLoop run_loop_; |
140 | 131 |
141 DISALLOW_COPY_AND_ASSIGN(NotificationWatcher); | 132 DISALLOW_COPY_AND_ASSIGN(NotificationWatcher); |
142 }; | 133 }; |
143 | 134 |
144 } // namespace | 135 } // namespace |
145 | 136 |
146 class ExistingUserControllerTest : public CrosInProcessBrowserTest { | 137 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { |
147 protected: | 138 protected: |
148 ExistingUserControllerTest() | 139 ExistingUserControllerTest() |
149 : mock_network_library_(NULL), | 140 : mock_network_library_(NULL), |
150 mock_login_display_(NULL), | 141 mock_login_display_(NULL), |
151 mock_user_manager_(NULL), | 142 mock_user_manager_(NULL), |
152 testing_profile_(NULL) { | 143 testing_profile_(NULL) { |
153 } | 144 } |
154 | 145 |
155 ExistingUserController* existing_user_controller() { | 146 ExistingUserController* existing_user_controller() { |
156 return ExistingUserController::current_controller(); | 147 return ExistingUserController::current_controller(); |
157 } | 148 } |
158 | 149 |
159 const ExistingUserController* existing_user_controller() const { | 150 const ExistingUserController* existing_user_controller() const { |
160 return ExistingUserController::current_controller(); | 151 return ExistingUserController::current_controller(); |
161 } | 152 } |
162 | 153 |
163 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 154 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
164 MockDBusThreadManager* mock_dbus_thread_manager = | 155 EXPECT_CALL(*mock_dbus_thread_manager(), GetSystemBus()) |
165 new MockDBusThreadManager; | |
166 EXPECT_CALL(*mock_dbus_thread_manager, GetSystemBus()) | |
167 .WillRepeatedly(Return(reinterpret_cast<dbus::Bus*>(NULL))); | 156 .WillRepeatedly(Return(reinterpret_cast<dbus::Bus*>(NULL))); |
168 EXPECT_CALL(*mock_dbus_thread_manager, GetIBusInputContextClient()) | 157 EXPECT_CALL(*mock_dbus_thread_manager(), GetIBusInputContextClient()) |
169 .WillRepeatedly( | 158 .WillRepeatedly( |
170 Return(reinterpret_cast<IBusInputContextClient*>(NULL))); | 159 Return(reinterpret_cast<IBusInputContextClient*>(NULL))); |
171 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(), | 160 EXPECT_CALL(*mock_dbus_thread_manager()->mock_shill_manager_client(), |
172 GetProperties(_)) | 161 GetProperties(_)) |
173 .Times(AnyNumber()); | 162 .Times(AnyNumber()); |
174 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(), | 163 EXPECT_CALL(*mock_dbus_thread_manager()->mock_shill_manager_client(), |
175 AddPropertyChangedObserver(_)) | 164 AddPropertyChangedObserver(_)) |
176 .Times(AnyNumber()); | 165 .Times(AnyNumber()); |
177 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(), | 166 EXPECT_CALL(*mock_dbus_thread_manager()->mock_shill_manager_client(), |
178 RemovePropertyChangedObserver(_)) | 167 RemovePropertyChangedObserver(_)) |
179 .Times(AnyNumber()); | 168 .Times(AnyNumber()); |
180 | 169 |
181 SetUpSessionManager(mock_dbus_thread_manager); | 170 SetUpSessionManager(); |
182 | 171 |
183 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); | 172 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); |
184 CrosInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | |
185 cros_mock_->InitStatusAreaMocks(); | 173 cros_mock_->InitStatusAreaMocks(); |
186 cros_mock_->SetStatusAreaMocksExpectations(); | 174 cros_mock_->SetStatusAreaMocksExpectations(); |
187 | 175 |
188 mock_network_library_ = cros_mock_->mock_network_library(); | 176 mock_network_library_ = cros_mock_->mock_network_library(); |
189 EXPECT_CALL(*mock_network_library_, AddUserActionObserver(_)) | 177 EXPECT_CALL(*mock_network_library_, AddUserActionObserver(_)) |
190 .Times(AnyNumber()); | 178 .Times(AnyNumber()); |
191 EXPECT_CALL(*mock_network_library_, LoadOncNetworks(_, _, _, _)) | 179 EXPECT_CALL(*mock_network_library_, LoadOncNetworks(_, _, _, _)) |
192 .WillRepeatedly(Return(true)); | 180 .WillRepeatedly(Return(true)); |
193 | 181 |
194 mock_login_utils_ = new MockLoginUtils(); | 182 mock_login_utils_ = new MockLoginUtils(); |
195 LoginUtils::Set(mock_login_utils_); | 183 LoginUtils::Set(mock_login_utils_); |
196 EXPECT_CALL(*mock_login_utils_, PrewarmAuthentication()) | 184 EXPECT_CALL(*mock_login_utils_, PrewarmAuthentication()) |
197 .Times(AnyNumber()); | 185 .Times(AnyNumber()); |
198 EXPECT_CALL(*mock_login_utils_, StopBackgroundFetchers()) | 186 EXPECT_CALL(*mock_login_utils_, StopBackgroundFetchers()) |
199 .Times(AnyNumber()); | 187 .Times(AnyNumber()); |
200 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_)) | 188 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_)) |
201 .Times(1); | 189 .Times(1); |
202 | 190 |
203 mock_login_display_host_.reset(new MockLoginDisplayHost()); | 191 mock_login_display_host_.reset(new MockLoginDisplayHost()); |
204 mock_login_display_ = new MockLoginDisplay(); | 192 mock_login_display_ = new MockLoginDisplay(); |
205 SetUpLoginDisplay(); | 193 SetUpLoginDisplay(); |
206 } | 194 } |
207 | 195 |
208 virtual void SetUpSessionManager( | 196 virtual void SetUpSessionManager() { |
209 MockDBusThreadManager* mock_dbus_thread_manager) { | |
210 MockSessionManagerClient* mock_session_manager_client = | |
211 mock_dbus_thread_manager->mock_session_manager_client(); | |
212 EXPECT_CALL(*mock_session_manager_client, EmitLoginPromptReady()) | |
213 .Times(1); | |
214 EXPECT_CALL(*mock_session_manager_client, RetrieveDevicePolicy(_)) | |
215 .Times(AnyNumber()); | |
216 } | 197 } |
217 | 198 |
218 virtual void SetUpLoginDisplay() { | 199 virtual void SetUpLoginDisplay() { |
219 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) | 200 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) |
220 .Times(1) | 201 .Times(1) |
221 .WillOnce(Return(mock_login_display_)); | 202 .WillOnce(Return(mock_login_display_)); |
222 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) | 203 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) |
223 .Times(1) | 204 .Times(1) |
224 .WillOnce(ReturnNull()); | 205 .WillOnce(ReturnNull()); |
225 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) | 206 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // If there is an outstanding login attempt when ExistingUserController is | 264 // If there is an outstanding login attempt when ExistingUserController is |
284 // deleted, its LoginPerformer instance will be deleted, which in turn | 265 // deleted, its LoginPerformer instance will be deleted, which in turn |
285 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must | 266 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must |
286 // be deleted on the UI thread. | 267 // be deleted on the UI thread. |
287 existing_user_controller_.reset(); | 268 existing_user_controller_.reset(); |
288 CrosInProcessBrowserTest::CleanUpOnMainThread(); | 269 CrosInProcessBrowserTest::CleanUpOnMainThread(); |
289 testing_profile_.reset(NULL); | 270 testing_profile_.reset(NULL); |
290 user_manager_enabler_.reset(); | 271 user_manager_enabler_.reset(); |
291 } | 272 } |
292 | 273 |
293 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | |
294 CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); | |
295 DBusThreadManager::Shutdown(); | |
296 } | |
297 | |
298 // ExistingUserController private member accessors. | 274 // ExistingUserController private member accessors. |
299 base::OneShotTimer<ExistingUserController>* auto_login_timer() { | 275 base::OneShotTimer<ExistingUserController>* auto_login_timer() { |
300 return existing_user_controller()->auto_login_timer_.get(); | 276 return existing_user_controller()->auto_login_timer_.get(); |
301 } | 277 } |
302 | 278 |
303 const std::string& auto_login_username() const { | 279 const std::string& auto_login_username() const { |
304 return existing_user_controller()->public_session_auto_login_username_; | 280 return existing_user_controller()->public_session_auto_login_username_; |
305 } | 281 } |
306 | 282 |
307 int auto_login_delay() const { | 283 int auto_login_delay() const { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 base::RunLoop loop; | 457 base::RunLoop loop; |
482 store->AddObserver(&observer); | 458 store->AddObserver(&observer); |
483 EXPECT_CALL(observer, OnStoreLoaded(store)) | 459 EXPECT_CALL(observer, OnStoreLoaded(store)) |
484 .Times(1) | 460 .Times(1) |
485 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); | 461 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); |
486 loop.Run(); | 462 loop.Run(); |
487 store->RemoveObserver(&observer); | 463 store->RemoveObserver(&observer); |
488 } | 464 } |
489 } | 465 } |
490 | 466 |
491 virtual void SetUpSessionManager( | 467 virtual void SetUpSessionManager() OVERRIDE { |
492 MockDBusThreadManager* mock_dbus_thread_manager) OVERRIDE { | 468 InstallOwnerKey(); |
493 EXPECT_CALL(*mock_dbus_thread_manager, GetSessionManagerClient()) | |
494 .WillRepeatedly(Return(&session_manager_client_)); | |
495 | |
496 // Install the owner key. | |
497 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
498 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key"); | |
499 std::vector<uint8> owner_key_bits; | |
500 ASSERT_TRUE(device_policy_.signing_key()->ExportPublicKey(&owner_key_bits)); | |
501 ASSERT_EQ( | |
502 file_util::WriteFile( | |
503 owner_key_file, | |
504 reinterpret_cast<const char*>(vector_as_array(&owner_key_bits)), | |
505 owner_key_bits.size()), | |
506 static_cast<int>(owner_key_bits.size())); | |
507 ASSERT_TRUE(PathService::Override(chrome::FILE_OWNER_KEY, owner_key_file)); | |
508 | 469 |
509 // Setup the device policy. | 470 // Setup the device policy. |
510 em::ChromeDeviceSettingsProto& proto(device_policy_.payload()); | 471 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
511 proto.mutable_device_local_accounts()->add_account()->set_id( | 472 proto.mutable_device_local_accounts()->add_account()->set_id( |
512 kAutoLoginUsername); | 473 kAutoLoginUsername); |
513 RefreshDevicePolicy(); | 474 RefreshDevicePolicy(); |
514 | 475 |
515 // Setup the device local account policy. | 476 // Setup the device local account policy. |
516 policy::UserPolicyBuilder device_local_account_policy; | 477 policy::UserPolicyBuilder device_local_account_policy; |
517 device_local_account_policy.policy_data().set_username(kAutoLoginUsername); | 478 device_local_account_policy.policy_data().set_username(kAutoLoginUsername); |
518 device_local_account_policy.policy_data().set_policy_type( | 479 device_local_account_policy.policy_data().set_policy_type( |
519 policy::dm_protocol::kChromePublicAccountPolicyType); | 480 policy::dm_protocol::kChromePublicAccountPolicyType); |
520 device_local_account_policy.policy_data().set_settings_entity_id( | 481 device_local_account_policy.policy_data().set_settings_entity_id( |
521 kAutoLoginUsername); | 482 kAutoLoginUsername); |
522 device_local_account_policy.Build(); | 483 device_local_account_policy.Build(); |
523 session_manager_client_.set_device_local_account_policy( | 484 session_manager_client()->set_device_local_account_policy( |
524 kAutoLoginUsername, | 485 kAutoLoginUsername, |
525 device_local_account_policy.GetBlob()); | 486 device_local_account_policy.GetBlob()); |
526 } | 487 } |
527 | 488 |
528 virtual void SetUpLoginDisplay() OVERRIDE { | 489 virtual void SetUpLoginDisplay() OVERRIDE { |
529 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) | 490 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) |
530 .Times(1) | 491 .Times(1) |
531 .WillOnce(Return(mock_login_display_)); | 492 .WillOnce(Return(mock_login_display_)); |
532 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) | 493 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) |
533 .Times(AnyNumber()) | 494 .Times(AnyNumber()) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 content::MockNotificationObserver& observer, const char* setting) { | 537 content::MockNotificationObserver& observer, const char* setting) { |
577 base::RunLoop* loop = new base::RunLoop; | 538 base::RunLoop* loop = new base::RunLoop; |
578 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, | 539 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, |
579 _, HasDetails(setting))) | 540 _, HasDetails(setting))) |
580 .Times(1) | 541 .Times(1) |
581 .WillOnce(InvokeWithoutArgs(loop, &base::RunLoop::Quit)); | 542 .WillOnce(InvokeWithoutArgs(loop, &base::RunLoop::Quit)); |
582 CrosSettings::Get()->AddSettingsObserver(setting, &observer); | 543 CrosSettings::Get()->AddSettingsObserver(setting, &observer); |
583 return make_scoped_ptr(loop); | 544 return make_scoped_ptr(loop); |
584 } | 545 } |
585 | 546 |
586 void RefreshDevicePolicy() { | |
587 // Reset the key to its original state. | |
588 device_policy_.set_signing_key( | |
589 policy::PolicyBuilder::CreateTestSigningKey()); | |
590 device_policy_.Build(); | |
591 // Trick the device into thinking it's enterprise-enrolled by | |
592 // removing the local private key. This will allow it to accept | |
593 // cloud policy for device owner settings. | |
594 device_policy_.set_signing_key( | |
595 make_scoped_ptr<crypto::RSAPrivateKey>(NULL)); | |
596 device_policy_.set_new_signing_key( | |
597 make_scoped_ptr<crypto::RSAPrivateKey>(NULL)); | |
598 session_manager_client_.set_device_policy(device_policy_.GetBlob()); | |
599 session_manager_client_.OnPropertyChangeComplete(true); | |
600 } | |
601 | |
602 void SetAutoLoginPolicy(const std::string& username, int delay) { | 547 void SetAutoLoginPolicy(const std::string& username, int delay) { |
603 // Wait until ExistingUserController has finished auto-login | 548 // Wait until ExistingUserController has finished auto-login |
604 // configuration by observing the same settings that trigger | 549 // configuration by observing the same settings that trigger |
605 // ConfigurePublicSessionAutoLogin. | 550 // ConfigurePublicSessionAutoLogin. |
606 content::MockNotificationObserver observer; | 551 content::MockNotificationObserver observer; |
607 | 552 |
608 em::ChromeDeviceSettingsProto& proto(device_policy_.payload()); | 553 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
609 | 554 |
610 // If both settings have changed we need to wait for both to | 555 // If both settings have changed we need to wait for both to |
611 // propagate, so check the new values against the old ones. | 556 // propagate, so check the new values against the old ones. |
612 scoped_ptr<base::RunLoop> runner1; | 557 scoped_ptr<base::RunLoop> runner1; |
613 if (!proto.has_device_local_accounts() || | 558 if (!proto.has_device_local_accounts() || |
614 !proto.device_local_accounts().has_auto_login_id() || | 559 !proto.device_local_accounts().has_auto_login_id() || |
615 proto.device_local_accounts().auto_login_id() != username) { | 560 proto.device_local_accounts().auto_login_id() != username) { |
616 runner1 = CreateSettingsObserverRunLoop( | 561 runner1 = CreateSettingsObserverRunLoop( |
617 observer, kAccountsPrefDeviceLocalAccountAutoLoginId); | 562 observer, kAccountsPrefDeviceLocalAccountAutoLoginId); |
618 } | 563 } |
(...skipping 26 matching lines...) Expand all Loading... |
645 } | 590 } |
646 | 591 |
647 void ConfigureAutoLogin() { | 592 void ConfigureAutoLogin() { |
648 existing_user_controller()->ConfigurePublicSessionAutoLogin(); | 593 existing_user_controller()->ConfigurePublicSessionAutoLogin(); |
649 } | 594 } |
650 | 595 |
651 void FireAutoLogin() { | 596 void FireAutoLogin() { |
652 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); | 597 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); |
653 } | 598 } |
654 | 599 |
655 // Mock out policy loads/stores from/to the device. | |
656 FakeSessionManagerClient session_manager_client_; | |
657 | |
658 // Stores the device owner key. | |
659 base::ScopedTempDir temp_dir_; | |
660 | |
661 // Carries Chrome OS device policies for tests. | |
662 policy::DevicePolicyBuilder device_policy_; | |
663 | |
664 private: | 600 private: |
665 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); | 601 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); |
666 }; | 602 }; |
667 | 603 |
668 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 604 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
669 ConfigureAutoLoginUsingPolicy) { | 605 ConfigureAutoLoginUsingPolicy) { |
670 existing_user_controller()->OnSigninScreenReady(); | 606 existing_user_controller()->OnSigninScreenReady(); |
671 EXPECT_EQ("", auto_login_username()); | 607 EXPECT_EQ("", auto_login_username()); |
672 EXPECT_EQ(0, auto_login_delay()); | 608 EXPECT_EQ(0, auto_login_delay()); |
673 EXPECT_FALSE(auto_login_timer()); | 609 EXPECT_FALSE(auto_login_timer()); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 | 752 |
817 // Wait for login tasks to complete. | 753 // Wait for login tasks to complete. |
818 content::RunAllPendingInMessageLoop(); | 754 content::RunAllPendingInMessageLoop(); |
819 | 755 |
820 // Timer should still be stopped after login completes. | 756 // Timer should still be stopped after login completes. |
821 ASSERT_TRUE(auto_login_timer()); | 757 ASSERT_TRUE(auto_login_timer()); |
822 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 758 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
823 } | 759 } |
824 | 760 |
825 } // namespace chromeos | 761 } // namespace chromeos |
OLD | NEW |