| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 private: | 123 private: |
| 124 int type_; | 124 int type_; |
| 125 ConditionTestCallback callback_; | 125 ConditionTestCallback callback_; |
| 126 base::RunLoop run_loop_; | 126 base::RunLoop run_loop_; |
| 127 | 127 |
| 128 DISALLOW_COPY_AND_ASSIGN(NotificationWatcher); | 128 DISALLOW_COPY_AND_ASSIGN(NotificationWatcher); |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 } // namespace | 131 } // namespace |
| 132 | 132 |
| 133 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { | 133 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest, |
| 134 public testing::WithParamInterface<bool> { |
| 134 protected: | 135 protected: |
| 135 ExistingUserControllerTest() | 136 ExistingUserControllerTest() |
| 136 : mock_network_library_(NULL), | 137 : mock_network_library_(NULL), |
| 137 mock_login_display_(NULL), | 138 mock_login_display_(NULL), |
| 138 mock_user_manager_(NULL), | 139 mock_user_manager_(NULL), |
| 139 testing_profile_(NULL) { | 140 testing_profile_(NULL) { |
| 140 } | 141 } |
| 141 | 142 |
| 142 ExistingUserController* existing_user_controller() { | 143 ExistingUserController* existing_user_controller() { |
| 143 return ExistingUserController::current_controller(); | 144 return ExistingUserController::current_controller(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 .Times(1) | 186 .Times(1) |
| 186 .WillOnce(ReturnNull()); | 187 .WillOnce(ReturnNull()); |
| 187 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) | 188 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) |
| 188 .Times(1); | 189 .Times(1); |
| 189 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) | 190 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) |
| 190 .Times(1); | 191 .Times(1); |
| 191 } | 192 } |
| 192 | 193 |
| 193 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 194 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 194 command_line->AppendSwitch(switches::kLoginManager); | 195 command_line->AppendSwitch(switches::kLoginManager); |
| 196 if (GetParam()) |
| 197 command_line->AppendSwitch(::switches::kMultiProfiles); |
| 195 } | 198 } |
| 196 | 199 |
| 197 virtual void SetUpUserManager() { | 200 virtual void SetUpUserManager() { |
| 198 // Replace the UserManager singleton with a mock. | 201 // Replace the UserManager singleton with a mock. |
| 199 mock_user_manager_ = new MockUserManager; | 202 mock_user_manager_ = new MockUserManager; |
| 200 user_manager_enabler_.reset( | 203 user_manager_enabler_.reset( |
| 201 new ScopedUserManagerEnabler(mock_user_manager_)); | 204 new ScopedUserManagerEnabler(mock_user_manager_)); |
| 202 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername)) | 205 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername)) |
| 203 .Times(AnyNumber()) | 206 .Times(AnyNumber()) |
| 204 .WillRepeatedly(Return(true)); | 207 .WillRepeatedly(Return(true)); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 292 |
| 290 // Mock URLFetcher. | 293 // Mock URLFetcher. |
| 291 MockURLFetcherFactory<SuccessFetcher> factory_; | 294 MockURLFetcherFactory<SuccessFetcher> factory_; |
| 292 | 295 |
| 293 base::Callback<void(void)> profile_prepared_cb_; | 296 base::Callback<void(void)> profile_prepared_cb_; |
| 294 | 297 |
| 295 private: | 298 private: |
| 296 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 299 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
| 297 }; | 300 }; |
| 298 | 301 |
| 299 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 302 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, ExistingUserLogin) { |
| 300 // This is disabled twice: once right after signin but before checking for | 303 // This is disabled twice: once right after signin but before checking for |
| 301 // auto-enrollment, and again after doing an ownership status check. | 304 // auto-enrollment, and again after doing an ownership status check. |
| 302 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 305 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 303 .Times(2); | 306 .Times(2); |
| 304 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 307 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
| 305 .Times(1) | 308 .Times(1) |
| 306 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); | 309 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); |
| 307 EXPECT_CALL(*mock_login_utils_, | 310 EXPECT_CALL(*mock_login_utils_, |
| 308 PrepareProfile(UserContext(kUsername, kPassword, "", kUsername), | 311 PrepareProfile(UserContext(kUsername, kPassword, "", kUsername), |
| 309 _, _, _, _)) | 312 _, _, _, _)) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 323 EXPECT_CALL(*mock_login_display_host_, | 326 EXPECT_CALL(*mock_login_display_host_, |
| 324 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL)) | 327 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL)) |
| 325 .Times(0); | 328 .Times(0); |
| 326 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) | 329 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) |
| 327 .Times(AnyNumber()) | 330 .Times(AnyNumber()) |
| 328 .WillRepeatedly(Return(false)); | 331 .WillRepeatedly(Return(false)); |
| 329 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); | 332 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); |
| 330 content::RunAllPendingInMessageLoop(); | 333 content::RunAllPendingInMessageLoop(); |
| 331 } | 334 } |
| 332 | 335 |
| 333 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { | 336 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, AutoEnrollAfterSignIn) { |
| 334 EXPECT_CALL(*mock_login_display_host_, | 337 EXPECT_CALL(*mock_login_display_host_, |
| 335 StartWizardPtr(WizardController::kEnrollmentScreenName, | 338 StartWizardPtr(WizardController::kEnrollmentScreenName, |
| 336 _)) | 339 _)) |
| 337 .Times(1); | 340 .Times(1); |
| 338 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 341 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
| 339 .Times(1); | 342 .Times(1); |
| 340 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 343 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
| 341 .Times(1); | 344 .Times(1); |
| 342 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) | 345 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) |
| 343 .Times(AnyNumber()) | 346 .Times(AnyNumber()) |
| 344 .WillRepeatedly(Return(false)); | 347 .WillRepeatedly(Return(false)); |
| 345 // The order of these expected calls matters: the UI if first disabled | 348 // The order of these expected calls matters: the UI if first disabled |
| 346 // during the login sequence, and is enabled again for the enrollment screen. | 349 // during the login sequence, and is enabled again for the enrollment screen. |
| 347 Sequence uiEnabledSequence; | 350 Sequence uiEnabledSequence; |
| 348 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 351 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 349 .Times(1) | 352 .Times(1) |
| 350 .InSequence(uiEnabledSequence); | 353 .InSequence(uiEnabledSequence); |
| 351 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 354 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
| 352 .Times(1) | 355 .Times(1) |
| 353 .InSequence(uiEnabledSequence); | 356 .InSequence(uiEnabledSequence); |
| 354 existing_user_controller()->DoAutoEnrollment(); | 357 existing_user_controller()->DoAutoEnrollment(); |
| 355 existing_user_controller()->CompleteLogin( | 358 existing_user_controller()->CompleteLogin( |
| 356 UserContext(kUsername, kPassword, "")); | 359 UserContext(kUsername, kPassword, "")); |
| 357 content::RunAllPendingInMessageLoop(); | 360 content::RunAllPendingInMessageLoop(); |
| 358 } | 361 } |
| 359 | 362 |
| 360 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, | 363 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, |
| 361 NewUserDontAutoEnrollAfterSignIn) { | 364 NewUserDontAutoEnrollAfterSignIn) { |
| 362 EXPECT_CALL(*mock_login_display_host_, | 365 EXPECT_CALL(*mock_login_display_host_, |
| 363 StartWizardPtr(WizardController::kEnrollmentScreenName, | 366 StartWizardPtr(WizardController::kEnrollmentScreenName, |
| 364 _)) | 367 _)) |
| 365 .Times(0); | 368 .Times(0); |
| 366 EXPECT_CALL(*mock_login_display_host_, | 369 EXPECT_CALL(*mock_login_display_host_, |
| 367 StartWizardPtr(WizardController::kTermsOfServiceScreenName, | 370 StartWizardPtr(WizardController::kTermsOfServiceScreenName, |
| 368 NULL)) | 371 NULL)) |
| 369 .Times(1); | 372 .Times(1); |
| 370 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 373 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 581 } |
| 579 | 582 |
| 580 void FireAutoLogin() { | 583 void FireAutoLogin() { |
| 581 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); | 584 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); |
| 582 } | 585 } |
| 583 | 586 |
| 584 private: | 587 private: |
| 585 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); | 588 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); |
| 586 }; | 589 }; |
| 587 | 590 |
| 588 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 591 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, |
| 589 ConfigureAutoLoginUsingPolicy) { | 592 ConfigureAutoLoginUsingPolicy) { |
| 590 existing_user_controller()->OnSigninScreenReady(); | 593 existing_user_controller()->OnSigninScreenReady(); |
| 591 EXPECT_EQ("", auto_login_username()); | 594 EXPECT_EQ("", auto_login_username()); |
| 592 EXPECT_EQ(0, auto_login_delay()); | 595 EXPECT_EQ(0, auto_login_delay()); |
| 593 EXPECT_FALSE(auto_login_timer()); | 596 EXPECT_FALSE(auto_login_timer()); |
| 594 | 597 |
| 595 // Set the policy. | 598 // Set the policy. |
| 596 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); | 599 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); |
| 597 EXPECT_EQ(kAutoLoginUsername, auto_login_username()); | 600 EXPECT_EQ(kAutoLoginUsername, auto_login_username()); |
| 598 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); | 601 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); |
| 599 ASSERT_TRUE(auto_login_timer()); | 602 ASSERT_TRUE(auto_login_timer()); |
| 600 EXPECT_TRUE(auto_login_timer()->IsRunning()); | 603 EXPECT_TRUE(auto_login_timer()->IsRunning()); |
| 601 | 604 |
| 602 // Unset the policy. | 605 // Unset the policy. |
| 603 SetAutoLoginPolicy("", 0); | 606 SetAutoLoginPolicy("", 0); |
| 604 EXPECT_EQ("", auto_login_username()); | 607 EXPECT_EQ("", auto_login_username()); |
| 605 EXPECT_EQ(0, auto_login_delay()); | 608 EXPECT_EQ(0, auto_login_delay()); |
| 606 ASSERT_TRUE(auto_login_timer()); | 609 ASSERT_TRUE(auto_login_timer()); |
| 607 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 610 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 608 } | 611 } |
| 609 | 612 |
| 610 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 613 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, |
| 611 AutoLoginNoDelay) { | 614 AutoLoginNoDelay) { |
| 612 // Set up mocks to check login success. | 615 // Set up mocks to check login success. |
| 613 ExpectSuccessfulLogin(kAutoLoginUsername, "", | 616 ExpectSuccessfulLogin(kAutoLoginUsername, "", |
| 614 CreateAuthenticatorForPublicSession); | 617 CreateAuthenticatorForPublicSession); |
| 615 existing_user_controller()->OnSigninScreenReady(); | 618 existing_user_controller()->OnSigninScreenReady(); |
| 616 | 619 |
| 617 // Start auto-login and wait for login tasks to complete. | 620 // Start auto-login and wait for login tasks to complete. |
| 618 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginNoDelay); | 621 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginNoDelay); |
| 619 content::RunAllPendingInMessageLoop(); | 622 content::RunAllPendingInMessageLoop(); |
| 620 } | 623 } |
| 621 | 624 |
| 622 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 625 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, |
| 623 AutoLoginShortDelay) { | 626 AutoLoginShortDelay) { |
| 624 // Set up mocks to check login success. | 627 // Set up mocks to check login success. |
| 625 ExpectSuccessfulLogin(kAutoLoginUsername, "", | 628 ExpectSuccessfulLogin(kAutoLoginUsername, "", |
| 626 CreateAuthenticatorForPublicSession); | 629 CreateAuthenticatorForPublicSession); |
| 627 existing_user_controller()->OnSigninScreenReady(); | 630 existing_user_controller()->OnSigninScreenReady(); |
| 628 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginShortDelay); | 631 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginShortDelay); |
| 629 ASSERT_TRUE(auto_login_timer()); | 632 ASSERT_TRUE(auto_login_timer()); |
| 630 // Don't assert that timer is running: with the short delay sometimes | 633 // Don't assert that timer is running: with the short delay sometimes |
| 631 // the trigger happens before the assert. We've already tested that | 634 // the trigger happens before the assert. We've already tested that |
| 632 // the timer starts when it should. | 635 // the timer starts when it should. |
| 633 | 636 |
| 634 // Wait for the timer to fire. | 637 // Wait for the timer to fire. |
| 635 base::RunLoop runner; | 638 base::RunLoop runner; |
| 636 base::OneShotTimer<base::RunLoop> timer; | 639 base::OneShotTimer<base::RunLoop> timer; |
| 637 timer.Start(FROM_HERE, | 640 timer.Start(FROM_HERE, |
| 638 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), | 641 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), |
| 639 runner.QuitClosure()); | 642 runner.QuitClosure()); |
| 640 runner.Run(); | 643 runner.Run(); |
| 641 | 644 |
| 642 // Wait for login tasks to complete. | 645 // Wait for login tasks to complete. |
| 643 content::RunAllPendingInMessageLoop(); | 646 content::RunAllPendingInMessageLoop(); |
| 644 } | 647 } |
| 645 | 648 |
| 646 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 649 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, |
| 647 LoginStopsAutoLogin) { | 650 LoginStopsAutoLogin) { |
| 648 // Set up mocks to check login success. | 651 // Set up mocks to check login success. |
| 649 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); | 652 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); |
| 650 | 653 |
| 651 existing_user_controller()->OnSigninScreenReady(); | 654 existing_user_controller()->OnSigninScreenReady(); |
| 652 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); | 655 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); |
| 653 ASSERT_TRUE(auto_login_timer()); | 656 ASSERT_TRUE(auto_login_timer()); |
| 654 | 657 |
| 655 // Login and check that it stopped the timer. | 658 // Login and check that it stopped the timer. |
| 656 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); | 659 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); |
| 657 EXPECT_TRUE(is_login_in_progress()); | 660 EXPECT_TRUE(is_login_in_progress()); |
| 658 ASSERT_TRUE(auto_login_timer()); | 661 ASSERT_TRUE(auto_login_timer()); |
| 659 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 662 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 660 | 663 |
| 661 // Wait for login tasks to complete. | 664 // Wait for login tasks to complete. |
| 662 content::RunAllPendingInMessageLoop(); | 665 content::RunAllPendingInMessageLoop(); |
| 663 | 666 |
| 664 // Timer should still be stopped after login completes. | 667 // Timer should still be stopped after login completes. |
| 665 ASSERT_TRUE(auto_login_timer()); | 668 ASSERT_TRUE(auto_login_timer()); |
| 666 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 669 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 667 } | 670 } |
| 668 | 671 |
| 669 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 672 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, |
| 670 GuestModeLoginStopsAutoLogin) { | 673 GuestModeLoginStopsAutoLogin) { |
| 671 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 674 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 672 .Times(1); | 675 .Times(1); |
| 673 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 676 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
| 674 .Times(1) | 677 .Times(1) |
| 675 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); | 678 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); |
| 676 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_)) | 679 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_)) |
| 677 .Times(1); | 680 .Times(1); |
| 678 | 681 |
| 679 existing_user_controller()->OnSigninScreenReady(); | 682 existing_user_controller()->OnSigninScreenReady(); |
| 680 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); | 683 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); |
| 681 ASSERT_TRUE(auto_login_timer()); | 684 ASSERT_TRUE(auto_login_timer()); |
| 682 | 685 |
| 683 // Login and check that it stopped the timer. | 686 // Login and check that it stopped the timer. |
| 684 existing_user_controller()->LoginAsGuest(); | 687 existing_user_controller()->LoginAsGuest(); |
| 685 EXPECT_TRUE(is_login_in_progress()); | 688 EXPECT_TRUE(is_login_in_progress()); |
| 686 ASSERT_TRUE(auto_login_timer()); | 689 ASSERT_TRUE(auto_login_timer()); |
| 687 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 690 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 688 | 691 |
| 689 // Wait for login tasks to complete. | 692 // Wait for login tasks to complete. |
| 690 content::RunAllPendingInMessageLoop(); | 693 content::RunAllPendingInMessageLoop(); |
| 691 | 694 |
| 692 // Timer should still be stopped after login completes. | 695 // Timer should still be stopped after login completes. |
| 693 ASSERT_TRUE(auto_login_timer()); | 696 ASSERT_TRUE(auto_login_timer()); |
| 694 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 697 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 695 } | 698 } |
| 696 | 699 |
| 697 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 700 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, |
| 698 CompleteLoginStopsAutoLogin) { | 701 CompleteLoginStopsAutoLogin) { |
| 699 // Set up mocks to check login success. | 702 // Set up mocks to check login success. |
| 700 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); | 703 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); |
| 701 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 704 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
| 702 .Times(1); | 705 .Times(1); |
| 703 | 706 |
| 704 existing_user_controller()->OnSigninScreenReady(); | 707 existing_user_controller()->OnSigninScreenReady(); |
| 705 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); | 708 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); |
| 706 ASSERT_TRUE(auto_login_timer()); | 709 ASSERT_TRUE(auto_login_timer()); |
| 707 | 710 |
| 708 // Check that login completes and stops the timer. | 711 // Check that login completes and stops the timer. |
| 709 existing_user_controller()->CompleteLogin( | 712 existing_user_controller()->CompleteLogin( |
| 710 UserContext(kUsername, kPassword, "")); | 713 UserContext(kUsername, kPassword, "")); |
| 711 ASSERT_TRUE(auto_login_timer()); | 714 ASSERT_TRUE(auto_login_timer()); |
| 712 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 715 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 713 | 716 |
| 714 // Wait for login tasks to complete. | 717 // Wait for login tasks to complete. |
| 715 content::RunAllPendingInMessageLoop(); | 718 content::RunAllPendingInMessageLoop(); |
| 716 | 719 |
| 717 // Timer should still be stopped after login completes. | 720 // Timer should still be stopped after login completes. |
| 718 ASSERT_TRUE(auto_login_timer()); | 721 ASSERT_TRUE(auto_login_timer()); |
| 719 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 722 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 720 } | 723 } |
| 721 | 724 |
| 722 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 725 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, |
| 723 PublicSessionLoginStopsAutoLogin) { | 726 PublicSessionLoginStopsAutoLogin) { |
| 724 // Set up mocks to check login success. | 727 // Set up mocks to check login success. |
| 725 ExpectSuccessfulLogin(kAutoLoginUsername, "", | 728 ExpectSuccessfulLogin(kAutoLoginUsername, "", |
| 726 CreateAuthenticatorForPublicSession); | 729 CreateAuthenticatorForPublicSession); |
| 727 existing_user_controller()->OnSigninScreenReady(); | 730 existing_user_controller()->OnSigninScreenReady(); |
| 728 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); | 731 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); |
| 729 ASSERT_TRUE(auto_login_timer()); | 732 ASSERT_TRUE(auto_login_timer()); |
| 730 | 733 |
| 731 // Login and check that it stopped the timer. | 734 // Login and check that it stopped the timer. |
| 732 existing_user_controller()->LoginAsPublicAccount(kAutoLoginUsername); | 735 existing_user_controller()->LoginAsPublicAccount(kAutoLoginUsername); |
| 733 EXPECT_TRUE(is_login_in_progress()); | 736 EXPECT_TRUE(is_login_in_progress()); |
| 734 ASSERT_TRUE(auto_login_timer()); | 737 ASSERT_TRUE(auto_login_timer()); |
| 735 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 738 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 736 | 739 |
| 737 // Wait for login tasks to complete. | 740 // Wait for login tasks to complete. |
| 738 content::RunAllPendingInMessageLoop(); | 741 content::RunAllPendingInMessageLoop(); |
| 739 | 742 |
| 740 // Timer should still be stopped after login completes. | 743 // Timer should still be stopped after login completes. |
| 741 ASSERT_TRUE(auto_login_timer()); | 744 ASSERT_TRUE(auto_login_timer()); |
| 742 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 745 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 743 } | 746 } |
| 744 | 747 |
| 748 INSTANTIATE_TEST_CASE_P(ExistingUserControllerTestInstantiation, |
| 749 ExistingUserControllerTest, |
| 750 testing::Bool()); |
| 751 |
| 752 INSTANTIATE_TEST_CASE_P(ExistingUserControllerPublicSessionTestInstantiation, |
| 753 ExistingUserControllerPublicSessionTest, |
| 754 testing::Bool()); |
| 755 |
| 745 } // namespace chromeos | 756 } // namespace chromeos |
| OLD | NEW |