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

Unified Diff: chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc

Issue 1425093004: Revert of This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
diff --git a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
index 68cceed0a5a581a31e41c3373e77f6413ec86d5d..04c945ece1fcdfa42c1e06d5d86a7ffea73415b1 100644
--- a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
+++ b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
@@ -116,12 +116,7 @@
MultiProfileUserControllerTest()
: fake_user_manager_(new FakeChromeUserManager),
user_manager_enabler_(fake_user_manager_),
- user_not_allowed_count_(0) {
- for (size_t i = 0; i < arraysize(kUsers); ++i) {
- test_users_.push_back(AccountId::FromUserEmail(kUsers[i]));
- }
- }
-
+ user_not_allowed_count_(0) {}
~MultiProfileUserControllerTest() override {}
void SetUp() override {
@@ -131,15 +126,14 @@
controller_.reset(new MultiProfileUserController(
this, TestingBrowserProcess::GetGlobal()->local_state()));
- for (size_t i = 0; i < test_users_.size(); ++i) {
- const AccountId account_id(test_users_[i]);
- const user_manager::User* user =
- fake_user_manager_->AddUser(test_users_[i]);
+ for (size_t i = 0; i < arraysize(kUsers); ++i) {
+ const std::string user_email(kUsers[i]);
+ const user_manager::User* user = fake_user_manager_->AddUser(user_email);
// Note that user profiles are created after user login in reality.
TestingProfile* user_profile =
- profile_manager_->CreateTestingProfile(account_id.GetUserEmail());
- user_profile->set_profile_name(account_id.GetUserEmail());
+ profile_manager_->CreateTestingProfile(user_email);
+ user_profile->set_profile_name(user_email);
user_profiles_.push_back(user_profile);
ProfileHelper::Get()->SetUserToProfileMappingForTesting(user,
@@ -163,13 +157,13 @@
}
void LoginUser(size_t user_index) {
- ASSERT_LT(user_index, test_users_.size());
- fake_user_manager_->LoginUser(test_users_[user_index]);
+ ASSERT_LT(user_index, arraysize(kUsers));
+ fake_user_manager_->LoginUser(kUsers[user_index]);
controller_->StartObserving(user_profiles_[user_index]);
}
void SetOwner(size_t user_index) {
- fake_user_manager_->set_owner_id(test_users_[user_index]);
+ fake_user_manager_->set_owner_email(kUsers[user_index]);
}
PrefService* GetUserPrefs(size_t user_index) {
@@ -182,13 +176,12 @@
}
std::string GetCachedBehavior(size_t user_index) {
- return controller_->GetCachedValue(test_users_[user_index].GetUserEmail());
+ return controller_->GetCachedValue(kUsers[user_index]);
}
void SetCachedBehavior(size_t user_index,
const std::string& behavior) {
- controller_->SetCachedValue(test_users_[user_index].GetUserEmail(),
- behavior);
+ controller_->SetCachedValue(kUsers[user_index], behavior);
}
void ResetCounts() {
@@ -218,8 +211,6 @@
std::vector<TestingProfile*> user_profiles_;
int user_not_allowed_count_;
-
- std::vector<AccountId> test_users_;
private:
DISALLOW_COPY_AND_ASSIGN(MultiProfileUserControllerTest);
@@ -235,8 +226,7 @@
for (size_t i = 0; i < arraysize(kTestCases); ++i) {
SetCachedBehavior(0, kTestCases[i]);
MultiProfileUserController::UserAllowedInSessionReason reason;
- EXPECT_TRUE(controller()->IsUserAllowedInSession(
- test_users_[0].GetUserEmail(), &reason))
+ EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[0], &reason))
<< "Case " << i;
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason) << "Case " << i;
EXPECT_EQ(MultiProfileUserController::ALLOWED,
@@ -302,8 +292,7 @@
MultiProfileUserController::GetPrimaryUserPolicy())
<< "Case " << i;
MultiProfileUserController::UserAllowedInSessionReason reason;
- controller()->IsUserAllowedInSession(test_users_[1].GetUserEmail(),
- &reason);
+ controller()->IsUserAllowedInSession(kUsers[1], &reason);
EXPECT_EQ(kBehaviorTestCases[i].expected_secondary_allowed, reason)
<< "Case " << i;
}
@@ -337,14 +326,11 @@
UsedPolicyCertificatesAllowedForPrimary) {
// Verifies that any user can sign-in as the primary user, regardless of the
// tainted state.
- policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(
- test_users_[0].GetUserEmail());
+ policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(kUsers[0]);
MultiProfileUserController::UserAllowedInSessionReason reason;
- EXPECT_TRUE(controller()->IsUserAllowedInSession(
- test_users_[0].GetUserEmail(), &reason));
+ EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[0], &reason));
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason);
- EXPECT_TRUE(controller()->IsUserAllowedInSession(
- test_users_[1].GetUserEmail(), &reason));
+ EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[1], &reason));
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason);
EXPECT_EQ(MultiProfileUserController::ALLOWED,
MultiProfileUserController::GetPrimaryUserPolicy());
@@ -361,14 +347,11 @@
SetPrefBehavior(1, MultiProfileUserController::kBehaviorUnrestricted);
MultiProfileUserController::UserAllowedInSessionReason reason;
- EXPECT_TRUE(controller()->IsUserAllowedInSession(
- test_users_[0].GetUserEmail(), &reason));
+ EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[0], &reason));
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason);
- policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(
- test_users_[0].GetUserEmail());
- EXPECT_FALSE(controller()->IsUserAllowedInSession(
- test_users_[0].GetUserEmail(), &reason));
+ policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(kUsers[0]);
+ EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[0], &reason));
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_POLICY_CERT_TAINTED,
reason);
}
@@ -377,8 +360,7 @@
UsedPolicyCertificatesDisallowsSecondaries) {
// Verifies that if a tainted user is signed-in then no other users can
// be added.
- policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(
- test_users_[0].GetUserEmail());
+ policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(kUsers[0]);
LoginUser(0);
cert_verifier_.reset(new policy::PolicyCertVerifier(base::Closure()));
@@ -388,16 +370,13 @@
profile(0), TestPolicyCertServiceFactory));
MultiProfileUserController::UserAllowedInSessionReason reason;
- EXPECT_FALSE(controller()->IsUserAllowedInSession(
- test_users_[1].GetUserEmail(), &reason));
+ EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason));
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,
reason);
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,
MultiProfileUserController::GetPrimaryUserPolicy());
- policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(
- test_users_[1].GetUserEmail());
- EXPECT_FALSE(controller()->IsUserAllowedInSession(
- test_users_[1].GetUserEmail(), &reason));
+ policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(kUsers[1]);
+ EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason));
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_POLICY_CERT_TAINTED,
reason);
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,
@@ -428,8 +407,7 @@
EXPECT_FALSE(service->has_policy_certificates());
MultiProfileUserController::UserAllowedInSessionReason reason;
- EXPECT_TRUE(controller()->IsUserAllowedInSession(
- test_users_[1].GetUserEmail(), &reason));
+ EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[1], &reason));
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason);
EXPECT_EQ(MultiProfileUserController::ALLOWED,
MultiProfileUserController::GetPrimaryUserPolicy());
@@ -439,8 +417,7 @@
"subject", "issuer", base::Time(), base::Time()));
service->OnTrustAnchorsChanged(certificates);
EXPECT_TRUE(service->has_policy_certificates());
- EXPECT_FALSE(controller()->IsUserAllowedInSession(
- test_users_[1].GetUserEmail(), &reason));
+ EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason));
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,
reason);
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,

Powered by Google App Engine
This is Rietveld 408576698