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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 338 |
339 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 339 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
340 // This is disabled twice: once right after signin but before checking for | 340 // This is disabled twice: once right after signin but before checking for |
341 // auto-enrollment, and again after doing an ownership status check. | 341 // auto-enrollment, and again after doing an ownership status check. |
342 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 342 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
343 .Times(2); | 343 .Times(2); |
344 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 344 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
345 .Times(1) | 345 .Times(1) |
346 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); | 346 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); |
347 EXPECT_CALL(*mock_login_utils_, | 347 EXPECT_CALL(*mock_login_utils_, |
348 PrepareProfile(kUsername, _, kPassword, _, _, _)) | 348 PrepareProfile(UserCredentials(kUsername, kPassword, ""), |
| 349 _, _, _, _)) |
349 .Times(1) | 350 .Times(1) |
350 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | 351 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, |
351 &base::Callback<void(void)>::Run)); | 352 &base::Callback<void(void)>::Run)); |
352 EXPECT_CALL(*mock_login_utils_, | 353 EXPECT_CALL(*mock_login_utils_, |
353 DoBrowserLaunch(testing_profile_.get(), | 354 DoBrowserLaunch(testing_profile_.get(), |
354 mock_login_display_host_.get())) | 355 mock_login_display_host_.get())) |
355 .Times(1); | 356 .Times(1); |
356 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername)) | 357 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername)) |
357 .Times(1); | 358 .Times(1); |
358 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 359 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
359 .Times(1); | 360 .Times(1); |
360 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 361 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
361 .Times(1); | 362 .Times(1); |
362 EXPECT_CALL(*mock_login_display_host_, | 363 EXPECT_CALL(*mock_login_display_host_, |
363 StartWizard(WizardController::kTermsOfServiceScreenName, NULL)) | 364 StartWizard(WizardController::kTermsOfServiceScreenName, NULL)) |
364 .Times(0); | 365 .Times(0); |
365 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) | 366 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) |
366 .Times(AnyNumber()) | 367 .Times(AnyNumber()) |
367 .WillRepeatedly(Return(false)); | 368 .WillRepeatedly(Return(false)); |
368 existing_user_controller()->Login(kUsername, kPassword); | 369 existing_user_controller()->Login(UserCredentials(kUsername, kPassword, "")); |
369 content::RunAllPendingInMessageLoop(); | 370 content::RunAllPendingInMessageLoop(); |
370 } | 371 } |
371 | 372 |
372 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { | 373 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { |
373 EXPECT_CALL(*mock_login_display_host_, | 374 EXPECT_CALL(*mock_login_display_host_, |
374 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) | 375 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) |
375 .Times(1); | 376 .Times(1); |
376 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 377 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
377 .Times(1); | 378 .Times(1); |
378 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 379 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
379 .Times(1); | 380 .Times(1); |
380 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) | 381 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) |
381 .Times(AnyNumber()) | 382 .Times(AnyNumber()) |
382 .WillRepeatedly(Return(false)); | 383 .WillRepeatedly(Return(false)); |
383 // The order of these expected calls matters: the UI if first disabled | 384 // The order of these expected calls matters: the UI if first disabled |
384 // during the login sequence, and is enabled again for the enrollment screen. | 385 // during the login sequence, and is enabled again for the enrollment screen. |
385 Sequence uiEnabledSequence; | 386 Sequence uiEnabledSequence; |
386 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 387 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
387 .Times(1) | 388 .Times(1) |
388 .InSequence(uiEnabledSequence); | 389 .InSequence(uiEnabledSequence); |
389 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 390 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
390 .Times(1) | 391 .Times(1) |
391 .InSequence(uiEnabledSequence); | 392 .InSequence(uiEnabledSequence); |
392 existing_user_controller()->DoAutoEnrollment(); | 393 existing_user_controller()->DoAutoEnrollment(); |
393 existing_user_controller()->CompleteLogin(kUsername, kPassword); | 394 existing_user_controller()->CompleteLogin( |
| 395 UserCredentials(kUsername, kPassword, "")); |
394 content::RunAllPendingInMessageLoop(); | 396 content::RunAllPendingInMessageLoop(); |
395 } | 397 } |
396 | 398 |
397 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, | 399 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, |
398 NewUserDontAutoEnrollAfterSignIn) { | 400 NewUserDontAutoEnrollAfterSignIn) { |
399 EXPECT_CALL(*mock_login_display_host_, | 401 EXPECT_CALL(*mock_login_display_host_, |
400 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) | 402 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) |
401 .Times(0); | 403 .Times(0); |
402 // This will be the first sign-in of a new user, which may cause the (legacy) | 404 // This will be the first sign-in of a new user, which may cause the (legacy) |
403 // registration to be activated. A real WizardController instance immediately | 405 // registration to be activated. A real WizardController instance immediately |
404 // advances to the Terms of Service or user image screen but this test uses | 406 // advances to the Terms of Service or user image screen but this test uses |
405 // MockLoginDisplayHost Instead. | 407 // MockLoginDisplayHost Instead. |
406 EXPECT_CALL(*mock_login_display_host_, | 408 EXPECT_CALL(*mock_login_display_host_, |
407 StartWizard(AnyOf(WizardController::kRegistrationScreenName, | 409 StartWizard(AnyOf(WizardController::kRegistrationScreenName, |
408 WizardController::kTermsOfServiceScreenName), | 410 WizardController::kTermsOfServiceScreenName), |
409 NULL)) | 411 NULL)) |
410 .Times(1); | 412 .Times(1); |
411 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 413 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
412 .Times(1) | 414 .Times(1) |
413 .WillOnce(WithArg<0>(Invoke(CreateAuthenticatorNewUser))); | 415 .WillOnce(WithArg<0>(Invoke(CreateAuthenticatorNewUser))); |
414 EXPECT_CALL(*mock_login_utils_, | 416 EXPECT_CALL(*mock_login_utils_, |
415 PrepareProfile(kNewUsername, _, kPassword, _, _, _)) | 417 PrepareProfile(UserCredentials(kNewUsername, kPassword, ""), |
| 418 _, _, _, _)) |
416 .Times(1) | 419 .Times(1) |
417 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | 420 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, |
418 &base::Callback<void(void)>::Run)); | 421 &base::Callback<void(void)>::Run)); |
419 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kNewUsername)) | 422 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kNewUsername)) |
420 .Times(1); | 423 .Times(1); |
421 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 424 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
422 .Times(1); | 425 .Times(1); |
423 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 426 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
424 .Times(1); | 427 .Times(1); |
425 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) | 428 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) |
426 .Times(AnyNumber()) | 429 .Times(AnyNumber()) |
427 .WillRepeatedly(Return(true)); | 430 .WillRepeatedly(Return(true)); |
428 | 431 |
429 // The order of these expected calls matters: the UI if first disabled | 432 // The order of these expected calls matters: the UI if first disabled |
430 // during the login sequence, and is enabled again after login completion. | 433 // during the login sequence, and is enabled again after login completion. |
431 Sequence uiEnabledSequence; | 434 Sequence uiEnabledSequence; |
432 // This is disabled twice: once right after signin but before checking for | 435 // This is disabled twice: once right after signin but before checking for |
433 // auto-enrollment, and again after doing an ownership status check. | 436 // auto-enrollment, and again after doing an ownership status check. |
434 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 437 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
435 .Times(2) | 438 .Times(2) |
436 .InSequence(uiEnabledSequence); | 439 .InSequence(uiEnabledSequence); |
437 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 440 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
438 .Times(1) | 441 .Times(1) |
439 .InSequence(uiEnabledSequence); | 442 .InSequence(uiEnabledSequence); |
440 | 443 |
441 existing_user_controller()->CompleteLogin(kNewUsername, kPassword); | 444 existing_user_controller()->CompleteLogin( |
| 445 UserCredentials(kNewUsername, kPassword, "")); |
442 content::RunAllPendingInMessageLoop(); | 446 content::RunAllPendingInMessageLoop(); |
443 } | 447 } |
444 | 448 |
445 MATCHER_P(HasDetails, expected, "") { | 449 MATCHER_P(HasDetails, expected, "") { |
446 return expected == *content::Details<const std::string>(arg).ptr(); | 450 return expected == *content::Details<const std::string>(arg).ptr(); |
447 } | 451 } |
448 | 452 |
449 class ExistingUserControllerPublicSessionTest | 453 class ExistingUserControllerPublicSessionTest |
450 : public ExistingUserControllerTest { | 454 : public ExistingUserControllerTest { |
451 protected: | 455 protected: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 void ExpectSuccessfulLogin(const std::string& username, | 539 void ExpectSuccessfulLogin(const std::string& username, |
536 const std::string& password, | 540 const std::string& password, |
537 scoped_refptr<Authenticator> create_authenticator( | 541 scoped_refptr<Authenticator> create_authenticator( |
538 LoginStatusConsumer* consumer)) { | 542 LoginStatusConsumer* consumer)) { |
539 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 543 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
540 .Times(AnyNumber()); | 544 .Times(AnyNumber()); |
541 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 545 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
542 .Times(1) | 546 .Times(1) |
543 .WillOnce(WithArg<0>(Invoke(create_authenticator))); | 547 .WillOnce(WithArg<0>(Invoke(create_authenticator))); |
544 EXPECT_CALL(*mock_login_utils_, | 548 EXPECT_CALL(*mock_login_utils_, |
545 PrepareProfile(username, _, password, _, _, _)) | 549 PrepareProfile(UserCredentials(username, password, ""), |
| 550 _, _, _, _)) |
546 .Times(1) | 551 .Times(1) |
547 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | 552 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, |
548 &base::Callback<void(void)>::Run)); | 553 &base::Callback<void(void)>::Run)); |
549 EXPECT_CALL(*mock_login_utils_, | 554 EXPECT_CALL(*mock_login_utils_, |
550 DoBrowserLaunch(testing_profile_.get(), | 555 DoBrowserLaunch(testing_profile_.get(), |
551 mock_login_display_host_.get())) | 556 mock_login_display_host_.get())) |
552 .Times(1); | 557 .Times(1); |
553 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(username)) | 558 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(username)) |
554 .Times(1); | 559 .Times(1); |
555 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 560 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 723 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
719 LoginStopsAutoLogin) { | 724 LoginStopsAutoLogin) { |
720 // Set up mocks to check login success. | 725 // Set up mocks to check login success. |
721 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); | 726 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); |
722 | 727 |
723 existing_user_controller()->OnSigninScreenReady(); | 728 existing_user_controller()->OnSigninScreenReady(); |
724 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); | 729 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); |
725 ASSERT_TRUE(auto_login_timer()); | 730 ASSERT_TRUE(auto_login_timer()); |
726 | 731 |
727 // Login and check that it stopped the timer. | 732 // Login and check that it stopped the timer. |
728 existing_user_controller()->Login(kUsername, kPassword); | 733 existing_user_controller()->Login(UserCredentials(kUsername, kPassword, "")); |
729 EXPECT_TRUE(is_login_in_progress()); | 734 EXPECT_TRUE(is_login_in_progress()); |
730 ASSERT_TRUE(auto_login_timer()); | 735 ASSERT_TRUE(auto_login_timer()); |
731 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 736 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
732 | 737 |
733 // Wait for login tasks to complete. | 738 // Wait for login tasks to complete. |
734 content::RunAllPendingInMessageLoop(); | 739 content::RunAllPendingInMessageLoop(); |
735 | 740 |
736 // Timer should still be stopped after login completes. | 741 // Timer should still be stopped after login completes. |
737 ASSERT_TRUE(auto_login_timer()); | 742 ASSERT_TRUE(auto_login_timer()); |
738 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 743 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 // Set up mocks to check login success. | 776 // Set up mocks to check login success. |
772 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); | 777 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator); |
773 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 778 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
774 .Times(1); | 779 .Times(1); |
775 | 780 |
776 existing_user_controller()->OnSigninScreenReady(); | 781 existing_user_controller()->OnSigninScreenReady(); |
777 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); | 782 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay); |
778 ASSERT_TRUE(auto_login_timer()); | 783 ASSERT_TRUE(auto_login_timer()); |
779 | 784 |
780 // Check that login completes and stops the timer. | 785 // Check that login completes and stops the timer. |
781 existing_user_controller()->CompleteLogin(kUsername, kPassword); | 786 existing_user_controller()->CompleteLogin( |
| 787 UserCredentials(kUsername, kPassword, "")); |
782 ASSERT_TRUE(auto_login_timer()); | 788 ASSERT_TRUE(auto_login_timer()); |
783 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 789 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
784 | 790 |
785 // Wait for login tasks to complete. | 791 // Wait for login tasks to complete. |
786 content::RunAllPendingInMessageLoop(); | 792 content::RunAllPendingInMessageLoop(); |
787 | 793 |
788 // Timer should still be stopped after login completes. | 794 // Timer should still be stopped after login completes. |
789 ASSERT_TRUE(auto_login_timer()); | 795 ASSERT_TRUE(auto_login_timer()); |
790 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 796 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
791 } | 797 } |
(...skipping 15 matching lines...) Expand all Loading... |
807 | 813 |
808 // Wait for login tasks to complete. | 814 // Wait for login tasks to complete. |
809 content::RunAllPendingInMessageLoop(); | 815 content::RunAllPendingInMessageLoop(); |
810 | 816 |
811 // Timer should still be stopped after login completes. | 817 // Timer should still be stopped after login completes. |
812 ASSERT_TRUE(auto_login_timer()); | 818 ASSERT_TRUE(auto_login_timer()); |
813 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 819 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
814 } | 820 } |
815 | 821 |
816 } // namespace chromeos | 822 } // namespace chromeos |
OLD | NEW |