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

Unified Diff: chrome/browser/profiles/gaia_info_update_service_unittest.cc

Issue 1913373002: Revert "Refactor ProfileInfoCache in most of c/b/profiles" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/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 1c7f697cfe2e0b3ca76b525a9550f3a555529ae1..4b95339b5dd20b09a7427b498d542fa1e97ec41a 100644
--- a/chrome/browser/profiles/gaia_info_update_service_unittest.cc
+++ b/chrome/browser/profiles/gaia_info_update_service_unittest.cc
@@ -11,8 +11,6 @@
#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"
@@ -68,7 +66,6 @@ class GAIAInfoUpdateServiceMock : public GAIAInfoUpdateService {
MOCK_METHOD0(Update, void());
};
-// TODO(anthonyvd) : remove ProfileInfoCacheTest from the test fixture.
class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest {
protected:
GAIAInfoUpdateServiceTest() : profile_(NULL) {
@@ -80,10 +77,6 @@ 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(); }
@@ -98,11 +91,8 @@ 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.
- 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);
+ size_t index = GetCache()->GetIndexOfProfileWithPath(profile->GetPath());
+ GetCache()->SetProfileIsUsingDefaultNameAtIndex(index, true);
return profile;
}
@@ -190,23 +180,20 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) {
ProfileDownloadSuccess(name, given_name, image, url, hosted_domain);
// On success the GAIA info should be updated.
- 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()));
+ 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)));
EXPECT_EQ(url, service()->GetCachedPictureURL());
EXPECT_EQ(Profile::kNoHostedDomainFound, profile()->GetPrefs()->
GetString(prefs::kGoogleServicesHostedDomain));
}
TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
- ProfileAttributesEntry* entry;
- ASSERT_TRUE(storage()->GetProfileAttributesWithPath(profile()->GetPath(),
- &entry));
- base::string16 old_name = entry->GetName();
- gfx::Image old_image = entry->GetAvatarIcon();
+ size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath());
+ base::string16 old_name = GetCache()->GetNameOfProfileAtIndex(index);
+ gfx::Image old_image = GetCache()->GetAvatarIconOfProfileAtIndex(index);
EXPECT_EQ(std::string(), service()->GetCachedPictureURL());
@@ -214,11 +201,13 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
ProfileDownloaderDelegate::SERVICE_ERROR);
// On failure nothing should be updated.
- 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(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(std::string(), service()->GetCachedPictureURL());
EXPECT_EQ(std::string(),
profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain));
@@ -239,8 +228,6 @@ 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"));
@@ -303,12 +290,9 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) {
SigninManagerFactory::GetForProfile(profile());
signin_manager->SetAuthenticatedAccountInfo("gaia_id", "pat@example.com");
base::string16 gaia_name = base::UTF8ToUTF16("Pat Foo");
-
- ASSERT_EQ(1u, storage()->GetNumberOfProfiles());
- ProfileAttributesEntry* entry = storage()->GetAllProfilesAttributes().front();
- entry->SetGAIAName(gaia_name);
+ GetCache()->SetGAIANameOfProfileAtIndex(0, gaia_name);
gfx::Image gaia_picture = gfx::test::CreateImage(256, 256);
- entry->SetGAIAPicture(&gaia_picture);
+ GetCache()->SetGAIAPictureOfProfileAtIndex(0, &gaia_picture);
// Set a fake picture URL.
profile()->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL,
@@ -320,8 +304,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(entry->GetGAIAName().empty());
- EXPECT_EQ(nullptr, entry->GetGAIAPicture());
+ EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty());
+ EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
EXPECT_TRUE(service()->GetCachedPictureURL().empty());
}
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service.cc ('k') | chrome/browser/profiles/profile_attributes_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698