Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller_browsertest.cc

Issue 294033002: Multi-profile flag cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Return --test-type flag back to profile_manager_unittest.cc Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 24 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
25 #include "chrome/browser/chromeos/login/users/user.h" 25 #include "chrome/browser/chromeos/login/users/user.h"
26 #include "chrome/browser/chromeos/login/users/user_manager.h" 26 #include "chrome/browser/chromeos/login/users/user_manager.h"
27 #include "chrome/browser/chromeos/login/wizard_controller.h" 27 #include "chrome/browser/chromeos/login/wizard_controller.h"
28 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 28 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
29 #include "chrome/browser/chromeos/policy/device_local_account.h" 29 #include "chrome/browser/chromeos/policy/device_local_account.h"
30 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" 30 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
31 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 31 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
32 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 32 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
33 #include "chrome/browser/chromeos/settings/cros_settings.h" 33 #include "chrome/browser/chromeos/settings/cros_settings.h"
34 #include "chrome/common/chrome_switches.h"
35 #include "chrome/test/base/testing_browser_process.h" 34 #include "chrome/test/base/testing_browser_process.h"
36 #include "chrome/test/base/testing_profile.h" 35 #include "chrome/test/base/testing_profile.h"
37 #include "chrome/test/base/ui_test_utils.h" 36 #include "chrome/test/base/ui_test_utils.h"
38 #include "chromeos/chromeos_switches.h" 37 #include "chromeos/chromeos_switches.h"
39 #include "chromeos/dbus/fake_session_manager_client.h" 38 #include "chromeos/dbus/fake_session_manager_client.h"
40 #include "chromeos/settings/cros_settings_names.h" 39 #include "chromeos/settings/cros_settings_names.h"
41 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 40 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
42 #include "components/policy/core/common/cloud/cloud_policy_core.h" 41 #include "components/policy/core/common/cloud/cloud_policy_core.h"
43 #include "components/policy/core/common/cloud/cloud_policy_store.h" 42 #include "components/policy/core/common/cloud/cloud_policy_store.h"
44 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" 43 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h"
(...skipping 30 matching lines...) Expand all
75 const int kAutoLoginShortDelay = 1; 74 const int kAutoLoginShortDelay = 1;
76 const int kAutoLoginLongDelay = 10000; 75 const int kAutoLoginLongDelay = 10000;
77 76
78 77
79 ACTION_P2(CreateAuthenticator, username, password) { 78 ACTION_P2(CreateAuthenticator, username, password) {
80 return new MockAuthenticator(arg0, username, password); 79 return new MockAuthenticator(arg0, username, password);
81 } 80 }
82 81
83 } // namespace 82 } // namespace
84 83
85 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest, 84 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest {
86 public testing::WithParamInterface<bool> {
87 protected: 85 protected:
88 ExistingUserControllerTest() 86 ExistingUserControllerTest()
89 : mock_login_display_(NULL), mock_user_manager_(NULL) {} 87 : mock_login_display_(NULL), mock_user_manager_(NULL) {}
90 88
91 ExistingUserController* existing_user_controller() { 89 ExistingUserController* existing_user_controller() {
92 return ExistingUserController::current_controller(); 90 return ExistingUserController::current_controller();
93 } 91 }
94 92
95 const ExistingUserController* existing_user_controller() const { 93 const ExistingUserController* existing_user_controller() const {
96 return ExistingUserController::current_controller(); 94 return ExistingUserController::current_controller();
(...skipping 25 matching lines...) Expand all
122 .Times(1) 120 .Times(1)
123 .WillOnce(ReturnNull()); 121 .WillOnce(ReturnNull());
124 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) 122 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged())
125 .Times(1); 123 .Times(1);
126 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) 124 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true))
127 .Times(1); 125 .Times(1);
128 } 126 }
129 127
130 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 128 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
131 command_line->AppendSwitch(switches::kLoginManager); 129 command_line->AppendSwitch(switches::kLoginManager);
132 if (GetParam())
133 command_line->AppendSwitch(::switches::kMultiProfiles);
134 } 130 }
135 131
136 virtual void SetUpUserManager() { 132 virtual void SetUpUserManager() {
137 // Replace the UserManager singleton with a mock. 133 // Replace the UserManager singleton with a mock.
138 mock_user_manager_ = new MockUserManager; 134 mock_user_manager_ = new MockUserManager;
139 user_manager_enabler_.reset( 135 user_manager_enabler_.reset(
140 new ScopedUserManagerEnabler(mock_user_manager_)); 136 new ScopedUserManagerEnabler(mock_user_manager_));
141 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername)) 137 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername))
142 .Times(AnyNumber()) 138 .Times(AnyNumber())
143 .WillRepeatedly(Return(true)); 139 .WillRepeatedly(Return(true));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 224
229 // Mock URLFetcher. 225 // Mock URLFetcher.
230 MockURLFetcherFactory<SuccessFetcher> factory_; 226 MockURLFetcherFactory<SuccessFetcher> factory_;
231 227
232 base::Callback<void(void)> profile_prepared_cb_; 228 base::Callback<void(void)> profile_prepared_cb_;
233 229
234 private: 230 private:
235 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); 231 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest);
236 }; 232 };
237 233
238 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, ExistingUserLogin) { 234 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) {
239 // 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
240 // auto-enrollment, and again after doing an ownership status check. 236 // auto-enrollment, and again after doing an ownership status check.
241 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 237 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
242 .Times(2); 238 .Times(2);
243 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) 239 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
244 .Times(1) 240 .Times(1)
245 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); 241 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword)));
246 UserContext user_context(kUsername); 242 UserContext user_context(kUsername);
247 user_context.SetPassword(kPassword); 243 user_context.SetPassword(kPassword);
248 user_context.SetUserIDHash(kUsername); 244 user_context.SetUserIDHash(kUsername);
(...skipping 14 matching lines...) Expand all
263 EXPECT_CALL(*mock_login_display_host_, 259 EXPECT_CALL(*mock_login_display_host_,
264 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL)) 260 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL))
265 .Times(0); 261 .Times(0);
266 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) 262 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew())
267 .Times(AnyNumber()) 263 .Times(AnyNumber())
268 .WillRepeatedly(Return(false)); 264 .WillRepeatedly(Return(false));
269 existing_user_controller()->Login(user_context); 265 existing_user_controller()->Login(user_context);
270 content::RunAllPendingInMessageLoop(); 266 content::RunAllPendingInMessageLoop();
271 } 267 }
272 268
273 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, AutoEnrollAfterSignIn) { 269 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) {
274 EXPECT_CALL(*mock_login_display_host_, 270 EXPECT_CALL(*mock_login_display_host_,
275 StartWizardPtr(WizardController::kEnrollmentScreenName, 271 StartWizardPtr(WizardController::kEnrollmentScreenName,
276 _)) 272 _))
277 .Times(1); 273 .Times(1);
278 EXPECT_CALL(*mock_login_display_, OnFadeOut()) 274 EXPECT_CALL(*mock_login_display_, OnFadeOut())
279 .Times(1); 275 .Times(1);
280 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) 276 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin())
281 .Times(1); 277 .Times(1);
282 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) 278 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew())
283 .Times(AnyNumber()) 279 .Times(AnyNumber())
284 .WillRepeatedly(Return(false)); 280 .WillRepeatedly(Return(false));
285 // The order of these expected calls matters: the UI if first disabled 281 // The order of these expected calls matters: the UI if first disabled
286 // during the login sequence, and is enabled again for the enrollment screen. 282 // during the login sequence, and is enabled again for the enrollment screen.
287 Sequence uiEnabledSequence; 283 Sequence uiEnabledSequence;
288 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 284 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
289 .Times(1) 285 .Times(1)
290 .InSequence(uiEnabledSequence); 286 .InSequence(uiEnabledSequence);
291 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) 287 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
292 .Times(1) 288 .Times(1)
293 .InSequence(uiEnabledSequence); 289 .InSequence(uiEnabledSequence);
294 existing_user_controller()->DoAutoEnrollment(); 290 existing_user_controller()->DoAutoEnrollment();
295 UserContext user_context(kUsername); 291 UserContext user_context(kUsername);
296 user_context.SetPassword(kPassword); 292 user_context.SetPassword(kPassword);
297 existing_user_controller()->CompleteLogin(user_context); 293 existing_user_controller()->CompleteLogin(user_context);
298 content::RunAllPendingInMessageLoop(); 294 content::RunAllPendingInMessageLoop();
299 } 295 }
300 296
301 IN_PROC_BROWSER_TEST_P(ExistingUserControllerTest, 297 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest,
302 NewUserDontAutoEnrollAfterSignIn) { 298 NewUserDontAutoEnrollAfterSignIn) {
303 EXPECT_CALL(*mock_login_display_host_, 299 EXPECT_CALL(*mock_login_display_host_,
304 StartWizardPtr(WizardController::kEnrollmentScreenName, 300 StartWizardPtr(WizardController::kEnrollmentScreenName,
305 _)) 301 _))
306 .Times(0); 302 .Times(0);
307 EXPECT_CALL(*mock_login_display_host_, 303 EXPECT_CALL(*mock_login_display_host_,
308 StartWizardPtr(WizardController::kTermsOfServiceScreenName, 304 StartWizardPtr(WizardController::kTermsOfServiceScreenName,
309 NULL)) 305 NULL))
310 .Times(1); 306 .Times(1);
311 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) 307 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 void FireAutoLogin() { 515 void FireAutoLogin() {
520 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); 516 existing_user_controller()->OnPublicSessionAutoLoginTimerFire();
521 } 517 }
522 518
523 const std::string public_session_user_id_; 519 const std::string public_session_user_id_;
524 520
525 private: 521 private:
526 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); 522 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest);
527 }; 523 };
528 524
529 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 525 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
530 ConfigureAutoLoginUsingPolicy) { 526 ConfigureAutoLoginUsingPolicy) {
531 existing_user_controller()->OnSigninScreenReady(); 527 existing_user_controller()->OnSigninScreenReady();
532 EXPECT_EQ("", auto_login_username()); 528 EXPECT_EQ("", auto_login_username());
533 EXPECT_EQ(0, auto_login_delay()); 529 EXPECT_EQ(0, auto_login_delay());
534 EXPECT_FALSE(auto_login_timer()); 530 EXPECT_FALSE(auto_login_timer());
535 531
536 // Set the policy. 532 // Set the policy.
537 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); 533 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay);
538 EXPECT_EQ(public_session_user_id_, auto_login_username()); 534 EXPECT_EQ(public_session_user_id_, auto_login_username());
539 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); 535 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay());
540 ASSERT_TRUE(auto_login_timer()); 536 ASSERT_TRUE(auto_login_timer());
541 EXPECT_TRUE(auto_login_timer()->IsRunning()); 537 EXPECT_TRUE(auto_login_timer()->IsRunning());
542 538
543 // Unset the policy. 539 // Unset the policy.
544 SetAutoLoginPolicy("", 0); 540 SetAutoLoginPolicy("", 0);
545 EXPECT_EQ("", auto_login_username()); 541 EXPECT_EQ("", auto_login_username());
546 EXPECT_EQ(0, auto_login_delay()); 542 EXPECT_EQ(0, auto_login_delay());
547 ASSERT_TRUE(auto_login_timer()); 543 ASSERT_TRUE(auto_login_timer());
548 EXPECT_FALSE(auto_login_timer()->IsRunning()); 544 EXPECT_FALSE(auto_login_timer()->IsRunning());
549 } 545 }
550 546
551 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 547 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
552 AutoLoginNoDelay) { 548 AutoLoginNoDelay) {
553 // Set up mocks to check login success. 549 // Set up mocks to check login success.
554 ExpectSuccessfulLogin(public_session_user_id_, ""); 550 ExpectSuccessfulLogin(public_session_user_id_, "");
555 existing_user_controller()->OnSigninScreenReady(); 551 existing_user_controller()->OnSigninScreenReady();
556 552
557 // Start auto-login and wait for login tasks to complete. 553 // Start auto-login and wait for login tasks to complete.
558 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); 554 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay);
559 content::RunAllPendingInMessageLoop(); 555 content::RunAllPendingInMessageLoop();
560 } 556 }
561 557
562 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 558 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
563 AutoLoginShortDelay) { 559 AutoLoginShortDelay) {
564 // Set up mocks to check login success. 560 // Set up mocks to check login success.
565 ExpectSuccessfulLogin(public_session_user_id_, ""); 561 ExpectSuccessfulLogin(public_session_user_id_, "");
566 existing_user_controller()->OnSigninScreenReady(); 562 existing_user_controller()->OnSigninScreenReady();
567 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); 563 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay);
568 ASSERT_TRUE(auto_login_timer()); 564 ASSERT_TRUE(auto_login_timer());
569 // Don't assert that timer is running: with the short delay sometimes 565 // Don't assert that timer is running: with the short delay sometimes
570 // the trigger happens before the assert. We've already tested that 566 // the trigger happens before the assert. We've already tested that
571 // the timer starts when it should. 567 // the timer starts when it should.
572 568
573 // Wait for the timer to fire. 569 // Wait for the timer to fire.
574 base::RunLoop runner; 570 base::RunLoop runner;
575 base::OneShotTimer<base::RunLoop> timer; 571 base::OneShotTimer<base::RunLoop> timer;
576 timer.Start(FROM_HERE, 572 timer.Start(FROM_HERE,
577 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), 573 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1),
578 runner.QuitClosure()); 574 runner.QuitClosure());
579 runner.Run(); 575 runner.Run();
580 576
581 // Wait for login tasks to complete. 577 // Wait for login tasks to complete.
582 content::RunAllPendingInMessageLoop(); 578 content::RunAllPendingInMessageLoop();
583 } 579 }
584 580
585 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 581 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
586 LoginStopsAutoLogin) { 582 LoginStopsAutoLogin) {
587 // Set up mocks to check login success. 583 // Set up mocks to check login success.
588 ExpectSuccessfulLogin(kUsername, kPassword); 584 ExpectSuccessfulLogin(kUsername, kPassword);
589 585
590 existing_user_controller()->OnSigninScreenReady(); 586 existing_user_controller()->OnSigninScreenReady();
591 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); 587 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay);
592 ASSERT_TRUE(auto_login_timer()); 588 ASSERT_TRUE(auto_login_timer());
593 589
594 // Login and check that it stopped the timer. 590 // Login and check that it stopped the timer.
595 UserContext user_context(kUsername); 591 UserContext user_context(kUsername);
596 user_context.SetPassword(kPassword); 592 user_context.SetPassword(kPassword);
597 existing_user_controller()->Login(user_context); 593 existing_user_controller()->Login(user_context);
598 EXPECT_TRUE(is_login_in_progress()); 594 EXPECT_TRUE(is_login_in_progress());
599 ASSERT_TRUE(auto_login_timer()); 595 ASSERT_TRUE(auto_login_timer());
600 EXPECT_FALSE(auto_login_timer()->IsRunning()); 596 EXPECT_FALSE(auto_login_timer()->IsRunning());
601 597
602 // Wait for login tasks to complete. 598 // Wait for login tasks to complete.
603 content::RunAllPendingInMessageLoop(); 599 content::RunAllPendingInMessageLoop();
604 600
605 // Timer should still be stopped after login completes. 601 // Timer should still be stopped after login completes.
606 ASSERT_TRUE(auto_login_timer()); 602 ASSERT_TRUE(auto_login_timer());
607 EXPECT_FALSE(auto_login_timer()->IsRunning()); 603 EXPECT_FALSE(auto_login_timer()->IsRunning());
608 } 604 }
609 605
610 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 606 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
611 GuestModeLoginStopsAutoLogin) { 607 GuestModeLoginStopsAutoLogin) {
612 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 608 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
613 .Times(1); 609 .Times(1);
614 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) 610 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
615 .Times(1) 611 .Times(1)
616 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword))); 612 .WillOnce(WithArg<0>(CreateAuthenticator(kUsername, kPassword)));
617 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_)) 613 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_))
618 .Times(1); 614 .Times(1);
619 615
620 existing_user_controller()->OnSigninScreenReady(); 616 existing_user_controller()->OnSigninScreenReady();
621 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); 617 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay);
622 ASSERT_TRUE(auto_login_timer()); 618 ASSERT_TRUE(auto_login_timer());
623 619
624 // Login and check that it stopped the timer. 620 // Login and check that it stopped the timer.
625 existing_user_controller()->LoginAsGuest(); 621 existing_user_controller()->LoginAsGuest();
626 EXPECT_TRUE(is_login_in_progress()); 622 EXPECT_TRUE(is_login_in_progress());
627 ASSERT_TRUE(auto_login_timer()); 623 ASSERT_TRUE(auto_login_timer());
628 EXPECT_FALSE(auto_login_timer()->IsRunning()); 624 EXPECT_FALSE(auto_login_timer()->IsRunning());
629 625
630 // Wait for login tasks to complete. 626 // Wait for login tasks to complete.
631 content::RunAllPendingInMessageLoop(); 627 content::RunAllPendingInMessageLoop();
632 628
633 // Timer should still be stopped after login completes. 629 // Timer should still be stopped after login completes.
634 ASSERT_TRUE(auto_login_timer()); 630 ASSERT_TRUE(auto_login_timer());
635 EXPECT_FALSE(auto_login_timer()->IsRunning()); 631 EXPECT_FALSE(auto_login_timer()->IsRunning());
636 } 632 }
637 633
638 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 634 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
639 CompleteLoginStopsAutoLogin) { 635 CompleteLoginStopsAutoLogin) {
640 // Set up mocks to check login success. 636 // Set up mocks to check login success.
641 ExpectSuccessfulLogin(kUsername, kPassword); 637 ExpectSuccessfulLogin(kUsername, kPassword);
642 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) 638 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin())
643 .Times(1); 639 .Times(1);
644 640
645 existing_user_controller()->OnSigninScreenReady(); 641 existing_user_controller()->OnSigninScreenReady();
646 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); 642 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay);
647 ASSERT_TRUE(auto_login_timer()); 643 ASSERT_TRUE(auto_login_timer());
648 644
649 // Check that login completes and stops the timer. 645 // Check that login completes and stops the timer.
650 UserContext user_context(kUsername); 646 UserContext user_context(kUsername);
651 user_context.SetPassword(kPassword); 647 user_context.SetPassword(kPassword);
652 existing_user_controller()->CompleteLogin(user_context); 648 existing_user_controller()->CompleteLogin(user_context);
653 ASSERT_TRUE(auto_login_timer()); 649 ASSERT_TRUE(auto_login_timer());
654 EXPECT_FALSE(auto_login_timer()->IsRunning()); 650 EXPECT_FALSE(auto_login_timer()->IsRunning());
655 651
656 // Wait for login tasks to complete. 652 // Wait for login tasks to complete.
657 content::RunAllPendingInMessageLoop(); 653 content::RunAllPendingInMessageLoop();
658 654
659 // Timer should still be stopped after login completes. 655 // Timer should still be stopped after login completes.
660 ASSERT_TRUE(auto_login_timer()); 656 ASSERT_TRUE(auto_login_timer());
661 EXPECT_FALSE(auto_login_timer()->IsRunning()); 657 EXPECT_FALSE(auto_login_timer()->IsRunning());
662 } 658 }
663 659
664 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 660 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
665 PublicSessionLoginStopsAutoLogin) { 661 PublicSessionLoginStopsAutoLogin) {
666 // Set up mocks to check login success. 662 // Set up mocks to check login success.
667 ExpectSuccessfulLogin(public_session_user_id_, ""); 663 ExpectSuccessfulLogin(public_session_user_id_, "");
668 existing_user_controller()->OnSigninScreenReady(); 664 existing_user_controller()->OnSigninScreenReady();
669 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); 665 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay);
670 ASSERT_TRUE(auto_login_timer()); 666 ASSERT_TRUE(auto_login_timer());
671 667
672 // Login and check that it stopped the timer. 668 // Login and check that it stopped the timer.
673 existing_user_controller()->LoginAsPublicAccount(public_session_user_id_); 669 existing_user_controller()->LoginAsPublicAccount(public_session_user_id_);
674 EXPECT_TRUE(is_login_in_progress()); 670 EXPECT_TRUE(is_login_in_progress());
675 ASSERT_TRUE(auto_login_timer()); 671 ASSERT_TRUE(auto_login_timer());
676 EXPECT_FALSE(auto_login_timer()->IsRunning()); 672 EXPECT_FALSE(auto_login_timer()->IsRunning());
677 673
678 // Wait for login tasks to complete. 674 // Wait for login tasks to complete.
679 content::RunAllPendingInMessageLoop(); 675 content::RunAllPendingInMessageLoop();
680 676
681 // Timer should still be stopped after login completes. 677 // Timer should still be stopped after login completes.
682 ASSERT_TRUE(auto_login_timer()); 678 ASSERT_TRUE(auto_login_timer());
683 EXPECT_FALSE(auto_login_timer()->IsRunning()); 679 EXPECT_FALSE(auto_login_timer()->IsRunning());
684 } 680 }
685 681
686 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 682 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
687 PRE_TestLoadingPublicUsersFromLocalState) { 683 PRE_TestLoadingPublicUsersFromLocalState) {
688 // First run propagates public accounts and stores them in Local State. 684 // First run propagates public accounts and stores them in Local State.
689 } 685 }
690 686
691 IN_PROC_BROWSER_TEST_P(ExistingUserControllerPublicSessionTest, 687 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
692 TestLoadingPublicUsersFromLocalState) { 688 TestLoadingPublicUsersFromLocalState) {
693 // Second run loads list of public accounts from Local State. 689 // Second run loads list of public accounts from Local State.
694 } 690 }
695 691
696 INSTANTIATE_TEST_CASE_P(ExistingUserControllerTestInstantiation,
697 ExistingUserControllerTest,
698 testing::Bool());
699
700 INSTANTIATE_TEST_CASE_P(ExistingUserControllerPublicSessionTestInstantiation,
701 ExistingUserControllerPublicSessionTest,
702 testing::Bool());
703
704 } // namespace chromeos 692 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698