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 "chrome/browser/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 std::string user_policy_; | 526 std::string user_policy_; |
527 | 527 |
528 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); | 528 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); |
529 }; | 529 }; |
530 | 530 |
531 class LoginUtilsBlockingLoginTest | 531 class LoginUtilsBlockingLoginTest |
532 : public LoginUtilsTest, | 532 : public LoginUtilsTest, |
533 public testing::WithParamInterface<int> {}; | 533 public testing::WithParamInterface<int> {}; |
534 | 534 |
535 TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) { | 535 TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) { |
536 UserManager* user_manager = UserManager::Get(); | 536 UserManager* user_manager = GetUserManager(); |
537 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 537 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
538 EXPECT_FALSE(connector_->IsEnterpriseManaged()); | 538 EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
539 EXPECT_FALSE(prepared_profile_); | 539 EXPECT_FALSE(prepared_profile_); |
540 EXPECT_EQ(policy::USER_AFFILIATION_NONE, | 540 EXPECT_EQ(policy::USER_AFFILIATION_NONE, |
541 connector_->GetUserAffiliation(kUsername)); | 541 connector_->GetUserAffiliation(kUsername)); |
542 | 542 |
543 // The profile will be created without waiting for a policy response. | 543 // The profile will be created without waiting for a policy response. |
544 PrepareProfile(kUsername); | 544 PrepareProfile(kUsername); |
545 | 545 |
546 EXPECT_TRUE(prepared_profile_); | 546 EXPECT_TRUE(prepared_profile_); |
547 ASSERT_TRUE(user_manager->IsUserLoggedIn()); | 547 ASSERT_TRUE(user_manager->IsUserLoggedIn()); |
548 EXPECT_EQ(kUsername, user_manager->GetLoggedInUser()->email()); | 548 EXPECT_EQ(kUsername, user_manager->GetLoggedInUser()->email()); |
549 } | 549 } |
550 | 550 |
551 TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) { | 551 TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) { |
552 UserManager* user_manager = UserManager::Get(); | 552 UserManager* user_manager = GetUserManager(); |
553 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 553 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
554 EXPECT_FALSE(connector_->IsEnterpriseManaged()); | 554 EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
555 EXPECT_FALSE(prepared_profile_); | 555 EXPECT_FALSE(prepared_profile_); |
556 | 556 |
557 // Enroll the device. | 557 // Enroll the device. |
558 EnrollDevice(kUsername); | 558 EnrollDevice(kUsername); |
559 | 559 |
560 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 560 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
561 EXPECT_TRUE(connector_->IsEnterpriseManaged()); | 561 EXPECT_TRUE(connector_->IsEnterpriseManaged()); |
562 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); | 562 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); |
(...skipping 29 matching lines...) Expand all Loading... |
592 | 592 |
593 // RLZ value for homepage access point should have been initialized. | 593 // RLZ value for homepage access point should have been initialized. |
594 base::string16 rlz_string; | 594 base::string16 rlz_string; |
595 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( | 595 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
596 RLZTracker::ChromeHomePage(), &rlz_string)); | 596 RLZTracker::ChromeHomePage(), &rlz_string)); |
597 EXPECT_EQ(base::string16(), rlz_string); | 597 EXPECT_EQ(base::string16(), rlz_string); |
598 } | 598 } |
599 #endif | 599 #endif |
600 | 600 |
601 TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) { | 601 TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) { |
602 UserManager* user_manager = UserManager::Get(); | 602 UserManager* user_manager = GetUserManager(); |
603 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 603 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
604 EXPECT_FALSE(connector_->IsEnterpriseManaged()); | 604 EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
605 EXPECT_FALSE(prepared_profile_); | 605 EXPECT_FALSE(prepared_profile_); |
606 | 606 |
607 // Enroll the device. | 607 // Enroll the device. |
608 EnrollDevice(kUsername); | 608 EnrollDevice(kUsername); |
609 | 609 |
610 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 610 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
611 EXPECT_TRUE(connector_->IsEnterpriseManaged()); | 611 EXPECT_TRUE(connector_->IsEnterpriseManaged()); |
612 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); | 612 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 } | 704 } |
705 | 705 |
706 INSTANTIATE_TEST_CASE_P( | 706 INSTANTIATE_TEST_CASE_P( |
707 LoginUtilsBlockingLoginTestInstance, | 707 LoginUtilsBlockingLoginTestInstance, |
708 LoginUtilsBlockingLoginTest, | 708 LoginUtilsBlockingLoginTest, |
709 testing::Values(0, 1, 2, 3, 4, 5)); | 709 testing::Values(0, 1, 2, 3, 4, 5)); |
710 | 710 |
711 } // namespace | 711 } // namespace |
712 | 712 |
713 } // namespace chromeos | 713 } // namespace chromeos |
OLD | NEW |