| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 DoBrowserLaunch(testing_profile_.get(), | 350 DoBrowserLaunch(testing_profile_.get(), |
| 351 mock_login_display_host_.get())) | 351 mock_login_display_host_.get())) |
| 352 .Times(1); | 352 .Times(1); |
| 353 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername)) | 353 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername)) |
| 354 .Times(1); | 354 .Times(1); |
| 355 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 355 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
| 356 .Times(1); | 356 .Times(1); |
| 357 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 357 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
| 358 .Times(1); | 358 .Times(1); |
| 359 EXPECT_CALL(*mock_login_display_host_, | 359 EXPECT_CALL(*mock_login_display_host_, |
| 360 StartWizard(WizardController::kTermsOfServiceScreenName, NULL)) | 360 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL)) |
| 361 .Times(0); | 361 .Times(0); |
| 362 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) | 362 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) |
| 363 .Times(AnyNumber()) | 363 .Times(AnyNumber()) |
| 364 .WillRepeatedly(Return(false)); | 364 .WillRepeatedly(Return(false)); |
| 365 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); | 365 existing_user_controller()->Login(UserContext(kUsername, kPassword, "")); |
| 366 content::RunAllPendingInMessageLoop(); | 366 content::RunAllPendingInMessageLoop(); |
| 367 } | 367 } |
| 368 | 368 |
| 369 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { | 369 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { |
| 370 EXPECT_CALL(*mock_login_display_host_, | 370 EXPECT_CALL(*mock_login_display_host_, |
| 371 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) | 371 StartWizardPtr(WizardController::kEnterpriseEnrollmentScreenName, |
| 372 _)) |
| 372 .Times(1); | 373 .Times(1); |
| 373 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 374 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
| 374 .Times(1); | 375 .Times(1); |
| 375 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 376 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
| 376 .Times(1); | 377 .Times(1); |
| 377 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) | 378 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew()) |
| 378 .Times(AnyNumber()) | 379 .Times(AnyNumber()) |
| 379 .WillRepeatedly(Return(false)); | 380 .WillRepeatedly(Return(false)); |
| 380 // The order of these expected calls matters: the UI if first disabled | 381 // The order of these expected calls matters: the UI if first disabled |
| 381 // during the login sequence, and is enabled again for the enrollment screen. | 382 // during the login sequence, and is enabled again for the enrollment screen. |
| 382 Sequence uiEnabledSequence; | 383 Sequence uiEnabledSequence; |
| 383 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 384 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 384 .Times(1) | 385 .Times(1) |
| 385 .InSequence(uiEnabledSequence); | 386 .InSequence(uiEnabledSequence); |
| 386 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 387 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
| 387 .Times(1) | 388 .Times(1) |
| 388 .InSequence(uiEnabledSequence); | 389 .InSequence(uiEnabledSequence); |
| 389 existing_user_controller()->DoAutoEnrollment(); | 390 existing_user_controller()->DoAutoEnrollment(); |
| 390 existing_user_controller()->CompleteLogin( | 391 existing_user_controller()->CompleteLogin( |
| 391 UserContext(kUsername, kPassword, "")); | 392 UserContext(kUsername, kPassword, "")); |
| 392 content::RunAllPendingInMessageLoop(); | 393 content::RunAllPendingInMessageLoop(); |
| 393 } | 394 } |
| 394 | 395 |
| 395 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, | 396 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, |
| 396 NewUserDontAutoEnrollAfterSignIn) { | 397 NewUserDontAutoEnrollAfterSignIn) { |
| 397 EXPECT_CALL(*mock_login_display_host_, | 398 EXPECT_CALL(*mock_login_display_host_, |
| 398 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) | 399 StartWizardPtr(WizardController::kEnterpriseEnrollmentScreenName, |
| 400 _)) |
| 399 .Times(0); | 401 .Times(0); |
| 400 EXPECT_CALL(*mock_login_display_host_, | 402 EXPECT_CALL(*mock_login_display_host_, |
| 401 StartWizard(WizardController::kTermsOfServiceScreenName, NULL)) | 403 StartWizardPtr(WizardController::kTermsOfServiceScreenName, |
| 404 NULL)) |
| 402 .Times(1); | 405 .Times(1); |
| 403 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 406 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
| 404 .Times(1) | 407 .Times(1) |
| 405 .WillOnce(WithArg<0>(Invoke(CreateAuthenticatorNewUser))); | 408 .WillOnce(WithArg<0>(Invoke(CreateAuthenticatorNewUser))); |
| 406 EXPECT_CALL(*mock_login_utils_, | 409 EXPECT_CALL(*mock_login_utils_, |
| 407 PrepareProfile(UserContext(kNewUsername, | 410 PrepareProfile(UserContext(kNewUsername, |
| 408 kPassword, | 411 kPassword, |
| 409 std::string(), | 412 std::string(), |
| 410 kNewUsername), | 413 kNewUsername), |
| 411 _, _, _, _)) | 414 _, _, _, _)) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 DoBrowserLaunch(testing_profile_.get(), | 550 DoBrowserLaunch(testing_profile_.get(), |
| 548 mock_login_display_host_.get())) | 551 mock_login_display_host_.get())) |
| 549 .Times(1); | 552 .Times(1); |
| 550 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(username)) | 553 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(username)) |
| 551 .Times(1); | 554 .Times(1); |
| 552 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 555 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
| 553 .Times(1); | 556 .Times(1); |
| 554 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 557 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
| 555 .Times(1); | 558 .Times(1); |
| 556 EXPECT_CALL(*mock_login_display_host_, | 559 EXPECT_CALL(*mock_login_display_host_, |
| 557 StartWizard(WizardController::kTermsOfServiceScreenName, NULL)) | 560 StartWizardPtr(WizardController::kTermsOfServiceScreenName, |
| 561 NULL)) |
| 558 .Times(0); | 562 .Times(0); |
| 559 } | 563 } |
| 560 | 564 |
| 561 scoped_ptr<base::RunLoop> CreateSettingsObserverRunLoop( | 565 scoped_ptr<base::RunLoop> CreateSettingsObserverRunLoop( |
| 562 content::MockNotificationObserver& observer, const char* setting) { | 566 content::MockNotificationObserver& observer, const char* setting) { |
| 563 base::RunLoop* loop = new base::RunLoop; | 567 base::RunLoop* loop = new base::RunLoop; |
| 564 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, | 568 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, |
| 565 _, HasDetails(setting))) | 569 _, HasDetails(setting))) |
| 566 .Times(1) | 570 .Times(1) |
| 567 .WillOnce(InvokeWithoutArgs(loop, &base::RunLoop::Quit)); | 571 .WillOnce(InvokeWithoutArgs(loop, &base::RunLoop::Quit)); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 | 806 |
| 803 // Wait for login tasks to complete. | 807 // Wait for login tasks to complete. |
| 804 content::RunAllPendingInMessageLoop(); | 808 content::RunAllPendingInMessageLoop(); |
| 805 | 809 |
| 806 // Timer should still be stopped after login completes. | 810 // Timer should still be stopped after login completes. |
| 807 ASSERT_TRUE(auto_login_timer()); | 811 ASSERT_TRUE(auto_login_timer()); |
| 808 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 812 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 809 } | 813 } |
| 810 | 814 |
| 811 } // namespace chromeos | 815 } // namespace chromeos |
| OLD | NEW |