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

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

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

Powered by Google App Engine
This is Rietveld 408576698