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"; ...@@ -50,7 +50,7 @@ const char kSupervisedUserId[] = "managed_user_id";
const char kAccountIdKey[] = "account_id_key"; const char kAccountIdKey[] = "account_id_key";
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
const char kLegacyProfileNameMigrated[] = "legacy.profile.name.migrated"; 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) #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
void DeleteBitmap(const base::FilePath& image_path) { void DeleteBitmap(const base::FilePath& image_path) {
...@@ -117,9 +117,9 @@ ProfileInfoCache::ProfileInfoCache(PrefService* prefs, ...@@ -117,9 +117,9 @@ ProfileInfoCache::ProfileInfoCache(PrefService* prefs,
LoadGAIAPictureIfNeeded(); LoadGAIAPictureIfNeeded();
bool migrate_legacy_profile_names = bool migrate_legacy_profile_names =
(!prefs_->GetBoolean(kLegacyProfileNameMigrated) && ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName() &&
ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName()) || (!prefs_->GetBoolean(kLegacyProfileNameMigrated) ||
migration_enabled_for_testing_; migration_enabled_for_testing);
if (migrate_legacy_profile_names) { if (migrate_legacy_profile_names) {
MigrateLegacyProfileNamesAndRecomputeIfNeeded(); MigrateLegacyProfileNamesAndRecomputeIfNeeded();
prefs_->SetBoolean(kLegacyProfileNameMigrated, true); prefs_->SetBoolean(kLegacyProfileNameMigrated, true);
...@@ -689,8 +689,8 @@ void ProfileInfoCache::MigrateLegacyProfileNamesAndRecomputeIfNeeded() { ...@@ -689,8 +689,8 @@ void ProfileInfoCache::MigrateLegacyProfileNamesAndRecomputeIfNeeded() {
} }
// static // static
void ProfileInfoCache::EnableLegacyProfileMigrationForTesting() { void ProfileInfoCache::SetLegacyProfileMigrationForTesting(bool value) {
migration_enabled_for_testing_ = true; migration_enabled_for_testing = value;
} }
#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
......
...@@ -186,7 +186,7 @@ class ProfileInfoCache : public ProfileInfoInterface, ...@@ -186,7 +186,7 @@ class ProfileInfoCache : public ProfileInfoInterface,
// i.e. Two or more profiles with the profile name "Person 1" would be // i.e. Two or more profiles with the profile name "Person 1" would be
// recomputed to "Person 1" and "Person 2". // recomputed to "Person 1" and "Person 2".
void MigrateLegacyProfileNamesAndRecomputeIfNeeded(); void MigrateLegacyProfileNamesAndRecomputeIfNeeded();
static void EnableLegacyProfileMigrationForTesting(); static void SetLegacyProfileMigrationForTesting(bool value);
#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
std::vector<std::string> keys_; std::vector<std::string> keys_;
......
...@@ -883,7 +883,9 @@ TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesAndRecomputeIfNeeded) { ...@@ -883,7 +883,9 @@ TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesAndRecomputeIfNeeded) {
EXPECT_EQ(12U, GetCache()->GetNumberOfProfiles()); EXPECT_EQ(12U, GetCache()->GetNumberOfProfiles());
ResetCache(); ResetCache();
ProfileInfoCache::EnableLegacyProfileMigrationForTesting(); ProfileInfoCache::SetLegacyProfileMigrationForTesting(true);
GetCache();
ProfileInfoCache::SetLegacyProfileMigrationForTesting(false);
EXPECT_EQ(name_5, GetCache()->GetNameToDisplayOfProfileAtIndex( EXPECT_EQ(name_5, GetCache()->GetNameToDisplayOfProfileAtIndex(
GetCache()->GetIndexOfProfileWithPath(path_5))); 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