Index: chrome/browser/chromeos/login/login_utils_browsertest.cc |
diff --git a/chrome/browser/chromeos/login/login_utils_browsertest.cc b/chrome/browser/chromeos/login/login_utils_browsertest.cc |
index 4437e5352d412e8ee4a6aad21172b1f923bd4f9e..792dcdb9ba3feeb8c0d1df0995b82cc3e572e362 100644 |
--- a/chrome/browser/chromeos/login/login_utils_browsertest.cc |
+++ b/chrome/browser/chromeos/login/login_utils_browsertest.cc |
@@ -528,49 +528,15 @@ class LoginUtilsTest : public testing::Test, |
DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); |
}; |
+struct LoginUtilsBlockingLoginTestParam { |
+ const int steps; |
+ const char* username; |
+ const bool enroll_device; |
+}; |
+ |
class LoginUtilsBlockingLoginTest |
: public LoginUtilsTest, |
- public testing::WithParamInterface<int> {}; |
- |
-TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) { |
- UserManager* user_manager = UserManager::Get(); |
- EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
- EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
- EXPECT_FALSE(prepared_profile_); |
- EXPECT_EQ(policy::USER_AFFILIATION_NONE, |
- connector_->GetUserAffiliation(kUsername)); |
- |
- // The profile will be created without waiting for a policy response. |
- PrepareProfile(kUsername); |
- |
- EXPECT_TRUE(prepared_profile_); |
- ASSERT_TRUE(user_manager->IsUserLoggedIn()); |
- EXPECT_EQ(kUsername, user_manager->GetLoggedInUser()->email()); |
-} |
- |
-TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) { |
- UserManager* user_manager = UserManager::Get(); |
- EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
- EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
- EXPECT_FALSE(prepared_profile_); |
- |
- // Enroll the device. |
- EnrollDevice(kUsername); |
- |
- EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
- EXPECT_TRUE(connector_->IsEnterpriseManaged()); |
- EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); |
- EXPECT_FALSE(prepared_profile_); |
- EXPECT_EQ(policy::USER_AFFILIATION_NONE, |
- connector_->GetUserAffiliation(kUsernameOtherDomain)); |
- |
- // Login with a non-enterprise user shouldn't block. |
- PrepareProfile(kUsernameOtherDomain); |
- |
- EXPECT_TRUE(prepared_profile_); |
- ASSERT_TRUE(user_manager->IsUserLoggedIn()); |
- EXPECT_EQ(kUsernameOtherDomain, user_manager->GetLoggedInUser()->email()); |
-} |
+ public testing::WithParamInterface<LoginUtilsBlockingLoginTestParam> {}; |
#if defined(ENABLE_RLZ) |
TEST_F(LoginUtilsTest, RlzInitialized) { |
@@ -598,25 +564,27 @@ TEST_F(LoginUtilsTest, RlzInitialized) { |
} |
#endif |
-TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) { |
+TEST_P(LoginUtilsBlockingLoginTest, LoginBlocksForUser) { |
UserManager* user_manager = UserManager::Get(); |
EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
EXPECT_FALSE(prepared_profile_); |
- // Enroll the device. |
- EnrollDevice(kUsername); |
+ if (GetParam().enroll_device) { |
+ // Enroll the device. |
+ EnrollDevice(kUsername); |
- EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
- EXPECT_TRUE(connector_->IsEnterpriseManaged()); |
- EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); |
- EXPECT_FALSE(prepared_profile_); |
- EXPECT_EQ(policy::USER_AFFILIATION_MANAGED, |
- connector_->GetUserAffiliation(kUsername)); |
- EXPECT_FALSE(user_manager->IsKnownUser(kUsername)); |
+ EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
+ EXPECT_TRUE(connector_->IsEnterpriseManaged()); |
+ EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); |
+ EXPECT_FALSE(prepared_profile_); |
+ EXPECT_EQ(policy::USER_AFFILIATION_MANAGED, |
+ connector_->GetUserAffiliation(kUsername)); |
+ EXPECT_FALSE(user_manager->IsKnownUser(kUsername)); |
+ } |
// Login with a user of the enterprise domain waits for policy. |
bartfab (slow)
2014/07/11 11:16:45
Nit: Remove this comment. It is no longer applicab
kaliamoorthi
2014/07/11 11:27:57
Done.
|
- PrepareProfile(kUsername); |
+ PrepareProfile(GetParam().username); |
EXPECT_FALSE(prepared_profile_); |
ASSERT_TRUE(user_manager->IsUserLoggedIn()); |
@@ -628,7 +596,7 @@ TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) { |
// |steps| is the test parameter, and is the number of successful fetches. |
// The first incomplete fetch will fail. In any case, the profile creation |
// should resume. |
- int steps = GetParam(); |
+ int steps = GetParam().steps; |
// The next expected fetcher ID. This is used to make it fail. |
int next_expected_fetcher_id = 0; |
@@ -703,10 +671,29 @@ TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) { |
EXPECT_TRUE(prepared_profile_); |
} |
-INSTANTIATE_TEST_CASE_P( |
- LoginUtilsBlockingLoginTestInstance, |
- LoginUtilsBlockingLoginTest, |
- testing::Values(0, 1, 2, 3, 4, 5)); |
+const LoginUtilsBlockingLoginTestParam kTestData[] = { |
bartfab (slow)
2014/07/11 11:16:45
Nit: s/kTestData/kBlockinLoginTestCases/ (or somet
kaliamoorthi
2014/07/11 11:27:57
Done.
|
+ {0, kUsername, true}, |
+ {1, kUsername, true}, |
+ {2, kUsername, true}, |
+ {3, kUsername, true}, |
+ {4, kUsername, true}, |
+ {5, kUsername, true}, |
+ {0, kUsername, false}, |
+ {1, kUsername, false}, |
+ {2, kUsername, false}, |
+ {3, kUsername, false}, |
+ {4, kUsername, false}, |
+ {5, kUsername, false}, |
+ {0, kUsernameOtherDomain, true}, |
+ {1, kUsernameOtherDomain, true}, |
+ {2, kUsernameOtherDomain, true}, |
+ {3, kUsernameOtherDomain, true}, |
+ {4, kUsernameOtherDomain, true}, |
+ {5, kUsernameOtherDomain, true}}; |
+ |
+INSTANTIATE_TEST_CASE_P(LoginUtilsBlockingLoginTestInstance, |
+ LoginUtilsBlockingLoginTest, |
+ testing::ValuesIn(kTestData)); |
} // namespace |