Chromium Code Reviews| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/prefs/pref_service.h" | |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 17 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 17 #include "chrome/browser/chromeos/login/help_app_launcher.h" | 18 #include "chrome/browser/chromeos/login/help_app_launcher.h" |
| 18 #include "chrome/browser/chromeos/login/helper.h" | 19 #include "chrome/browser/chromeos/login/helper.h" |
| 19 #include "chrome/browser/chromeos/login/mock_login_utils.h" | |
| 20 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h" | 20 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h" |
| 21 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | |
| 22 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" | |
| 21 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_scre en.h" | 23 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_scre en.h" |
| 22 #include "chrome/browser/chromeos/login/ui/mock_login_display.h" | 24 #include "chrome/browser/chromeos/login/ui/mock_login_display.h" |
| 23 #include "chrome/browser/chromeos/login/ui/mock_login_display_host.h" | 25 #include "chrome/browser/chromeos/login/ui/mock_login_display_host.h" |
| 24 #include "chrome/browser/chromeos/login/user_flow.h" | 26 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
| 25 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | |
| 26 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 27 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 27 #include "chrome/browser/chromeos/login/wizard_controller.h" | 28 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 28 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 29 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 29 #include "chrome/browser/chromeos/policy/device_local_account.h" | 30 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 30 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 31 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 31 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 32 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 32 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 33 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 33 #include "chrome/browser/chromeos/settings/cros_settings.h" | 34 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 34 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen _handler.h" | 35 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen _handler.h" |
| 35 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
| 36 #include "chrome/test/base/testing_browser_process.h" | 37 #include "chrome/test/base/testing_browser_process.h" |
| 37 #include "chrome/test/base/testing_profile.h" | |
| 38 #include "chromeos/chromeos_switches.h" | 38 #include "chromeos/chromeos_switches.h" |
| 39 #include "chromeos/dbus/fake_session_manager_client.h" | 39 #include "chromeos/dbus/fake_session_manager_client.h" |
| 40 #include "chromeos/login/auth/authenticator.h" | |
| 41 #include "chromeos/login/auth/key.h" | 40 #include "chromeos/login/auth/key.h" |
| 42 #include "chromeos/login/auth/mock_authenticator.h" | |
| 43 #include "chromeos/login/auth/mock_url_fetchers.h" | 41 #include "chromeos/login/auth/mock_url_fetchers.h" |
| 44 #include "chromeos/login/auth/user_context.h" | 42 #include "chromeos/login/auth/user_context.h" |
| 45 #include "chromeos/login/user_names.h" | 43 #include "chromeos/login/user_names.h" |
| 46 #include "chromeos/settings/cros_settings_names.h" | 44 #include "chromeos/settings/cros_settings_names.h" |
| 47 #include "chromeos/settings/cros_settings_provider.h" | 45 #include "chromeos/settings/cros_settings_provider.h" |
| 48 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 46 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 49 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 47 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 50 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 48 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 51 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 49 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
| 52 #include "components/policy/core/common/cloud/policy_builder.h" | 50 #include "components/policy/core/common/cloud/policy_builder.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 68 using ::testing::WithArg; | 66 using ::testing::WithArg; |
| 69 using ::testing::_; | 67 using ::testing::_; |
| 70 | 68 |
| 71 namespace em = enterprise_management; | 69 namespace em = enterprise_management; |
| 72 | 70 |
| 73 namespace chromeos { | 71 namespace chromeos { |
| 74 | 72 |
| 75 namespace { | 73 namespace { |
| 76 | 74 |
| 77 const char kUsername[] = "test_user@gmail.com"; | 75 const char kUsername[] = "test_user@gmail.com"; |
| 78 const char kNewUsername[] = "test_new_user@gmail.com"; | |
| 79 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; | 76 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; |
| 80 const char kPassword[] = "test_password"; | 77 const char kPassword[] = "test_password"; |
| 81 | 78 |
| 82 const char kPublicSessionAccountId[] = "public_session_user@localhost"; | 79 const char kPublicSessionAccountId[] = "public_session_user@localhost"; |
| 83 const int kAutoLoginNoDelay = 0; | 80 const int kAutoLoginNoDelay = 0; |
| 84 const int kAutoLoginShortDelay = 1; | 81 const int kAutoLoginShortDelay = 1; |
| 85 const int kAutoLoginLongDelay = 10000; | 82 const int kAutoLoginLongDelay = 10000; |
| 86 | 83 |
| 87 ACTION_P(CreateAuthenticator, user_context) { | |
| 88 return new MockAuthenticator(arg0, user_context); | |
| 89 } | |
| 90 | |
| 91 void DeleteUserFlow(UserFlow* user_flow) { | |
| 92 delete user_flow; | |
| 93 } | |
| 94 | |
| 95 // Wait for cros settings to become permanently untrusted and run |callback|. | 84 // Wait for cros settings to become permanently untrusted and run |callback|. |
| 96 void WaitForPermanentlyUntrustedStatusAndRun(const base::Closure& callback) { | 85 void WaitForPermanentlyUntrustedStatusAndRun(const base::Closure& callback) { |
| 97 while (true) { | 86 while (true) { |
| 98 const CrosSettingsProvider::TrustedStatus status = | 87 const CrosSettingsProvider::TrustedStatus status = |
| 99 CrosSettings::Get()->PrepareTrustedValues(base::Bind( | 88 CrosSettings::Get()->PrepareTrustedValues(base::Bind( |
| 100 &WaitForPermanentlyUntrustedStatusAndRun, | 89 &WaitForPermanentlyUntrustedStatusAndRun, |
| 101 callback)); | 90 callback)); |
| 102 switch (status) { | 91 switch (status) { |
| 103 case CrosSettingsProvider::PERMANENTLY_UNTRUSTED: | 92 case CrosSettingsProvider::PERMANENTLY_UNTRUSTED: |
| 104 callback.Run(); | 93 callback.Run(); |
| 105 return; | 94 return; |
| 106 case CrosSettingsProvider::TEMPORARILY_UNTRUSTED: | 95 case CrosSettingsProvider::TEMPORARILY_UNTRUSTED: |
| 107 return; | 96 return; |
| 108 case CrosSettingsProvider::TRUSTED: | 97 case CrosSettingsProvider::TRUSTED: |
| 109 content::RunAllPendingInMessageLoop(); | 98 content::RunAllPendingInMessageLoop(); |
| 110 break; | 99 break; |
| 111 } | 100 } |
| 112 } | 101 } |
| 113 } | 102 } |
| 114 | 103 |
| 115 } // namespace | 104 } // namespace |
| 116 | 105 |
| 117 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { | 106 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { |
| 118 protected: | 107 protected: |
| 119 ExistingUserControllerTest() | 108 ExistingUserControllerTest() : mock_login_display_(NULL) {} |
| 120 : mock_login_display_(NULL), mock_user_manager_(NULL) {} | |
| 121 | 109 |
| 122 ExistingUserController* existing_user_controller() { | 110 ExistingUserController* existing_user_controller() { |
| 123 return ExistingUserController::current_controller(); | 111 return ExistingUserController::current_controller(); |
| 124 } | 112 } |
| 125 | 113 |
| 126 const ExistingUserController* existing_user_controller() const { | 114 const ExistingUserController* existing_user_controller() const { |
| 127 return ExistingUserController::current_controller(); | 115 return ExistingUserController::current_controller(); |
| 128 } | 116 } |
| 129 | 117 |
| 130 void SetUpInProcessBrowserTestFixture() override { | 118 void SetUpInProcessBrowserTestFixture() override { |
| 131 SetUpSessionManager(); | 119 SetUpSessionManager(); |
| 132 | 120 |
| 133 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); | 121 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 134 | 122 |
| 135 mock_login_utils_ = new MockLoginUtils(); | |
| 136 LoginUtils::Set(mock_login_utils_); | |
| 137 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_)) | |
| 138 .Times(1); | |
| 139 | |
| 140 mock_login_display_host_.reset(new MockLoginDisplayHost()); | 123 mock_login_display_host_.reset(new MockLoginDisplayHost()); |
| 141 mock_login_display_ = new MockLoginDisplay(); | 124 mock_login_display_ = new MockLoginDisplay(); |
| 142 SetUpLoginDisplay(); | 125 SetUpLoginDisplay(); |
| 143 } | 126 } |
| 144 | 127 |
| 128 void TearDown() override { user_manager_enabler_.reset(); } | |
| 129 | |
| 145 virtual void SetUpSessionManager() { | 130 virtual void SetUpSessionManager() { |
| 146 } | 131 } |
| 147 | 132 |
| 148 virtual void SetUpLoginDisplay() { | 133 virtual void SetUpLoginDisplay() { |
| 149 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) | 134 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) |
| 150 .Times(1) | 135 .Times(1) |
| 151 .WillOnce(Return(mock_login_display_)); | 136 .WillOnce(Return(mock_login_display_)); |
| 152 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) | 137 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) |
| 153 .Times(1) | 138 .Times(1) |
| 154 .WillOnce(ReturnNull()); | 139 .WillOnce(ReturnNull()); |
| 155 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) | 140 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) |
| 156 .Times(1); | 141 .Times(1); |
| 157 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) | 142 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) |
| 158 .Times(1); | 143 .Times(1); |
| 159 } | 144 } |
| 160 | 145 |
| 161 void SetUpCommandLine(base::CommandLine* command_line) override { | 146 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 162 command_line->AppendSwitch(switches::kLoginManager); | 147 command_line->AppendSwitch(switches::kLoginManager); |
| 148 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | |
| 163 } | 149 } |
| 164 | 150 |
| 165 virtual void SetUpUserManager() { | 151 virtual void SetUpUserManager() { |
| 166 // Replace the UserManager singleton with a mock. | |
| 167 mock_user_manager_ = new MockUserManager; | |
| 168 user_manager_enabler_.reset( | 152 user_manager_enabler_.reset( |
| 169 new ScopedUserManagerEnabler(mock_user_manager_)); | 153 new ScopedUserManagerEnabler(new chromeos::FakeUserManager())); |
| 170 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername)) | 154 GetFakeUserManager()->AddUser(kUsername); |
| 171 .Times(AnyNumber()) | |
| 172 .WillRepeatedly(Return(true)); | |
| 173 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kNewUsername)) | |
| 174 .Times(AnyNumber()) | |
| 175 .WillRepeatedly(Return(false)); | |
| 176 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) | |
| 177 .Times(AnyNumber()) | |
| 178 .WillRepeatedly(Return(false)); | |
| 179 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsGuest()) | |
| 180 .Times(AnyNumber()) | |
| 181 .WillRepeatedly(Return(false)); | |
| 182 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsPublicAccount()) | |
| 183 .Times(AnyNumber()) | |
| 184 .WillRepeatedly(Return(false)); | |
| 185 EXPECT_CALL(*mock_user_manager_, IsSessionStarted()) | |
| 186 .Times(AnyNumber()) | |
| 187 .WillRepeatedly(Return(false)); | |
| 188 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) | |
| 189 .Times(AnyNumber()) | |
| 190 .WillRepeatedly(Return(false)); | |
| 191 EXPECT_CALL(*mock_user_manager_, Shutdown()) | |
| 192 .Times(1); | |
| 193 EXPECT_CALL(*mock_user_manager_, FindUser(_)) | |
| 194 .Times(AnyNumber()) | |
| 195 .WillRepeatedly(ReturnNull()); | |
| 196 } | 155 } |
| 197 | 156 |
| 198 void SetUpOnMainThread() override { | 157 void SetUpOnMainThread() override { |
| 199 testing_profile_.reset(new TestingProfile()); | |
| 200 SetUpUserManager(); | 158 SetUpUserManager(); |
| 201 existing_user_controller_.reset( | 159 existing_user_controller_.reset( |
| 202 new ExistingUserController(mock_login_display_host_.get())); | 160 new ExistingUserController(mock_login_display_host_.get())); |
| 203 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get()); | 161 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get()); |
| 204 existing_user_controller_->Init(user_manager::UserList()); | 162 existing_user_controller_->Init(user_manager::UserList()); |
| 205 profile_prepared_cb_ = | |
| 206 base::Bind(&ExistingUserController::OnProfilePrepared, | |
| 207 base::Unretained(existing_user_controller()), | |
| 208 testing_profile_.get(), | |
| 209 false); | |
| 210 } | 163 } |
| 211 | 164 |
| 212 void TearDownOnMainThread() override { | 165 void TearDownOnMainThread() override { |
| 213 // ExistingUserController must be deleted before the thread is cleaned up: | 166 // ExistingUserController must be deleted before the thread is cleaned up: |
| 214 // If there is an outstanding login attempt when ExistingUserController is | 167 // If there is an outstanding login attempt when ExistingUserController is |
| 215 // deleted, its LoginPerformer instance will be deleted, which in turn | 168 // deleted, its LoginPerformer instance will be deleted, which in turn |
| 216 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must | 169 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must |
| 217 // be deleted on the UI thread. | 170 // be deleted on the UI thread. |
| 218 existing_user_controller_.reset(); | 171 existing_user_controller_.reset(); |
| 219 DevicePolicyCrosBrowserTest::InProcessBrowserTest::TearDownOnMainThread(); | 172 DevicePolicyCrosBrowserTest::InProcessBrowserTest::TearDownOnMainThread(); |
| 220 testing_profile_.reset(NULL); | |
| 221 user_manager_enabler_.reset(); | 173 user_manager_enabler_.reset(); |
| 222 } | 174 } |
| 223 | 175 |
| 224 void ExpectLoginFailure() { | 176 void ExpectLoginFailure() { |
| 225 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 177 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 226 .Times(1); | 178 .Times(1); |
| 227 EXPECT_CALL(*mock_login_display_, | 179 EXPECT_CALL(*mock_login_display_, |
| 228 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, | 180 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, |
| 229 1, | 181 1, |
| 230 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT)) | 182 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT)) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 250 return existing_user_controller()->is_login_in_progress_; | 202 return existing_user_controller()->is_login_in_progress_; |
| 251 } | 203 } |
| 252 | 204 |
| 253 scoped_ptr<ExistingUserController> existing_user_controller_; | 205 scoped_ptr<ExistingUserController> existing_user_controller_; |
| 254 | 206 |
| 255 // |mock_login_display_| is owned by the ExistingUserController, which calls | 207 // |mock_login_display_| is owned by the ExistingUserController, which calls |
| 256 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. | 208 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. |
| 257 MockLoginDisplay* mock_login_display_; | 209 MockLoginDisplay* mock_login_display_; |
| 258 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; | 210 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; |
| 259 | 211 |
| 260 // Owned by LoginUtilsWrapper. | |
| 261 MockLoginUtils* mock_login_utils_; | |
| 262 | |
| 263 MockUserManager* mock_user_manager_; // Not owned. | |
| 264 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; | 212 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; |
| 265 | 213 |
| 266 scoped_ptr<TestingProfile> testing_profile_; | |
| 267 | |
| 268 // Mock URLFetcher. | 214 // Mock URLFetcher. |
| 269 MockURLFetcherFactory<SuccessFetcher> factory_; | 215 MockURLFetcherFactory<SuccessFetcher> factory_; |
| 270 | 216 |
| 271 base::Callback<void(void)> profile_prepared_cb_; | 217 private: |
| 218 chromeos::FakeUserManager* GetFakeUserManager() { | |
| 219 return static_cast<chromeos::FakeUserManager*>( | |
| 220 user_manager::UserManager::Get()); | |
| 221 } | |
| 272 | 222 |
| 273 private: | |
| 274 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 223 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
| 275 }; | 224 }; |
| 276 | 225 |
| 277 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 226 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
| 278 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 227 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 279 .Times(2); | 228 .Times(2); |
| 280 UserContext user_context(kUsername); | 229 UserContext user_context(kUsername); |
| 281 user_context.SetKey(Key(kPassword)); | 230 user_context.SetKey(Key(kPassword)); |
| 282 user_context.SetUserIDHash(kUsername); | 231 user_context.SetUserIDHash(kUsername); |
| 283 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 232 test::UserSessionManagerTestApi session_manager_test_api( |
| 284 .Times(1) | 233 UserSessionManager::GetInstance()); |
| 285 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); | 234 session_manager_test_api.InjectStubUserContext(user_context); |
| 286 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _)) | |
| 287 .Times(1) | |
| 288 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | |
| 289 &base::Callback<void(void)>::Run)); | |
| 290 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 235 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
| 291 .Times(1); | 236 .Times(1); |
| 292 EXPECT_CALL(*mock_login_display_host_, | 237 EXPECT_CALL(*mock_login_display_host_, |
| 293 StartWizard(WizardController::kTermsOfServiceScreenName)) | 238 StartWizard(WizardController::kTermsOfServiceScreenName)) |
| 294 .Times(0); | 239 .Times(0); |
| 295 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) | 240 |
| 296 .Times(AnyNumber()) | 241 content::WindowedNotificationObserver profile_prepared_observer( |
| 297 .WillRepeatedly(Return(false)); | 242 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 243 content::NotificationService::AllSources()); | |
| 298 existing_user_controller()->Login(user_context, SigninSpecifics()); | 244 existing_user_controller()->Login(user_context, SigninSpecifics()); |
| 245 | |
| 246 profile_prepared_observer.Wait(); | |
| 299 content::RunAllPendingInMessageLoop(); | 247 content::RunAllPendingInMessageLoop(); |
| 300 } | 248 } |
| 301 | 249 |
| 302 // Verifies that when the cros settings are untrusted, no new session can be | 250 // Verifies that when the cros settings are untrusted, no new session can be |
| 303 // started. | 251 // started. |
| 304 class ExistingUserControllerUntrustedTest : public ExistingUserControllerTest { | 252 class ExistingUserControllerUntrustedTest : public ExistingUserControllerTest { |
| 305 public: | 253 public: |
| 306 ExistingUserControllerUntrustedTest(); | 254 ExistingUserControllerUntrustedTest(); |
| 307 | 255 |
| 308 void SetUpInProcessBrowserTestFixture() override; | 256 void SetUpInProcessBrowserTestFixture() override; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 existing_user_controller()->Login(user_context, SigninSpecifics()); | 302 existing_user_controller()->Login(user_context, SigninSpecifics()); |
| 355 } | 303 } |
| 356 | 304 |
| 357 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 305 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
| 358 SupervisedUserCreationForbidden) { | 306 SupervisedUserCreationForbidden) { |
| 359 MockBaseScreenDelegate mock_base_screen_delegate; | 307 MockBaseScreenDelegate mock_base_screen_delegate; |
| 360 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; | 308 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; |
| 361 SupervisedUserCreationScreen supervised_user_creation_screen( | 309 SupervisedUserCreationScreen supervised_user_creation_screen( |
| 362 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); | 310 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); |
| 363 | 311 |
| 364 EXPECT_CALL(*mock_user_manager_, SetUserFlow(kUsername, _)) | |
| 365 .Times(1) | |
| 366 .WillOnce(WithArg<1>(Invoke(DeleteUserFlow))); | |
| 367 supervised_user_creation_screen.AuthenticateManager(kUsername, kPassword); | 312 supervised_user_creation_screen.AuthenticateManager(kUsername, kPassword); |
| 368 } | 313 } |
| 369 | 314 |
| 370 MATCHER_P(HasDetails, expected, "") { | 315 MATCHER_P(HasDetails, expected, "") { |
| 371 return expected == *content::Details<const std::string>(arg).ptr(); | 316 return expected == *content::Details<const std::string>(arg).ptr(); |
| 372 } | 317 } |
| 373 | 318 |
| 374 class ExistingUserControllerPublicSessionTest | 319 class ExistingUserControllerPublicSessionTest |
| 375 : public ExistingUserControllerTest { | 320 : public ExistingUserControllerTest { |
| 376 protected: | 321 protected: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 .WillRepeatedly(ReturnNull()); | 395 .WillRepeatedly(ReturnNull()); |
| 451 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) | 396 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) |
| 452 .Times(AnyNumber()); | 397 .Times(AnyNumber()); |
| 453 EXPECT_CALL(*mock_login_display_, Init(_, _, _, _)) | 398 EXPECT_CALL(*mock_login_display_, Init(_, _, _, _)) |
| 454 .Times(AnyNumber()); | 399 .Times(AnyNumber()); |
| 455 } | 400 } |
| 456 | 401 |
| 457 void SetUpUserManager() override {} | 402 void SetUpUserManager() override {} |
| 458 | 403 |
| 459 void ExpectSuccessfulLogin(const UserContext& user_context) { | 404 void ExpectSuccessfulLogin(const UserContext& user_context) { |
| 460 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 405 test::UserSessionManagerTestApi session_manager_test_api( |
| 461 .Times(AnyNumber()); | 406 UserSessionManager::GetInstance()); |
| 462 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 407 session_manager_test_api.InjectStubUserContext(user_context); |
| 463 .Times(1) | |
| 464 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); | |
| 465 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _)) | |
| 466 .Times(1) | |
| 467 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | |
| 468 &base::Callback<void(void)>::Run)); | |
| 469 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | |
| 470 .Times(1); | |
| 471 EXPECT_CALL(*mock_login_display_host_, | 408 EXPECT_CALL(*mock_login_display_host_, |
| 472 StartWizard(WizardController::kTermsOfServiceScreenName)) | 409 StartWizard(WizardController::kTermsOfServiceScreenName)) |
| 473 .Times(0); | 410 .Times(0); |
| 411 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(AnyNumber()); | |
| 412 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(AnyNumber()); | |
| 474 } | 413 } |
| 475 | 414 |
| 476 void SetAutoLoginPolicy(const std::string& username, int delay) { | 415 void SetAutoLoginPolicy(const std::string& username, int delay) { |
| 477 // Wait until ExistingUserController has finished auto-login | 416 // Wait until ExistingUserController has finished auto-login |
| 478 // configuration by observing the same settings that trigger | 417 // configuration by observing the same settings that trigger |
| 479 // ConfigurePublicSessionAutoLogin. | 418 // ConfigurePublicSessionAutoLogin. |
| 480 | 419 |
| 481 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 420 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
| 482 | 421 |
| 483 // If both settings have changed we need to wait for both to | 422 // If both settings have changed we need to wait for both to |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); | 491 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); |
| 553 ASSERT_TRUE(auto_login_timer()); | 492 ASSERT_TRUE(auto_login_timer()); |
| 554 EXPECT_TRUE(auto_login_timer()->IsRunning()); | 493 EXPECT_TRUE(auto_login_timer()->IsRunning()); |
| 555 | 494 |
| 556 // Unset the policy. | 495 // Unset the policy. |
| 557 SetAutoLoginPolicy("", 0); | 496 SetAutoLoginPolicy("", 0); |
| 558 EXPECT_EQ("", auto_login_username()); | 497 EXPECT_EQ("", auto_login_username()); |
| 559 EXPECT_EQ(0, auto_login_delay()); | 498 EXPECT_EQ(0, auto_login_delay()); |
| 560 ASSERT_TRUE(auto_login_timer()); | 499 ASSERT_TRUE(auto_login_timer()); |
| 561 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 500 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 501 | |
| 502 // This test is configured with the real user manager but empty user list | |
| 503 // initially. So network OOBE screen is initialized. | |
| 504 // Need to reset it manually so that we don't end up with CrosSettings | |
| 505 // observer that wasn't removed. | |
| 506 WizardController* controller = WizardController::default_controller(); | |
|
Dmitry Polukhin
2015/02/03 11:33:07
What do you think about moving this logic to test
Nikita (slow)
2015/02/03 13:12:26
Done.
| |
| 507 if (controller && controller->current_screen()) | |
| 508 controller->current_screen()->Hide(); | |
| 562 } | 509 } |
| 563 | 510 |
| 564 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 511 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 565 AutoLoginNoDelay) { | 512 AutoLoginNoDelay) { |
| 566 // Set up mocks to check login success. | 513 // Set up mocks to check login success. |
| 567 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 514 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
| 568 public_session_user_id_); | 515 public_session_user_id_); |
| 569 user_context.SetUserIDHash(user_context.GetUserID()); | 516 user_context.SetUserIDHash(user_context.GetUserID()); |
| 570 ExpectSuccessfulLogin(user_context); | 517 ExpectSuccessfulLogin(user_context); |
| 571 existing_user_controller()->OnSigninScreenReady(); | 518 existing_user_controller()->OnSigninScreenReady(); |
| 572 | 519 |
| 573 // Start auto-login and wait for login tasks to complete. | 520 // Start auto-login and wait for login tasks to complete. |
| 574 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); | 521 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); |
| 575 content::RunAllPendingInMessageLoop(); | 522 content::RunAllPendingInMessageLoop(); |
| 576 } | 523 } |
| 577 | 524 |
| 578 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 525 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 579 AutoLoginShortDelay) { | 526 AutoLoginShortDelay) { |
| 580 // Set up mocks to check login success. | 527 // Set up mocks to check login success. |
| 581 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 528 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
| 582 public_session_user_id_); | 529 public_session_user_id_); |
| 583 user_context.SetUserIDHash(user_context.GetUserID()); | 530 user_context.SetUserIDHash(user_context.GetUserID()); |
| 584 ExpectSuccessfulLogin(user_context); | 531 ExpectSuccessfulLogin(user_context); |
| 585 existing_user_controller()->OnSigninScreenReady(); | 532 existing_user_controller()->OnSigninScreenReady(); |
| 533 | |
| 534 content::WindowedNotificationObserver profile_prepared_observer( | |
| 535 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 536 content::NotificationService::AllSources()); | |
| 537 | |
| 586 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); | 538 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); |
| 587 ASSERT_TRUE(auto_login_timer()); | 539 ASSERT_TRUE(auto_login_timer()); |
| 588 // Don't assert that timer is running: with the short delay sometimes | 540 // Don't assert that timer is running: with the short delay sometimes |
| 589 // the trigger happens before the assert. We've already tested that | 541 // the trigger happens before the assert. We've already tested that |
| 590 // the timer starts when it should. | 542 // the timer starts when it should. |
| 591 | 543 |
| 592 // Wait for the timer to fire. | 544 // Wait for the timer to fire. |
| 593 base::RunLoop runner; | 545 base::RunLoop runner; |
| 594 base::OneShotTimer<base::RunLoop> timer; | 546 base::OneShotTimer<base::RunLoop> timer; |
| 595 timer.Start(FROM_HERE, | 547 timer.Start(FROM_HERE, |
| 596 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), | 548 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), |
| 597 runner.QuitClosure()); | 549 runner.QuitClosure()); |
| 598 runner.Run(); | 550 runner.Run(); |
| 599 | 551 |
| 552 profile_prepared_observer.Wait(); | |
| 553 | |
| 554 // This test is configured with the real user manager but empty user list | |
| 555 // initially. So network OOBE screen is initialized. | |
| 556 // Need to reset it manually so that we don't end up with CrosSettings | |
| 557 // observer that wasn't removed. | |
| 558 WizardController* controller = WizardController::default_controller(); | |
| 559 if (controller && controller->current_screen()) | |
| 560 controller->current_screen()->Hide(); | |
| 561 | |
| 600 // Wait for login tasks to complete. | 562 // Wait for login tasks to complete. |
| 601 content::RunAllPendingInMessageLoop(); | 563 content::RunAllPendingInMessageLoop(); |
| 602 } | 564 } |
| 603 | 565 |
| 604 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 566 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 605 LoginStopsAutoLogin) { | 567 LoginStopsAutoLogin) { |
| 606 // Set up mocks to check login success. | 568 // Set up mocks to check login success. |
| 607 UserContext user_context(kUsername); | 569 UserContext user_context(kUsername); |
| 608 user_context.SetKey(Key(kPassword)); | 570 user_context.SetKey(Key(kPassword)); |
| 609 user_context.SetUserIDHash(user_context.GetUserID()); | 571 user_context.SetUserIDHash(user_context.GetUserID()); |
| 610 ExpectSuccessfulLogin(user_context); | 572 ExpectSuccessfulLogin(user_context); |
| 611 | 573 |
| 612 existing_user_controller()->OnSigninScreenReady(); | 574 existing_user_controller()->OnSigninScreenReady(); |
| 613 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 575 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
| 614 EXPECT_TRUE(auto_login_timer()); | 576 EXPECT_TRUE(auto_login_timer()); |
| 615 | 577 |
| 578 content::WindowedNotificationObserver profile_prepared_observer( | |
| 579 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 580 content::NotificationService::AllSources()); | |
| 581 | |
| 616 // Log in and check that it stopped the timer. | 582 // Log in and check that it stopped the timer. |
| 617 existing_user_controller()->Login(user_context, SigninSpecifics()); | 583 existing_user_controller()->Login(user_context, SigninSpecifics()); |
| 618 EXPECT_TRUE(is_login_in_progress()); | 584 EXPECT_TRUE(is_login_in_progress()); |
| 619 ASSERT_TRUE(auto_login_timer()); | 585 ASSERT_TRUE(auto_login_timer()); |
| 620 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 586 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 621 | 587 |
| 588 profile_prepared_observer.Wait(); | |
| 589 | |
| 622 // Wait for login tasks to complete. | 590 // Wait for login tasks to complete. |
| 623 content::RunAllPendingInMessageLoop(); | 591 content::RunAllPendingInMessageLoop(); |
| 624 | 592 |
| 625 // Timer should still be stopped after login completes. | 593 // Timer should still be stopped after login completes. |
| 626 ASSERT_TRUE(auto_login_timer()); | 594 ASSERT_TRUE(auto_login_timer()); |
| 627 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 595 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 596 | |
| 597 // This test is configured with the real user manager but empty user list. | |
| 598 // When logging in this test we end up on user image screen. | |
| 599 WizardController* controller = WizardController::default_controller(); | |
| 600 if (controller && controller->current_screen()) | |
| 601 controller->current_screen()->Hide(); | |
| 628 } | 602 } |
| 629 | 603 |
| 630 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 604 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 631 GuestModeLoginStopsAutoLogin) { | 605 GuestModeLoginStopsAutoLogin) { |
| 632 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 606 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 633 .Times(2); | 607 .Times(2); |
| 634 UserContext user_context(kUsername); | 608 UserContext user_context(kUsername); |
| 635 user_context.SetKey(Key(kPassword)); | 609 user_context.SetKey(Key(kPassword)); |
| 636 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 610 test::UserSessionManagerTestApi session_manager_test_api( |
| 637 .Times(1) | 611 UserSessionManager::GetInstance()); |
| 638 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); | 612 session_manager_test_api.InjectStubUserContext(user_context); |
| 639 | 613 |
| 640 existing_user_controller()->OnSigninScreenReady(); | 614 existing_user_controller()->OnSigninScreenReady(); |
| 641 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 615 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
| 642 EXPECT_TRUE(auto_login_timer()); | 616 EXPECT_TRUE(auto_login_timer()); |
| 643 | 617 |
| 644 // Login and check that it stopped the timer. | 618 // Login and check that it stopped the timer. |
| 645 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, | 619 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, |
| 646 std::string()), | 620 std::string()), |
| 647 SigninSpecifics()); | 621 SigninSpecifics()); |
| 648 EXPECT_TRUE(is_login_in_progress()); | 622 EXPECT_TRUE(is_login_in_progress()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 664 user_context.SetKey(Key(kPassword)); | 638 user_context.SetKey(Key(kPassword)); |
| 665 user_context.SetUserIDHash(user_context.GetUserID()); | 639 user_context.SetUserIDHash(user_context.GetUserID()); |
| 666 ExpectSuccessfulLogin(user_context); | 640 ExpectSuccessfulLogin(user_context); |
| 667 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 641 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
| 668 .Times(1); | 642 .Times(1); |
| 669 | 643 |
| 670 existing_user_controller()->OnSigninScreenReady(); | 644 existing_user_controller()->OnSigninScreenReady(); |
| 671 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 645 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
| 672 EXPECT_TRUE(auto_login_timer()); | 646 EXPECT_TRUE(auto_login_timer()); |
| 673 | 647 |
| 648 content::WindowedNotificationObserver profile_prepared_observer( | |
| 649 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 650 content::NotificationService::AllSources()); | |
| 651 | |
| 674 // Check that login completes and stops the timer. | 652 // Check that login completes and stops the timer. |
| 675 existing_user_controller()->CompleteLogin(user_context); | 653 existing_user_controller()->CompleteLogin(user_context); |
| 676 ASSERT_TRUE(auto_login_timer()); | 654 ASSERT_TRUE(auto_login_timer()); |
| 677 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 655 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 678 | 656 |
| 657 profile_prepared_observer.Wait(); | |
| 658 | |
| 679 // Wait for login tasks to complete. | 659 // Wait for login tasks to complete. |
| 680 content::RunAllPendingInMessageLoop(); | 660 content::RunAllPendingInMessageLoop(); |
| 681 | 661 |
| 682 // Timer should still be stopped after login completes. | 662 // Timer should still be stopped after login completes. |
| 683 ASSERT_TRUE(auto_login_timer()); | 663 ASSERT_TRUE(auto_login_timer()); |
| 684 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 664 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 665 | |
| 666 // This test is configured with the real user manager but empty user list. | |
| 667 // When logging in this test we end up on user image screen. | |
| 668 WizardController* controller = WizardController::default_controller(); | |
| 669 if (controller && controller->current_screen()) | |
| 670 controller->current_screen()->Hide(); | |
| 685 } | 671 } |
| 686 | 672 |
| 687 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 673 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 688 PublicSessionLoginStopsAutoLogin) { | 674 PublicSessionLoginStopsAutoLogin) { |
| 689 // Set up mocks to check login success. | 675 // Set up mocks to check login success. |
| 690 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 676 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
| 691 public_session_user_id_); | 677 public_session_user_id_); |
| 692 user_context.SetUserIDHash(user_context.GetUserID()); | 678 user_context.SetUserIDHash(user_context.GetUserID()); |
| 693 ExpectSuccessfulLogin(user_context); | 679 ExpectSuccessfulLogin(user_context); |
| 694 existing_user_controller()->OnSigninScreenReady(); | 680 existing_user_controller()->OnSigninScreenReady(); |
| 695 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 681 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
| 696 EXPECT_TRUE(auto_login_timer()); | 682 EXPECT_TRUE(auto_login_timer()); |
| 697 | 683 |
| 684 content::WindowedNotificationObserver profile_prepared_observer( | |
| 685 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 686 content::NotificationService::AllSources()); | |
| 687 | |
| 698 // Login and check that it stopped the timer. | 688 // Login and check that it stopped the timer. |
| 699 existing_user_controller()->Login( | 689 existing_user_controller()->Login( |
| 700 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 690 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
| 701 public_session_user_id_), | 691 public_session_user_id_), |
| 702 SigninSpecifics()); | 692 SigninSpecifics()); |
| 703 | 693 |
| 704 EXPECT_TRUE(is_login_in_progress()); | 694 EXPECT_TRUE(is_login_in_progress()); |
| 705 ASSERT_TRUE(auto_login_timer()); | 695 ASSERT_TRUE(auto_login_timer()); |
| 706 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 696 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 707 | 697 |
| 698 profile_prepared_observer.Wait(); | |
| 699 | |
| 708 // Wait for login tasks to complete. | 700 // Wait for login tasks to complete. |
| 709 content::RunAllPendingInMessageLoop(); | 701 content::RunAllPendingInMessageLoop(); |
| 710 | 702 |
| 711 // Timer should still be stopped after login completes. | 703 // Timer should still be stopped after login completes. |
| 712 ASSERT_TRUE(auto_login_timer()); | 704 ASSERT_TRUE(auto_login_timer()); |
| 713 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 705 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 714 } | 706 } |
| 715 | 707 |
| 716 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 708 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 717 LoginForbiddenWhenUntrusted) { | 709 LoginForbiddenWhenUntrusted) { |
| 718 // Make cros settings untrusted. | 710 // Make cros settings untrusted. |
| 719 MakeCrosSettingsPermanentlyUntrusted(); | 711 MakeCrosSettingsPermanentlyUntrusted(); |
| 720 | 712 |
| 721 // Check that the attempt to start a public session fails with an error. | 713 // Check that the attempt to start a public session fails with an error. |
| 722 ExpectLoginFailure(); | 714 ExpectLoginFailure(); |
| 723 UserContext user_context(kUsername); | 715 UserContext user_context(kUsername); |
| 724 user_context.SetKey(Key(kPassword)); | 716 user_context.SetKey(Key(kPassword)); |
| 725 user_context.SetUserIDHash(user_context.GetUserID()); | 717 user_context.SetUserIDHash(user_context.GetUserID()); |
| 726 existing_user_controller()->Login(user_context, SigninSpecifics()); | 718 existing_user_controller()->Login(user_context, SigninSpecifics()); |
| 719 | |
| 720 // This test is configured with the real user manager but empty user list | |
| 721 // initially. So network OOBE screen is initialized. | |
| 722 // Need to reset it manually so that we don't end up with CrosSettings | |
| 723 // observer that wasn't removed. | |
| 724 WizardController* controller = WizardController::default_controller(); | |
| 725 if (controller && controller->current_screen()) | |
| 726 controller->current_screen()->Hide(); | |
| 727 } | 727 } |
| 728 | 728 |
| 729 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 729 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 730 NoAutoLoginWhenUntrusted) { | 730 NoAutoLoginWhenUntrusted) { |
| 731 // Start the public session timer. | 731 // Start the public session timer. |
| 732 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 732 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
| 733 existing_user_controller()->OnSigninScreenReady(); | 733 existing_user_controller()->OnSigninScreenReady(); |
| 734 EXPECT_TRUE(auto_login_timer()); | 734 EXPECT_TRUE(auto_login_timer()); |
| 735 | 735 |
| 736 // Make cros settings untrusted. | 736 // Make cros settings untrusted. |
| 737 MakeCrosSettingsPermanentlyUntrusted(); | 737 MakeCrosSettingsPermanentlyUntrusted(); |
| 738 | 738 |
| 739 // Check that when the timer fires, auto-login fails with an error. | 739 // Check that when the timer fires, auto-login fails with an error. |
| 740 ExpectLoginFailure(); | 740 ExpectLoginFailure(); |
| 741 FireAutoLogin(); | 741 FireAutoLogin(); |
| 742 | |
| 743 // This test is configured with the real user manager but empty user list | |
| 744 // initially. So network OOBE screen is initialized. | |
| 745 // Need to reset it manually so that we don't end up with CrosSettings | |
| 746 // observer that wasn't removed. | |
| 747 WizardController* controller = WizardController::default_controller(); | |
| 748 if (controller && controller->current_screen()) | |
| 749 controller->current_screen()->Hide(); | |
| 742 } | 750 } |
| 743 | 751 |
| 744 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 752 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 745 PRE_TestLoadingPublicUsersFromLocalState) { | 753 PRE_TestLoadingPublicUsersFromLocalState) { |
| 746 // First run propagates public accounts and stores them in Local State. | 754 // First run propagates public accounts and stores them in Local State. |
| 747 } | 755 } |
| 748 | 756 |
| 749 // See http://crbug.com/393704; flaky. | 757 // See http://crbug.com/393704; flaky. |
| 750 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 758 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 751 DISABLED_TestLoadingPublicUsersFromLocalState) { | 759 DISABLED_TestLoadingPublicUsersFromLocalState) { |
| 752 // Second run loads list of public accounts from Local State. | 760 // Second run loads list of public accounts from Local State. |
| 753 } | 761 } |
| 754 | 762 |
| 755 } // namespace chromeos | 763 } // namespace chromeos |
| OLD | NEW |