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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/chromeos/login/ui/mock_login_display_host.h" | 22 #include "chrome/browser/chromeos/login/ui/mock_login_display_host.h" |
23 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 23 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
24 #include "chrome/browser/chromeos/login/users/user_manager.h" | 24 #include "chrome/browser/chromeos/login/users/user_manager.h" |
25 #include "chrome/browser/chromeos/login/wizard_controller.h" | 25 #include "chrome/browser/chromeos/login/wizard_controller.h" |
26 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 26 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
27 #include "chrome/browser/chromeos/policy/device_local_account.h" | 27 #include "chrome/browser/chromeos/policy/device_local_account.h" |
28 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 28 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
29 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 29 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
30 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 30 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
31 #include "chrome/browser/chromeos/settings/cros_settings.h" | 31 #include "chrome/browser/chromeos/settings/cros_settings.h" |
32 #include "chrome/common/chrome_switches.h" | |
33 #include "chrome/test/base/testing_browser_process.h" | 32 #include "chrome/test/base/testing_browser_process.h" |
34 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
35 #include "chrome/test/base/ui_test_utils.h" | 34 #include "chrome/test/base/ui_test_utils.h" |
36 #include "chromeos/chromeos_switches.h" | 35 #include "chromeos/chromeos_switches.h" |
37 #include "chromeos/dbus/fake_session_manager_client.h" | 36 #include "chromeos/dbus/fake_session_manager_client.h" |
38 #include "chromeos/settings/cros_settings_names.h" | 37 #include "chromeos/settings/cros_settings_names.h" |
39 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 38 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
40 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 39 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
41 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 40 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
42 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 41 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
(...skipping 30 matching lines...) Expand all Loading... |
73 const int kAutoLoginShortDelay = 1; | 72 const int kAutoLoginShortDelay = 1; |
74 const int kAutoLoginLongDelay = 10000; | 73 const int kAutoLoginLongDelay = 10000; |
75 | 74 |
76 | 75 |
77 ACTION_P2(CreateAuthenticator, username, password) { | 76 ACTION_P2(CreateAuthenticator, username, password) { |
78 return new MockAuthenticator(arg0, username, password); | 77 return new MockAuthenticator(arg0, username, password); |
79 } | 78 } |
80 | 79 |
81 } // namespace | 80 } // namespace |
82 | 81 |
83 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest, | 82 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { |
84 public testing::WithParamInterface<bool> { | |
85 protected: | 83 protected: |
86 ExistingUserControllerTest() | 84 ExistingUserControllerTest() |
87 : mock_login_display_(NULL), mock_user_manager_(NULL) {} | 85 : mock_login_display_(NULL), mock_user_manager_(NULL) {} |
88 | 86 |
89 ExistingUserController* existing_user_controller() { | 87 ExistingUserController* existing_user_controller() { |
90 return ExistingUserController::current_controller(); | 88 return ExistingUserController::current_controller(); |
91 } | 89 } |
92 | 90 |
93 const ExistingUserController* existing_user_controller() const { | 91 const ExistingUserController* existing_user_controller() const { |
94 return ExistingUserController::current_controller(); | 92 return ExistingUserController::current_controller(); |
(...skipping 25 matching lines...) Expand all Loading... |
120 .Times(1) | 118 .Times(1) |
121 .WillOnce(ReturnNull()); | 119 .WillOnce(ReturnNull()); |
122 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) | 120 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) |
123 .Times(1); | 121 .Times(1); |
124 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) | 122 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) |
125 .Times(1); | 123 .Times(1); |
126 } | 124 } |
127 | 125 |
128 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 126 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
129 command_line->AppendSwitch(switches::kLoginManager); | 127 command_line->AppendSwitch(switches::kLoginManager); |
130 if (GetParam()) | |
131 command_line->AppendSwitch(::switches::kMultiProfiles); | |
132 } | 128 } |
133 | 129 |
134 virtual void SetUpUserManager() { | 130 virtual void SetUpUserManager() { |
135 // Replace the UserManager singleton with a mock. | 131 // Replace the UserManager singleton with a mock. |
136 mock_user_manager_ = new MockUserManager; | 132 mock_user_manager_ = new MockUserManager; |
137 user_manager_enabler_.reset( | 133 user_manager_enabler_.reset( |
138 new ScopedUserManagerEnabler(mock_user_manager_)); | 134 new ScopedUserManagerEnabler(mock_user_manager_)); |
139 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername)) | 135 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername)) |
140 .Times(AnyNumber()) | 136 .Times(AnyNumber()) |
141 .WillRepeatedly(Return(true)); | 137 .WillRepeatedly(Return(true)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 222 |
227 // Mock URLFetcher. | 223 // Mock URLFetcher. |
228 MockURLFetcherFactory<SuccessFetcher> factory_; | 224 MockURLFetcherFactory<SuccessFetcher> factory_; |
229 | 225 |
230 base::Callback<void(void)> profile_prepared_cb_; | 226 base::Callback<void(void)> profile_prepared_cb_; |
231 | 227 |
232 private: | 228 private: |
233 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 229 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
234 }; | 230 }; |
235 | 231 |
236 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, ExistingUserLogin) { | 232 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
237 // This is disabled twice: once right after signin but before checking for | 233 // This is disabled twice: once right after signin but before checking for |
238 // auto-enrollment, and again after doing an ownership status check. | 234 // auto-enrollment, and again after doing an ownership status check. |
239 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 235 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
240 .Times(2); | 236 .Times(2); |
241 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 237 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
242 .Times(1) | 238 .Times(1) |
243 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); | 239 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); |
244 EXPECT_CALL(*mock_login_utils_, | 240 EXPECT_CALL(*mock_login_utils_, |
245 PrepareProfile(UserContext(kUsername, kPassword, "", kUsername), | 241 PrepareProfile(UserContext(kUsername, kPassword, "", kUsername), |
246 _, _, _, _)) | 242 _, _, _, _)) |
(...skipping 13 matching lines...) Expand all Loading... |
260 EXPECT_CALL(*mock_login_display_host_, | 256 EXPECT_CALL(*mock_login_display_host_, |
261 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL)) | 257 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL)) |
262 .Times(0); | 258 .Times(0); |
263 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) | 259 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) |
264 .Times(AnyNumber()) | 260 .Times(AnyNumber()) |
265 .WillRepeatedly(Return(false)); | 261 .WillRepeatedly(Return(false)); |
266 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); | 262 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); |
267 content::RunAllPendingInMessageLoop(); | 263 content::RunAllPendingInMessageLoop(); |
268 } | 264 } |
269 | 265 |
270 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, AutoEnrollAfterSignIn) { | 266 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { |
271 EXPECT_CALL(*mock_login_display_host_, | 267 EXPECT_CALL(*mock_login_display_host_, |
272 StartWizardPtr(WizardController::kEnrollmentScreenName, | 268 StartWizardPtr(WizardController::kEnrollmentScreenName, |
273 _)) | 269 _)) |
274 .Times(1); | 270 .Times(1); |
275 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 271 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
276 .Times(1); | 272 .Times(1); |
277 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 273 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
278 .Times(1); | 274 .Times(1); |
279 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) | 275 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) |
280 .Times(AnyNumber()) | 276 .Times(AnyNumber()) |
281 .WillRepeatedly(Return(false)); | 277 .WillRepeatedly(Return(false)); |
282 // The order of these expected calls matters: the UI if first disabled | 278 // The order of these expected calls matters: the UI if first disabled |
283 // during the login sequence, and is enabled again for the enrollment screen. | 279 // during the login sequence, and is enabled again for the enrollment screen. |
284 Sequence uiEnabledSequence; | 280 Sequence uiEnabledSequence; |
285 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 281 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
286 .Times(1) | 282 .Times(1) |
287 .InSequence(uiEnabledSequence); | 283 .InSequence(uiEnabledSequence); |
288 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 284 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
289 .Times(1) | 285 .Times(1) |
290 .InSequence(uiEnabledSequence); | 286 .InSequence(uiEnabledSequence); |
291 existing_user_controller()->DoAutoEnrollment(); | 287 existing_user_controller()->DoAutoEnrollment(); |
292 existing_user_controller()->CompleteLogin( | 288 existing_user_controller()->CompleteLogin( |
293 UserContext(kUsername, kPassword, "")); | 289 UserContext(kUsername, kPassword, "")); |
294 content::RunAllPendingInMessageLoop(); | 290 content::RunAllPendingInMessageLoop(); |
295 } | 291 } |
296 | 292 |
297 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, | 293 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, |
298 NewUserDontAutoEnrollAfterSignIn) { | 294 NewUserDontAutoEnrollAfterSignIn) { |
299 EXPECT_CALL(*mock_login_display_host_, | 295 EXPECT_CALL(*mock_login_display_host_, |
300 StartWizardPtr(WizardController::kEnrollmentScreenName, | 296 StartWizardPtr(WizardController::kEnrollmentScreenName, |
301 _)) | 297 _)) |
302 .Times(0); | 298 .Times(0); |
303 EXPECT_CALL(*mock_login_display_host_, | 299 EXPECT_CALL(*mock_login_display_host_, |
304 StartWizardPtr(WizardController::kTermsOfServiceScreenName, | 300 StartWizardPtr(WizardController::kTermsOfServiceScreenName, |
305 NULL)) | 301 NULL)) |
306 .Times(1); | 302 .Times(1); |
307 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 303 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 void FireAutoLogin() { | 513 void FireAutoLogin() { |
518 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); | 514 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); |
519 } | 515 } |
520 | 516 |
521 const std::string public_session_user_id_; | 517 const std::string public_session_user_id_; |
522 | 518 |
523 private: | 519 private: |
524 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); | 520 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); |
525 }; | 521 }; |
526 | 522 |
527 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 523 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
528 ConfigureAutoLoginUsingPolicy) { | 524 ConfigureAutoLoginUsingPolicy) { |
529 existing_user_controller()->OnSigninScreenReady(); | 525 existing_user_controller()->OnSigninScreenReady(); |
530 EXPECT_EQ("", auto_login_username()); | 526 EXPECT_EQ("", auto_login_username()); |
531 EXPECT_EQ(0, auto_login_delay()); | 527 EXPECT_EQ(0, auto_login_delay()); |
532 EXPECT_FALSE(auto_login_timer()); | 528 EXPECT_FALSE(auto_login_timer()); |
533 | 529 |
534 // Set the policy. | 530 // Set the policy. |
535 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 531 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
536 EXPECT_EQ(public_session_user_id_, auto_login_username()); | 532 EXPECT_EQ(public_session_user_id_, auto_login_username()); |
537 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); | 533 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); |
538 ASSERT_TRUE(auto_login_timer()); | 534 ASSERT_TRUE(auto_login_timer()); |
539 EXPECT_TRUE(auto_login_timer()->IsRunning()); | 535 EXPECT_TRUE(auto_login_timer()->IsRunning()); |
540 | 536 |
541 // Unset the policy. | 537 // Unset the policy. |
542 SetAutoLoginPolicy("", 0); | 538 SetAutoLoginPolicy("", 0); |
543 EXPECT_EQ("", auto_login_username()); | 539 EXPECT_EQ("", auto_login_username()); |
544 EXPECT_EQ(0, auto_login_delay()); | 540 EXPECT_EQ(0, auto_login_delay()); |
545 ASSERT_TRUE(auto_login_timer()); | 541 ASSERT_TRUE(auto_login_timer()); |
546 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 542 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
547 } | 543 } |
548 | 544 |
549 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 545 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
550 AutoLoginNoDelay) { | 546 AutoLoginNoDelay) { |
551 // Set up mocks to check login success. | 547 // Set up mocks to check login success. |
552 ExpectSuccessfulLogin(public_session_user_id_, ""); | 548 ExpectSuccessfulLogin(public_session_user_id_, ""); |
553 existing_user_controller()->OnSigninScreenReady(); | 549 existing_user_controller()->OnSigninScreenReady(); |
554 | 550 |
555 // Start auto-login and wait for login tasks to complete. | 551 // Start auto-login and wait for login tasks to complete. |
556 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); | 552 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); |
557 content::RunAllPendingInMessageLoop(); | 553 content::RunAllPendingInMessageLoop(); |
558 } | 554 } |
559 | 555 |
560 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 556 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
561 AutoLoginShortDelay) { | 557 AutoLoginShortDelay) { |
562 // Set up mocks to check login success. | 558 // Set up mocks to check login success. |
563 ExpectSuccessfulLogin(public_session_user_id_, ""); | 559 ExpectSuccessfulLogin(public_session_user_id_, ""); |
564 existing_user_controller()->OnSigninScreenReady(); | 560 existing_user_controller()->OnSigninScreenReady(); |
565 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); | 561 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); |
566 ASSERT_TRUE(auto_login_timer()); | 562 ASSERT_TRUE(auto_login_timer()); |
567 // Don't assert that timer is running: with the short delay sometimes | 563 // Don't assert that timer is running: with the short delay sometimes |
568 // the trigger happens before the assert. We've already tested that | 564 // the trigger happens before the assert. We've already tested that |
569 // the timer starts when it should. | 565 // the timer starts when it should. |
570 | 566 |
571 // Wait for the timer to fire. | 567 // Wait for the timer to fire. |
572 base::RunLoop runner; | 568 base::RunLoop runner; |
573 base::OneShotTimer<base::RunLoop> timer; | 569 base::OneShotTimer<base::RunLoop> timer; |
574 timer.Start(FROM_HERE, | 570 timer.Start(FROM_HERE, |
575 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), | 571 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), |
576 runner.QuitClosure()); | 572 runner.QuitClosure()); |
577 runner.Run(); | 573 runner.Run(); |
578 | 574 |
579 // Wait for login tasks to complete. | 575 // Wait for login tasks to complete. |
580 content::RunAllPendingInMessageLoop(); | 576 content::RunAllPendingInMessageLoop(); |
581 } | 577 } |
582 | 578 |
583 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 579 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
584 LoginStopsAutoLogin) { | 580 LoginStopsAutoLogin) { |
585 // Set up mocks to check login success. | 581 // Set up mocks to check login success. |
586 ExpectSuccessfulLogin(kUsername, kPassword); | 582 ExpectSuccessfulLogin(kUsername, kPassword); |
587 | 583 |
588 existing_user_controller()->OnSigninScreenReady(); | 584 existing_user_controller()->OnSigninScreenReady(); |
589 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 585 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
590 ASSERT_TRUE(auto_login_timer()); | 586 ASSERT_TRUE(auto_login_timer()); |
591 | 587 |
592 // Login and check that it stopped the timer. | 588 // Login and check that it stopped the timer. |
593 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); | 589 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); |
594 EXPECT_TRUE(is_login_in_progress()); | 590 EXPECT_TRUE(is_login_in_progress()); |
595 ASSERT_TRUE(auto_login_timer()); | 591 ASSERT_TRUE(auto_login_timer()); |
596 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 592 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
597 | 593 |
598 // Wait for login tasks to complete. | 594 // Wait for login tasks to complete. |
599 content::RunAllPendingInMessageLoop(); | 595 content::RunAllPendingInMessageLoop(); |
600 | 596 |
601 // Timer should still be stopped after login completes. | 597 // Timer should still be stopped after login completes. |
602 ASSERT_TRUE(auto_login_timer()); | 598 ASSERT_TRUE(auto_login_timer()); |
603 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 599 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
604 } | 600 } |
605 | 601 |
606 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 602 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
607 GuestModeLoginStopsAutoLogin) { | 603 GuestModeLoginStopsAutoLogin) { |
608 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 604 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
609 .Times(1); | 605 .Times(1); |
610 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 606 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
611 .Times(1) | 607 .Times(1) |
612 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); | 608 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); |
613 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_)) | 609 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_)) |
614 .Times(1); | 610 .Times(1); |
615 | 611 |
616 existing_user_controller()->OnSigninScreenReady(); | 612 existing_user_controller()->OnSigninScreenReady(); |
617 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 613 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
618 ASSERT_TRUE(auto_login_timer()); | 614 ASSERT_TRUE(auto_login_timer()); |
619 | 615 |
620 // Login and check that it stopped the timer. | 616 // Login and check that it stopped the timer. |
621 existing_user_controller()->LoginAsGuest(); | 617 existing_user_controller()->LoginAsGuest(); |
622 EXPECT_TRUE(is_login_in_progress()); | 618 EXPECT_TRUE(is_login_in_progress()); |
623 ASSERT_TRUE(auto_login_timer()); | 619 ASSERT_TRUE(auto_login_timer()); |
624 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 620 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
625 | 621 |
626 // Wait for login tasks to complete. | 622 // Wait for login tasks to complete. |
627 content::RunAllPendingInMessageLoop(); | 623 content::RunAllPendingInMessageLoop(); |
628 | 624 |
629 // Timer should still be stopped after login completes. | 625 // Timer should still be stopped after login completes. |
630 ASSERT_TRUE(auto_login_timer()); | 626 ASSERT_TRUE(auto_login_timer()); |
631 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 627 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
632 } | 628 } |
633 | 629 |
634 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 630 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
635 CompleteLoginStopsAutoLogin) { | 631 CompleteLoginStopsAutoLogin) { |
636 // Set up mocks to check login success. | 632 // Set up mocks to check login success. |
637 ExpectSuccessfulLogin(kUsername, kPassword); | 633 ExpectSuccessfulLogin(kUsername, kPassword); |
638 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 634 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
639 .Times(1); | 635 .Times(1); |
640 | 636 |
641 existing_user_controller()->OnSigninScreenReady(); | 637 existing_user_controller()->OnSigninScreenReady(); |
642 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 638 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
643 ASSERT_TRUE(auto_login_timer()); | 639 ASSERT_TRUE(auto_login_timer()); |
644 | 640 |
645 // Check that login completes and stops the timer. | 641 // Check that login completes and stops the timer. |
646 existing_user_controller()->CompleteLogin( | 642 existing_user_controller()->CompleteLogin( |
647 UserContext(kUsername, kPassword, "")); | 643 UserContext(kUsername, kPassword, "")); |
648 ASSERT_TRUE(auto_login_timer()); | 644 ASSERT_TRUE(auto_login_timer()); |
649 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 645 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
650 | 646 |
651 // Wait for login tasks to complete. | 647 // Wait for login tasks to complete. |
652 content::RunAllPendingInMessageLoop(); | 648 content::RunAllPendingInMessageLoop(); |
653 | 649 |
654 // Timer should still be stopped after login completes. | 650 // Timer should still be stopped after login completes. |
655 ASSERT_TRUE(auto_login_timer()); | 651 ASSERT_TRUE(auto_login_timer()); |
656 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 652 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
657 } | 653 } |
658 | 654 |
659 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 655 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
660 PublicSessionLoginStopsAutoLogin) { | 656 PublicSessionLoginStopsAutoLogin) { |
661 // Set up mocks to check login success. | 657 // Set up mocks to check login success. |
662 ExpectSuccessfulLogin(public_session_user_id_, ""); | 658 ExpectSuccessfulLogin(public_session_user_id_, ""); |
663 existing_user_controller()->OnSigninScreenReady(); | 659 existing_user_controller()->OnSigninScreenReady(); |
664 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 660 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
665 ASSERT_TRUE(auto_login_timer()); | 661 ASSERT_TRUE(auto_login_timer()); |
666 | 662 |
667 // Login and check that it stopped the timer. | 663 // Login and check that it stopped the timer. |
668 existing_user_controller()->LoginAsPublicAccount(public_session_user_id_); | 664 existing_user_controller()->LoginAsPublicAccount(public_session_user_id_); |
669 EXPECT_TRUE(is_login_in_progress()); | 665 EXPECT_TRUE(is_login_in_progress()); |
670 ASSERT_TRUE(auto_login_timer()); | 666 ASSERT_TRUE(auto_login_timer()); |
671 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 667 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
672 | 668 |
673 // Wait for login tasks to complete. | 669 // Wait for login tasks to complete. |
674 content::RunAllPendingInMessageLoop(); | 670 content::RunAllPendingInMessageLoop(); |
675 | 671 |
676 // Timer should still be stopped after login completes. | 672 // Timer should still be stopped after login completes. |
677 ASSERT_TRUE(auto_login_timer()); | 673 ASSERT_TRUE(auto_login_timer()); |
678 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 674 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
679 } | 675 } |
680 | 676 |
681 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 677 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
682 PRE_TestLoadingPublicUsersFromLocalState) { | 678 PRE_TestLoadingPublicUsersFromLocalState) { |
683 // First run propagates public accounts and stores them in Local State. | 679 // First run propagates public accounts and stores them in Local State. |
684 } | 680 } |
685 | 681 |
686 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, | 682 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
687 TestLoadingPublicUsersFromLocalState) { | 683 TestLoadingPublicUsersFromLocalState) { |
688 // Second run loads list of public accounts from Local State. | 684 // Second run loads list of public accounts from Local State. |
689 } | 685 } |
690 | 686 |
691 INSTANTIATE_TEST_CASE_P(ExistingUserControllerTestInstantiation, | |
692 ExistingUserControllerTest, | |
693 testing::Bool()); | |
694 | |
695 INSTANTIATE_TEST_CASE_P(ExistingUserControllerPublicSessionTestInstantiation, | |
696 ExistingUserControllerPublicSessionTest, | |
697 testing::Bool()); | |
698 | |
699 } // namespace chromeos | 687 } // namespace chromeos |
OLD | NEW |