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