| 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 4b95339b5dd20b09a7427b498d542fa1e97ec41a..1c7f697cfe2e0b3ca76b525a9550f3a555529ae1 100644
|
| --- a/chrome/browser/profiles/gaia_info_update_service_unittest.cc
|
| +++ b/chrome/browser/profiles/gaia_info_update_service_unittest.cc
|
| @@ -11,6 +11,8 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "build/build_config.h"
|
| #include "chrome/browser/browser_process.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"
|
| @@ -66,6 +68,7 @@ class GAIAInfoUpdateServiceMock : public GAIAInfoUpdateService {
|
| MOCK_METHOD0(Update, void());
|
| };
|
|
|
| +// TODO(anthonyvd) : remove ProfileInfoCacheTest from the test fixture.
|
| class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest {
|
| protected:
|
| GAIAInfoUpdateServiceTest() : profile_(NULL) {
|
| @@ -77,6 +80,10 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest {
|
| return profile_;
|
| }
|
|
|
| + ProfileAttributesStorage* storage() {
|
| + return testing_profile_manager_.profile_attributes_storage();
|
| + }
|
| +
|
| NiceMock<GAIAInfoUpdateServiceMock>* service() { return service_.get(); }
|
| NiceMock<ProfileDownloaderMock>* downloader() { return downloader_.get(); }
|
|
|
| @@ -91,8 +98,11 @@ 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 = nullptr;
|
| + // TODO(anthonyvd) : refactor the function so the following assertion can be
|
| + // changed to ASSERT_TRUE.
|
| + DCHECK(storage()->GetProfileAttributesWithPath(profile->GetPath(), &entry));
|
| + entry->SetIsUsingDefaultName(true);
|
| return profile;
|
| }
|
|
|
| @@ -180,20 +190,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::AreImagesEqual(
|
| - 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::AreImagesEqual(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());
|
|
|
| @@ -201,13 +214,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::AreImagesEqual(
|
| - 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::AreImagesEqual(old_image, entry->GetAvatarIcon()));
|
| + EXPECT_EQ(nullptr, entry->GetGAIAPicture());
|
| EXPECT_EQ(std::string(), service()->GetCachedPictureURL());
|
| EXPECT_EQ(std::string(),
|
| profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain));
|
| @@ -228,6 +239,8 @@ TEST_F(GAIAInfoUpdateServiceTest, ProfileLockEnabledForWhitelist) {
|
| GetString(prefs::kGoogleServicesHostedDomain));
|
| }
|
|
|
| +// TODO(anthonyvd) : remove or update test once the refactoring of the internals
|
| +// of ProfileInfoCache is complete.
|
| TEST_F(GAIAInfoUpdateServiceTest, HandlesProfileReordering) {
|
| size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath());
|
| GetCache()->SetNameOfProfileAtIndex(index, FullName16("B"));
|
| @@ -290,9 +303,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);
|
| +
|
| + ASSERT_EQ(1u, storage()->GetNumberOfProfiles());
|
| + ProfileAttributesEntry* entry = storage()->GetAllProfilesAttributes().front();
|
| + 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,
|
| @@ -304,8 +320,8 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) {
|
| signin_manager->SignOut(signin_metrics::SIGNOUT_TEST,
|
| signin_metrics::SignoutDelete::IGNORE_METRIC);
|
| // 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(nullptr, entry->GetGAIAPicture());
|
| EXPECT_TRUE(service()->GetCachedPictureURL().empty());
|
| }
|
|
|
|
|