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" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/chromeos/login/auth/authenticator.h" | 15 #include "chrome/browser/chromeos/login/auth/authenticator.h" |
| 16 #include "chrome/browser/chromeos/login/auth/key.h" |
16 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" | 17 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" |
17 #include "chrome/browser/chromeos/login/auth/mock_url_fetchers.h" | 18 #include "chrome/browser/chromeos/login/auth/mock_url_fetchers.h" |
18 #include "chrome/browser/chromeos/login/auth/user_context.h" | 19 #include "chrome/browser/chromeos/login/auth/user_context.h" |
19 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 20 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
20 #include "chrome/browser/chromeos/login/helper.h" | 21 #include "chrome/browser/chromeos/login/helper.h" |
21 #include "chrome/browser/chromeos/login/mock_login_utils.h" | 22 #include "chrome/browser/chromeos/login/mock_login_utils.h" |
22 #include "chrome/browser/chromeos/login/ui/mock_login_display.h" | 23 #include "chrome/browser/chromeos/login/ui/mock_login_display.h" |
23 #include "chrome/browser/chromeos/login/ui/mock_login_display_host.h" | 24 #include "chrome/browser/chromeos/login/ui/mock_login_display_host.h" |
24 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 25 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
25 #include "chrome/browser/chromeos/login/users/user.h" | 26 #include "chrome/browser/chromeos/login/users/user.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 68 |
68 const char kUsername[] = "test_user@gmail.com"; | 69 const char kUsername[] = "test_user@gmail.com"; |
69 const char kNewUsername[] = "test_new_user@gmail.com"; | 70 const char kNewUsername[] = "test_new_user@gmail.com"; |
70 const char kPassword[] = "test_password"; | 71 const char kPassword[] = "test_password"; |
71 | 72 |
72 const char kPublicSessionAccountId[] = "public_session_user@localhost"; | 73 const char kPublicSessionAccountId[] = "public_session_user@localhost"; |
73 const int kAutoLoginNoDelay = 0; | 74 const int kAutoLoginNoDelay = 0; |
74 const int kAutoLoginShortDelay = 1; | 75 const int kAutoLoginShortDelay = 1; |
75 const int kAutoLoginLongDelay = 10000; | 76 const int kAutoLoginLongDelay = 10000; |
76 | 77 |
77 | 78 ACTION_P(CreateAuthenticator, user_context) { |
78 ACTION_P2(CreateAuthenticator, username, password) { | 79 return new MockAuthenticator(arg0, user_context); |
79 return new MockAuthenticator(arg0, username, password); | |
80 } | 80 } |
81 | 81 |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { | 84 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { |
85 protected: | 85 protected: |
86 ExistingUserControllerTest() | 86 ExistingUserControllerTest() |
87 : mock_login_display_(NULL), mock_user_manager_(NULL) {} | 87 : mock_login_display_(NULL), mock_user_manager_(NULL) {} |
88 | 88 |
89 ExistingUserController* existing_user_controller() { | 89 ExistingUserController* existing_user_controller() { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 229 |
230 private: | 230 private: |
231 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 231 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
232 }; | 232 }; |
233 | 233 |
234 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 234 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
235 // This is disabled twice: once right after signin but before checking for | 235 // This is disabled twice: once right after signin but before checking for |
236 // auto-enrollment, and again after doing an ownership status check. | 236 // auto-enrollment, and again after doing an ownership status check. |
237 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 237 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
238 .Times(2); | 238 .Times(2); |
| 239 UserContext user_context(kUsername); |
| 240 user_context.SetKey(Key(kPassword)); |
| 241 user_context.SetUserIDHash(kUsername); |
239 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 242 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
240 .Times(1) | 243 .Times(1) |
241 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); | 244 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); |
242 UserContext user_context(kUsername); | |
243 user_context.SetPassword(kPassword); | |
244 user_context.SetUserIDHash(kUsername); | |
245 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _, _)) | 245 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _, _)) |
246 .Times(1) | 246 .Times(1) |
247 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | 247 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, |
248 &base::Callback<void(void)>::Run)); | 248 &base::Callback<void(void)>::Run)); |
249 EXPECT_CALL(*mock_login_utils_, | 249 EXPECT_CALL(*mock_login_utils_, |
250 DoBrowserLaunch(testing_profile_.get(), | 250 DoBrowserLaunch(testing_profile_.get(), |
251 mock_login_display_host_.get())) | 251 mock_login_display_host_.get())) |
252 .Times(1); | 252 .Times(1); |
253 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 253 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
254 .Times(1); | 254 .Times(1); |
(...skipping 21 matching lines...) Expand all Loading... |
276 // during the login sequence, and is enabled again for the enrollment screen. | 276 // during the login sequence, and is enabled again for the enrollment screen. |
277 Sequence uiEnabledSequence; | 277 Sequence uiEnabledSequence; |
278 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 278 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
279 .Times(1) | 279 .Times(1) |
280 .InSequence(uiEnabledSequence); | 280 .InSequence(uiEnabledSequence); |
281 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 281 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
282 .Times(1) | 282 .Times(1) |
283 .InSequence(uiEnabledSequence); | 283 .InSequence(uiEnabledSequence); |
284 existing_user_controller()->DoAutoEnrollment(); | 284 existing_user_controller()->DoAutoEnrollment(); |
285 UserContext user_context(kUsername); | 285 UserContext user_context(kUsername); |
286 user_context.SetPassword(kPassword); | 286 user_context.SetKey(Key(kPassword)); |
287 existing_user_controller()->CompleteLogin(user_context); | 287 existing_user_controller()->CompleteLogin(user_context); |
288 content::RunAllPendingInMessageLoop(); | 288 content::RunAllPendingInMessageLoop(); |
289 } | 289 } |
290 | 290 |
291 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, | 291 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, |
292 NewUserDontAutoEnrollAfterSignIn) { | 292 NewUserDontAutoEnrollAfterSignIn) { |
293 EXPECT_CALL(*mock_login_display_host_, | 293 EXPECT_CALL(*mock_login_display_host_, |
294 StartWizardPtr(WizardController::kEnrollmentScreenName, | 294 StartWizardPtr(WizardController::kEnrollmentScreenName, |
295 _)) | 295 _)) |
296 .Times(0); | 296 .Times(0); |
297 EXPECT_CALL(*mock_login_display_host_, | 297 EXPECT_CALL(*mock_login_display_host_, |
298 StartWizardPtr(WizardController::kTermsOfServiceScreenName, | 298 StartWizardPtr(WizardController::kTermsOfServiceScreenName, |
299 NULL)) | 299 NULL)) |
300 .Times(1); | 300 .Times(1); |
| 301 UserContext user_context(kNewUsername); |
| 302 user_context.SetKey(Key(kPassword)); |
301 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 303 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
302 .Times(1) | 304 .Times(1) |
303 .WillOnce(WithArg<0>(CreateAuthenticator(kNewUsername, kPassword))); | 305 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); |
304 base::Callback<void(void)> add_user_cb = | 306 base::Callback<void(void)> add_user_cb = |
305 base::Bind(&MockUserManager::AddUser, | 307 base::Bind(&MockUserManager::AddUser, |
306 base::Unretained(mock_user_manager_), | 308 base::Unretained(mock_user_manager_), |
307 kNewUsername); | 309 kNewUsername); |
308 UserContext user_context(kNewUsername); | |
309 user_context.SetPassword(kPassword); | |
310 user_context.SetUserIDHash(kNewUsername); | 310 user_context.SetUserIDHash(kNewUsername); |
311 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _, _)) | 311 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _, _)) |
312 .Times(1) | 312 .Times(1) |
313 .WillOnce(DoAll( | 313 .WillOnce(DoAll( |
314 InvokeWithoutArgs(&add_user_cb, | 314 InvokeWithoutArgs(&add_user_cb, |
315 &base::Callback<void(void)>::Run), | 315 &base::Callback<void(void)>::Run), |
316 InvokeWithoutArgs(&profile_prepared_cb_, | 316 InvokeWithoutArgs(&profile_prepared_cb_, |
317 &base::Callback<void(void)>::Run))); | 317 &base::Callback<void(void)>::Run))); |
318 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 318 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
319 .Times(1); | 319 .Times(1); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 .WillRepeatedly(ReturnNull()); | 419 .WillRepeatedly(ReturnNull()); |
420 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) | 420 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) |
421 .Times(AnyNumber()); | 421 .Times(AnyNumber()); |
422 EXPECT_CALL(*mock_login_display_, Init(_, _, _, _)) | 422 EXPECT_CALL(*mock_login_display_, Init(_, _, _, _)) |
423 .Times(AnyNumber()); | 423 .Times(AnyNumber()); |
424 } | 424 } |
425 | 425 |
426 virtual void SetUpUserManager() OVERRIDE { | 426 virtual void SetUpUserManager() OVERRIDE { |
427 } | 427 } |
428 | 428 |
429 void ExpectSuccessfulLogin(const std::string& username, | 429 void ExpectSuccessfulLogin(const UserContext& user_context) { |
430 const std::string& password) { | |
431 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 430 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
432 .Times(AnyNumber()); | 431 .Times(AnyNumber()); |
433 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 432 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
434 .Times(1) | 433 .Times(1) |
435 .WillOnce(WithArg<0>(CreateAuthenticator(username, password))); | 434 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); |
436 UserContext user_context(username); | |
437 user_context.SetPassword(password); | |
438 user_context.SetUserIDHash(username); | |
439 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _, _)) | 435 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _, _)) |
440 .Times(1) | 436 .Times(1) |
441 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | 437 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, |
442 &base::Callback<void(void)>::Run)); | 438 &base::Callback<void(void)>::Run)); |
443 EXPECT_CALL(*mock_login_utils_, | 439 EXPECT_CALL(*mock_login_utils_, |
444 DoBrowserLaunch(testing_profile_.get(), | 440 DoBrowserLaunch(testing_profile_.get(), |
445 mock_login_display_host_.get())) | 441 mock_login_display_host_.get())) |
446 .Times(1); | 442 .Times(1); |
447 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 443 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
448 .Times(1); | 444 .Times(1); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 SetAutoLoginPolicy("", 0); | 522 SetAutoLoginPolicy("", 0); |
527 EXPECT_EQ("", auto_login_username()); | 523 EXPECT_EQ("", auto_login_username()); |
528 EXPECT_EQ(0, auto_login_delay()); | 524 EXPECT_EQ(0, auto_login_delay()); |
529 ASSERT_TRUE(auto_login_timer()); | 525 ASSERT_TRUE(auto_login_timer()); |
530 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 526 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
531 } | 527 } |
532 | 528 |
533 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 529 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
534 AutoLoginNoDelay) { | 530 AutoLoginNoDelay) { |
535 // Set up mocks to check login success. | 531 // Set up mocks to check login success. |
536 ExpectSuccessfulLogin(public_session_user_id_, ""); | 532 UserContext user_context(public_session_user_id_); |
| 533 user_context.SetUserIDHash(user_context.GetUserID()); |
| 534 ExpectSuccessfulLogin(user_context); |
537 existing_user_controller()->OnSigninScreenReady(); | 535 existing_user_controller()->OnSigninScreenReady(); |
538 | 536 |
539 // Start auto-login and wait for login tasks to complete. | 537 // Start auto-login and wait for login tasks to complete. |
540 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); | 538 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); |
541 content::RunAllPendingInMessageLoop(); | 539 content::RunAllPendingInMessageLoop(); |
542 } | 540 } |
543 | 541 |
544 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 542 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
545 AutoLoginShortDelay) { | 543 AutoLoginShortDelay) { |
546 // Set up mocks to check login success. | 544 // Set up mocks to check login success. |
547 ExpectSuccessfulLogin(public_session_user_id_, ""); | 545 UserContext user_context(public_session_user_id_); |
| 546 user_context.SetUserIDHash(user_context.GetUserID()); |
| 547 ExpectSuccessfulLogin(user_context); |
548 existing_user_controller()->OnSigninScreenReady(); | 548 existing_user_controller()->OnSigninScreenReady(); |
549 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); | 549 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); |
550 ASSERT_TRUE(auto_login_timer()); | 550 ASSERT_TRUE(auto_login_timer()); |
551 // Don't assert that timer is running: with the short delay sometimes | 551 // Don't assert that timer is running: with the short delay sometimes |
552 // the trigger happens before the assert. We've already tested that | 552 // the trigger happens before the assert. We've already tested that |
553 // the timer starts when it should. | 553 // the timer starts when it should. |
554 | 554 |
555 // Wait for the timer to fire. | 555 // Wait for the timer to fire. |
556 base::RunLoop runner; | 556 base::RunLoop runner; |
557 base::OneShotTimer<base::RunLoop> timer; | 557 base::OneShotTimer<base::RunLoop> timer; |
558 timer.Start(FROM_HERE, | 558 timer.Start(FROM_HERE, |
559 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), | 559 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), |
560 runner.QuitClosure()); | 560 runner.QuitClosure()); |
561 runner.Run(); | 561 runner.Run(); |
562 | 562 |
563 // Wait for login tasks to complete. | 563 // Wait for login tasks to complete. |
564 content::RunAllPendingInMessageLoop(); | 564 content::RunAllPendingInMessageLoop(); |
565 } | 565 } |
566 | 566 |
567 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 567 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
568 LoginStopsAutoLogin) { | 568 LoginStopsAutoLogin) { |
569 // Set up mocks to check login success. | 569 // Set up mocks to check login success. |
570 ExpectSuccessfulLogin(kUsername, kPassword); | 570 UserContext user_context(kUsername); |
| 571 user_context.SetKey(Key(kPassword)); |
| 572 user_context.SetUserIDHash(user_context.GetUserID()); |
| 573 ExpectSuccessfulLogin(user_context); |
571 | 574 |
572 existing_user_controller()->OnSigninScreenReady(); | 575 existing_user_controller()->OnSigninScreenReady(); |
573 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 576 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
574 ASSERT_TRUE(auto_login_timer()); | 577 ASSERT_TRUE(auto_login_timer()); |
575 | 578 |
576 // Login and check that it stopped the timer. | 579 // Log in and check that it stopped the timer. |
577 UserContext user_context(kUsername); | |
578 user_context.SetPassword(kPassword); | |
579 existing_user_controller()->Login(user_context); | 580 existing_user_controller()->Login(user_context); |
580 EXPECT_TRUE(is_login_in_progress()); | 581 EXPECT_TRUE(is_login_in_progress()); |
581 ASSERT_TRUE(auto_login_timer()); | 582 ASSERT_TRUE(auto_login_timer()); |
582 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 583 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
583 | 584 |
584 // Wait for login tasks to complete. | 585 // Wait for login tasks to complete. |
585 content::RunAllPendingInMessageLoop(); | 586 content::RunAllPendingInMessageLoop(); |
586 | 587 |
587 // Timer should still be stopped after login completes. | 588 // Timer should still be stopped after login completes. |
588 ASSERT_TRUE(auto_login_timer()); | 589 ASSERT_TRUE(auto_login_timer()); |
589 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 590 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
590 } | 591 } |
591 | 592 |
592 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 593 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
593 GuestModeLoginStopsAutoLogin) { | 594 GuestModeLoginStopsAutoLogin) { |
594 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 595 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
595 .Times(1); | 596 .Times(1); |
| 597 UserContext user_context(kUsername); |
| 598 user_context.SetKey(Key(kPassword)); |
596 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 599 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
597 .Times(1) | 600 .Times(1) |
598 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); | 601 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); |
599 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_)) | 602 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_)) |
600 .Times(1); | 603 .Times(1); |
601 | 604 |
602 existing_user_controller()->OnSigninScreenReady(); | 605 existing_user_controller()->OnSigninScreenReady(); |
603 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 606 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
604 ASSERT_TRUE(auto_login_timer()); | 607 ASSERT_TRUE(auto_login_timer()); |
605 | 608 |
606 // Login and check that it stopped the timer. | 609 // Login and check that it stopped the timer. |
607 existing_user_controller()->LoginAsGuest(); | 610 existing_user_controller()->LoginAsGuest(); |
608 EXPECT_TRUE(is_login_in_progress()); | 611 EXPECT_TRUE(is_login_in_progress()); |
609 ASSERT_TRUE(auto_login_timer()); | 612 ASSERT_TRUE(auto_login_timer()); |
610 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 613 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
611 | 614 |
612 // Wait for login tasks to complete. | 615 // Wait for login tasks to complete. |
613 content::RunAllPendingInMessageLoop(); | 616 content::RunAllPendingInMessageLoop(); |
614 | 617 |
615 // Timer should still be stopped after login completes. | 618 // Timer should still be stopped after login completes. |
616 ASSERT_TRUE(auto_login_timer()); | 619 ASSERT_TRUE(auto_login_timer()); |
617 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 620 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
618 } | 621 } |
619 | 622 |
620 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 623 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
621 CompleteLoginStopsAutoLogin) { | 624 CompleteLoginStopsAutoLogin) { |
622 // Set up mocks to check login success. | 625 // Set up mocks to check login success. |
623 ExpectSuccessfulLogin(kUsername, kPassword); | 626 UserContext user_context(kUsername); |
| 627 user_context.SetKey(Key(kPassword)); |
| 628 user_context.SetUserIDHash(user_context.GetUserID()); |
| 629 ExpectSuccessfulLogin(user_context); |
624 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 630 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
625 .Times(1); | 631 .Times(1); |
626 | 632 |
627 existing_user_controller()->OnSigninScreenReady(); | 633 existing_user_controller()->OnSigninScreenReady(); |
628 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 634 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
629 ASSERT_TRUE(auto_login_timer()); | 635 ASSERT_TRUE(auto_login_timer()); |
630 | 636 |
631 // Check that login completes and stops the timer. | 637 // Check that login completes and stops the timer. |
632 UserContext user_context(kUsername); | |
633 user_context.SetPassword(kPassword); | |
634 existing_user_controller()->CompleteLogin(user_context); | 638 existing_user_controller()->CompleteLogin(user_context); |
635 ASSERT_TRUE(auto_login_timer()); | 639 ASSERT_TRUE(auto_login_timer()); |
636 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 640 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
637 | 641 |
638 // Wait for login tasks to complete. | 642 // Wait for login tasks to complete. |
639 content::RunAllPendingInMessageLoop(); | 643 content::RunAllPendingInMessageLoop(); |
640 | 644 |
641 // Timer should still be stopped after login completes. | 645 // Timer should still be stopped after login completes. |
642 ASSERT_TRUE(auto_login_timer()); | 646 ASSERT_TRUE(auto_login_timer()); |
643 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 647 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
644 } | 648 } |
645 | 649 |
646 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 650 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
647 PublicSessionLoginStopsAutoLogin) { | 651 PublicSessionLoginStopsAutoLogin) { |
648 // Set up mocks to check login success. | 652 // Set up mocks to check login success. |
649 ExpectSuccessfulLogin(public_session_user_id_, ""); | 653 UserContext user_context(public_session_user_id_); |
| 654 user_context.SetUserIDHash(user_context.GetUserID()); |
| 655 ExpectSuccessfulLogin(user_context); |
650 existing_user_controller()->OnSigninScreenReady(); | 656 existing_user_controller()->OnSigninScreenReady(); |
651 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 657 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
652 ASSERT_TRUE(auto_login_timer()); | 658 ASSERT_TRUE(auto_login_timer()); |
653 | 659 |
654 // Login and check that it stopped the timer. | 660 // Login and check that it stopped the timer. |
655 existing_user_controller()->LoginAsPublicAccount(public_session_user_id_); | 661 existing_user_controller()->LoginAsPublicAccount(public_session_user_id_); |
656 EXPECT_TRUE(is_login_in_progress()); | 662 EXPECT_TRUE(is_login_in_progress()); |
657 ASSERT_TRUE(auto_login_timer()); | 663 ASSERT_TRUE(auto_login_timer()); |
658 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 664 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
659 | 665 |
660 // Wait for login tasks to complete. | 666 // Wait for login tasks to complete. |
661 content::RunAllPendingInMessageLoop(); | 667 content::RunAllPendingInMessageLoop(); |
662 | 668 |
663 // Timer should still be stopped after login completes. | 669 // Timer should still be stopped after login completes. |
664 ASSERT_TRUE(auto_login_timer()); | 670 ASSERT_TRUE(auto_login_timer()); |
665 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 671 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
666 } | 672 } |
667 | 673 |
668 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 674 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
669 PRE_TestLoadingPublicUsersFromLocalState) { | 675 PRE_TestLoadingPublicUsersFromLocalState) { |
670 // First run propagates public accounts and stores them in Local State. | 676 // First run propagates public accounts and stores them in Local State. |
671 } | 677 } |
672 | 678 |
673 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 679 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
674 TestLoadingPublicUsersFromLocalState) { | 680 TestLoadingPublicUsersFromLocalState) { |
675 // Second run loads list of public accounts from Local State. | 681 // Second run loads list of public accounts from Local State. |
676 } | 682 } |
677 | 683 |
678 } // namespace chromeos | 684 } // namespace chromeos |
OLD | NEW |