Index: chrome/browser/profiles/gaia_info_update_service_unittest.cc |
diff --git a/chrome/browser/profiles/gaia_info_update_service_unittest.cc b/chrome/browser/profiles/gaia_info_update_service_unittest.cc |
index 64c1a85385f7541b868d571181a3a269471f3cb0..7769b0be42728d6f5f17867791557f6b60771e4a 100644 |
--- a/chrome/browser/profiles/gaia_info_update_service_unittest.cc |
+++ b/chrome/browser/profiles/gaia_info_update_service_unittest.cc |
@@ -8,6 +8,8 @@ |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/prefs/pref_service_syncable.h" |
+#include "chrome/browser/profiles/profile_attributes_entry.h" |
+#include "chrome/browser/profiles/profile_attributes_storage.h" |
#include "chrome/browser/profiles/profile_downloader.h" |
#include "chrome/browser/profiles/profile_info_cache.h" |
#include "chrome/browser/profiles/profile_info_cache_unittest.h" |
@@ -71,6 +73,10 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest { |
return profile_; |
} |
+ ProfileAttributesStorage* storage() { |
+ return GetCache(); |
Mike Lerman
2015/08/06 16:06:19
Do we still need a GetCache() method?
|
+ } |
+ |
NiceMock<GAIAInfoUpdateServiceMock>* service() { return service_.get(); } |
NiceMock<ProfileDownloaderMock>* downloader() { return downloader_.get(); } |
@@ -85,8 +91,10 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest { |
// The testing manager sets the profile name manually, which counts as |
// a user-customized profile name. Reset this to match the default name |
// we are actually using. |
- size_t index = GetCache()->GetIndexOfProfileWithPath(profile->GetPath()); |
- GetCache()->SetProfileIsUsingDefaultNameAtIndex(index, true); |
+ ProfileAttributesEntry* entry; |
+ if (storage()->GetProfileAttributesWithPath(profile->GetPath(), &entry)) { |
+ entry->SetIsUsingDefaultName(true); |
+ } |
return profile; |
} |
@@ -131,9 +139,11 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest { |
ProfileDownloadSuccess(full_name, given_name, image, url, base::string16()); |
// Make sure the right profile was updated correctly. |
- size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath()); |
- EXPECT_EQ(full_name, GetCache()->GetGAIANameOfProfileAtIndex(index)); |
- EXPECT_EQ(given_name, GetCache()->GetGAIAGivenNameOfProfileAtIndex(index)); |
+ ProfileAttributesEntry* entry; |
+ ASSERT_TRUE( |
+ storage()->GetProfileAttributesWithPath(profile()->GetPath(), &entry)); |
+ EXPECT_EQ(full_name, entry->GetGAIAName()); |
+ EXPECT_EQ(given_name, entry->GetGAIAGivenName()); |
} |
private: |
@@ -174,20 +184,23 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) { |
ProfileDownloadSuccess(name, given_name, image, url, hosted_domain); |
// On success the GAIA info should be updated. |
- size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath()); |
- EXPECT_EQ(name, GetCache()->GetGAIANameOfProfileAtIndex(index)); |
- EXPECT_EQ(given_name, GetCache()->GetGAIAGivenNameOfProfileAtIndex(index)); |
- EXPECT_TRUE(gfx::test::IsEqual( |
- image, *GetCache()->GetGAIAPictureOfProfileAtIndex(index))); |
+ ProfileAttributesEntry* entry; |
+ ASSERT_TRUE( |
+ storage()->GetProfileAttributesWithPath(profile()->GetPath(), &entry)); |
+ EXPECT_EQ(name, entry->GetGAIAName()); |
+ EXPECT_EQ(given_name, entry->GetGAIAGivenName()); |
+ EXPECT_TRUE(gfx::test::IsEqual(image, *entry->GetGAIAPicture())); |
EXPECT_EQ(url, service()->GetCachedPictureURL()); |
EXPECT_EQ(Profile::kNoHostedDomainFound, profile()->GetPrefs()-> |
GetString(prefs::kGoogleServicesHostedDomain)); |
} |
TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) { |
- size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath()); |
- base::string16 old_name = GetCache()->GetNameOfProfileAtIndex(index); |
- gfx::Image old_image = GetCache()->GetAvatarIconOfProfileAtIndex(index); |
+ ProfileAttributesEntry* entry; |
+ ASSERT_TRUE( |
+ storage()->GetProfileAttributesWithPath(profile()->GetPath(), &entry)); |
+ base::string16 old_name = entry->GetName(); |
+ gfx::Image old_image = entry->GetAvatarIcon(); |
EXPECT_EQ(std::string(), service()->GetCachedPictureURL()); |
@@ -195,13 +208,11 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) { |
ProfileDownloaderDelegate::SERVICE_ERROR); |
// On failure nothing should be updated. |
- EXPECT_EQ(old_name, GetCache()->GetNameOfProfileAtIndex(index)); |
- EXPECT_EQ(base::string16(), GetCache()->GetGAIANameOfProfileAtIndex(index)); |
- EXPECT_EQ(base::string16(), |
- GetCache()->GetGAIAGivenNameOfProfileAtIndex(index)); |
- EXPECT_TRUE(gfx::test::IsEqual( |
- old_image, GetCache()->GetAvatarIconOfProfileAtIndex(index))); |
- EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(index)); |
+ EXPECT_EQ(old_name, entry->GetName()); |
+ EXPECT_EQ(base::string16(), entry->GetGAIAName()); |
+ EXPECT_EQ(base::string16(), entry->GetGAIAGivenName()); |
+ EXPECT_TRUE(gfx::test::IsEqual(old_image, entry->GetAvatarIcon())); |
+ EXPECT_EQ(NULL, entry->GetGAIAPicture()); |
EXPECT_EQ(std::string(), service()->GetCachedPictureURL()); |
EXPECT_EQ(std::string(), |
profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain)); |
@@ -222,46 +233,6 @@ TEST_F(GAIAInfoUpdateServiceTest, ProfileLockEnabledForWhitelist) { |
GetString(prefs::kGoogleServicesHostedDomain)); |
} |
-TEST_F(GAIAInfoUpdateServiceTest, HandlesProfileReordering) { |
- size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath()); |
- GetCache()->SetNameOfProfileAtIndex(index, FullName16("B")); |
- GetCache()->SetProfileIsUsingDefaultNameAtIndex(index, true); |
- |
- CreateProfile(FullName("A")); |
- CreateProfile(FullName("C")); |
- CreateProfile(FullName("E")); |
- |
- size_t index_before = |
- GetCache()->GetIndexOfProfileWithPath(profile()->GetPath()); |
- |
- // Rename our profile. |
- RenameProfile(FullName16("D"), GivenName16("D")); |
- // Profiles should have been reordered in the cache. |
- EXPECT_NE(index_before, |
- GetCache()->GetIndexOfProfileWithPath(profile()->GetPath())); |
- // Rename the profile back to the original name, it should go back to its |
- // original position. |
- RenameProfile(FullName16("B"), GivenName16("B")); |
- EXPECT_EQ(index_before, |
- GetCache()->GetIndexOfProfileWithPath(profile()->GetPath())); |
- |
- // Rename only the given name of our profile. |
- RenameProfile(FullName16("B"), GivenName16("D")); |
- // Rename the profile back to the original name, it should go back to its |
- // original position. |
- RenameProfile(FullName16("B"), GivenName16("B")); |
- EXPECT_EQ(index_before, |
- GetCache()->GetIndexOfProfileWithPath(profile()->GetPath())); |
- |
- // Rename only the full name of our profile. |
- RenameProfile(FullName16("D"), GivenName16("B")); |
- // Rename the profile back to the original name, it should go back to its |
- // original position. |
- RenameProfile(FullName16("B"), GivenName16("B")); |
- EXPECT_EQ(index_before, |
- GetCache()->GetIndexOfProfileWithPath(profile()->GetPath())); |
-} |
- |
TEST_F(GAIAInfoUpdateServiceTest, ShouldUseGAIAProfileInfo) { |
#if defined(OS_CHROMEOS) |
// This feature should never be enabled on ChromeOS. |
@@ -284,9 +255,12 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) { |
SigninManagerFactory::GetForProfile(profile()); |
signin_manager->SetAuthenticatedAccountInfo("gaia_id", "pat@example.com"); |
base::string16 gaia_name = base::UTF8ToUTF16("Pat Foo"); |
- GetCache()->SetGAIANameOfProfileAtIndex(0, gaia_name); |
+ ProfileAttributesEntry* entry; |
+ ASSERT_TRUE( |
+ storage()->GetProfileAttributesWithPath(profile()->GetPath(), &entry)); |
+ entry->SetGAIAName(gaia_name); |
gfx::Image gaia_picture = gfx::test::CreateImage(256,256); |
- GetCache()->SetGAIAPictureOfProfileAtIndex(0, &gaia_picture); |
+ entry->SetGAIAPicture(&gaia_picture); |
// Set a fake picture URL. |
profile()->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, |
@@ -297,8 +271,8 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) { |
// Log out. |
signin_manager->SignOut(signin_metrics::SIGNOUT_TEST); |
// Verify that the GAIA name and picture, and picture URL are unset. |
- EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty()); |
- EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); |
+ EXPECT_TRUE(entry->GetGAIAName().empty()); |
+ EXPECT_EQ(NULL, entry->GetGAIAPicture()); |
EXPECT_TRUE(service()->GetCachedPictureURL().empty()); |
} |