Commit 731bc430 authored by Monica Basta's avatar Monica Basta Committed by Commit Bot

[ProfileInfoCache]: Fix flaky test.

Bug: 1020493
Change-Id: Ia8b943288ea32f7deaa1349854807e101b37ebfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899493
Commit-Queue: Monica Basta <msalama@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712600}
parent 26ecf146
......@@ -50,7 +50,7 @@ const char kSupervisedUserId[] = "managed_user_id";
const char kAccountIdKey[] = "account_id_key";
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
const char kLegacyProfileNameMigrated[] = "legacy.profile.name.migrated";
bool migration_enabled_for_testing_ = false;
bool migration_enabled_for_testing = false;
#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
void DeleteBitmap(const base::FilePath& image_path) {
......@@ -117,9 +117,9 @@ ProfileInfoCache::ProfileInfoCache(PrefService* prefs,
LoadGAIAPictureIfNeeded();
bool migrate_legacy_profile_names =
(!prefs_->GetBoolean(kLegacyProfileNameMigrated) &&
ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName()) ||
migration_enabled_for_testing_;
ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName() &&
(!prefs_->GetBoolean(kLegacyProfileNameMigrated) ||
migration_enabled_for_testing);
if (migrate_legacy_profile_names) {
MigrateLegacyProfileNamesAndRecomputeIfNeeded();
prefs_->SetBoolean(kLegacyProfileNameMigrated, true);
......@@ -689,8 +689,8 @@ void ProfileInfoCache::MigrateLegacyProfileNamesAndRecomputeIfNeeded() {
}
// static
void ProfileInfoCache::EnableLegacyProfileMigrationForTesting() {
migration_enabled_for_testing_ = true;
void ProfileInfoCache::SetLegacyProfileMigrationForTesting(bool value) {
migration_enabled_for_testing = value;
}
#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
......
......@@ -186,7 +186,7 @@ class ProfileInfoCache : public ProfileInfoInterface,
// i.e. Two or more profiles with the profile name "Person 1" would be
// recomputed to "Person 1" and "Person 2".
void MigrateLegacyProfileNamesAndRecomputeIfNeeded();
static void EnableLegacyProfileMigrationForTesting();
static void SetLegacyProfileMigrationForTesting(bool value);
#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
std::vector<std::string> keys_;
......
......@@ -883,7 +883,9 @@ TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesAndRecomputeIfNeeded) {
EXPECT_EQ(12U, GetCache()->GetNumberOfProfiles());
ResetCache();
ProfileInfoCache::EnableLegacyProfileMigrationForTesting();
ProfileInfoCache::SetLegacyProfileMigrationForTesting(true);
GetCache();
ProfileInfoCache::SetLegacyProfileMigrationForTesting(false);
EXPECT_EQ(name_5, GetCache()->GetNameToDisplayOfProfileAtIndex(
GetCache()->GetIndexOfProfileWithPath(path_5)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment