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

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

Issue 8742009: Cache GAIA profile picture URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service.cc ('k') | chrome/browser/profiles/profile_downloader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 be1cd3e8d1225777f42d2dd4802e5e97968c91f5..ca9adc8bb057ac3f6580bc01d37d785ed6fc6a06 100644
--- a/chrome/browser/profiles/gaia_info_update_service_unittest.cc
+++ b/chrome/browser/profiles/gaia_info_update_service_unittest.cc
@@ -34,6 +34,9 @@ class ProfileDownloaderMock : public ProfileDownloader {
MOCK_CONST_METHOD0(GetProfileFullName, string16());
MOCK_CONST_METHOD0(GetProfilePicture, SkBitmap());
+ MOCK_CONST_METHOD0(GetProfilePictureStatus,
+ ProfileDownloader::PictureStatus());
+ MOCK_CONST_METHOD0(GetProfilePictureURL, std::string());
};
class GAIAInfoUpdateServiceMock : public GAIAInfoUpdateService {
@@ -74,6 +77,13 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) {
gfx::Image image = gfx::test::CreateImage();
SkBitmap bmp = image;
EXPECT_CALL(downloader, GetProfilePicture()).WillOnce(Return(bmp));
+ EXPECT_CALL(downloader, GetProfilePictureStatus()).
+ WillOnce(Return(ProfileDownloader::PICTURE_SUCCESS));
+ std::string url("foo.com");
+ EXPECT_CALL(downloader, GetProfilePictureURL()).WillOnce(Return(url));
+
+ // No URL should be cached yet.
+ EXPECT_EQ(std::string(), service.GetCachedPictureURL());
service.OnDownloadComplete(&downloader, true);
@@ -86,6 +96,7 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) {
image, GetCache()->GetAvatarIconOfProfileAtIndex(index)));
EXPECT_TRUE(gfx::test::IsEqual(
image, *GetCache()->GetGAIAPictureOfProfileAtIndex(index)));
+ EXPECT_EQ(url, service.GetCachedPictureURL());
}
TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
@@ -94,6 +105,7 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
gfx::Image old_image = GetCache()->GetAvatarIconOfProfileAtIndex(index);
GAIAInfoUpdateService service(profile());
+ EXPECT_EQ(std::string(), service.GetCachedPictureURL());
NiceMock<ProfileDownloaderMock> downloader(&service);
service.OnDownloadComplete(&downloader, false);
@@ -105,6 +117,7 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
EXPECT_TRUE(gfx::test::IsEqual(
old_image, GetCache()->GetAvatarIconOfProfileAtIndex(index)));
EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(index));
+ EXPECT_EQ(std::string(), service.GetCachedPictureURL());
}
TEST_F(GAIAInfoUpdateServiceTest, NoMigration) {
@@ -122,6 +135,9 @@ TEST_F(GAIAInfoUpdateServiceTest, NoMigration) {
gfx::Image new_image = gfx::test::CreateImage();
SkBitmap new_bmp = new_image;
EXPECT_CALL(downloader, GetProfilePicture()).WillOnce(Return(new_bmp));
+ EXPECT_CALL(downloader, GetProfilePictureStatus()).
+ WillOnce(Return(ProfileDownloader::PICTURE_SUCCESS));
+ EXPECT_CALL(downloader, GetProfilePictureURL()).WillOnce(Return(""));
service.OnDownloadComplete(&downloader, true);
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service.cc ('k') | chrome/browser/profiles/profile_downloader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698