Commit 87182d18 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Avoid conversion between GURL and std::string

ProfileDownloader::GetProfilePictureURL returns a std::string
corresponding to the representation of a GURL then immediately
converts it back to a GURL.

This is wasteful, so convert this method to return a GURL
instead and convert GetCachedPictureURL to also cache the
GURL instead of the string representation.

Convert static std::string to static char[] and use EXPECT_
instead of ASSERT_ macros when possible in unit tests (since
the EXPECT_ macro do not stop the test in case of failure).

Bug: none
Change-Id: Ibe73f28b38b2061b37cbdb0b9b0696b25ca8c41c
Reviewed-on: https://chromium-review.googlesource.com/1160645
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585426}
parent 44a15d72
...@@ -66,9 +66,7 @@ class AccountInfoRetriever : public ProfileDownloaderDelegate { ...@@ -66,9 +66,7 @@ class AccountInfoRetriever : public ProfileDownloaderDelegate {
return profile_; return profile_;
} }
std::string GetCachedPictureURL() const override { GURL GetCachedPictureURL() const override { return GURL(); }
return std::string();
}
bool IsPreSignin() const override { bool IsPreSignin() const override {
return is_pre_signin_; return is_pre_signin_;
......
...@@ -792,8 +792,8 @@ Profile* UserImageManagerImpl::GetBrowserProfile() { ...@@ -792,8 +792,8 @@ Profile* UserImageManagerImpl::GetBrowserProfile() {
return ProfileHelper::Get()->GetProfileByUserUnsafe(GetUser()); return ProfileHelper::Get()->GetProfileByUserUnsafe(GetUser());
} }
std::string UserImageManagerImpl::GetCachedPictureURL() const { GURL UserImageManagerImpl::GetCachedPictureURL() const {
return profile_image_url_.spec(); return profile_image_url_;
} }
bool UserImageManagerImpl::IsPreSignin() const { bool UserImageManagerImpl::IsPreSignin() const {
...@@ -855,7 +855,8 @@ void UserImageManagerImpl::OnProfileDownloadSuccess( ...@@ -855,7 +855,8 @@ void UserImageManagerImpl::OnProfileDownloadSuccess(
downloaded_profile_image_ = downloaded_profile_image_ =
gfx::ImageSkia::CreateFrom1xBitmap(downloader->GetProfilePicture()); gfx::ImageSkia::CreateFrom1xBitmap(downloader->GetProfilePicture());
profile_image_url_ = GURL(downloader->GetProfilePictureURL()); profile_image_url_ = downloader->GetProfilePictureURL();
DCHECK(profile_image_url_.is_valid());
if (user->image_index() == user_manager::User::USER_IMAGE_PROFILE) { if (user->image_index() == user_manager::User::USER_IMAGE_PROFILE) {
VLOG(1) << "Updating profile image for logged-in user."; VLOG(1) << "Updating profile image for logged-in user.";
......
...@@ -95,7 +95,7 @@ class UserImageManagerImpl : public UserImageManager, ...@@ -95,7 +95,7 @@ class UserImageManagerImpl : public UserImageManager,
bool NeedsProfilePicture() const override; bool NeedsProfilePicture() const override;
int GetDesiredImageSideLength() const override; int GetDesiredImageSideLength() const override;
Profile* GetBrowserProfile() override; Profile* GetBrowserProfile() override;
std::string GetCachedPictureURL() const override; GURL GetCachedPictureURL() const override;
bool IsPreSignin() const override; bool IsPreSignin() const override;
void OnProfileDownloadSuccess(ProfileDownloader* downloader) override; void OnProfileDownloadSuccess(ProfileDownloader* downloader) override;
void OnProfileDownloadFailure( void OnProfileDownloadFailure(
......
...@@ -86,8 +86,9 @@ Profile* GAIAInfoUpdateService::GetBrowserProfile() { ...@@ -86,8 +86,9 @@ Profile* GAIAInfoUpdateService::GetBrowserProfile() {
return profile_; return profile_;
} }
std::string GAIAInfoUpdateService::GetCachedPictureURL() const { GURL GAIAInfoUpdateService::GetCachedPictureURL() const {
return profile_->GetPrefs()->GetString(prefs::kProfileGAIAInfoPictureURL); return GURL(
profile_->GetPrefs()->GetString(prefs::kProfileGAIAInfoPictureURL));
} }
bool GAIAInfoUpdateService::IsPreSignin() const { bool GAIAInfoUpdateService::IsPreSignin() const {
...@@ -111,7 +112,8 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess( ...@@ -111,7 +112,8 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess(
SkBitmap bitmap = downloader->GetProfilePicture(); SkBitmap bitmap = downloader->GetProfilePicture();
ProfileDownloader::PictureStatus picture_status = ProfileDownloader::PictureStatus picture_status =
downloader->GetProfilePictureStatus(); downloader->GetProfilePictureStatus();
std::string picture_url = downloader->GetProfilePictureURL(); GURL picture_url = downloader->GetProfilePictureURL();
DCHECK(picture_url.is_valid());
ProfileAttributesEntry* entry; ProfileAttributesEntry* entry;
if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
...@@ -124,7 +126,7 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess( ...@@ -124,7 +126,7 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess(
if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { if (picture_status == ProfileDownloader::PICTURE_SUCCESS) {
profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL,
picture_url); picture_url.spec());
gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap); gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap);
entry->SetGAIAPicture(&gfx_image); entry->SetGAIAPicture(&gfx_image);
} else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) {
......
...@@ -38,7 +38,7 @@ class GAIAInfoUpdateService : public KeyedService, ...@@ -38,7 +38,7 @@ class GAIAInfoUpdateService : public KeyedService,
bool NeedsProfilePicture() const override; bool NeedsProfilePicture() const override;
int GetDesiredImageSideLength() const override; int GetDesiredImageSideLength() const override;
Profile* GetBrowserProfile() override; Profile* GetBrowserProfile() override;
std::string GetCachedPictureURL() const override; GURL GetCachedPictureURL() const override;
bool IsPreSignin() const override; bool IsPreSignin() const override;
void OnProfileDownloadSuccess(ProfileDownloader* downloader) override; void OnProfileDownloadSuccess(ProfileDownloader* downloader) override;
void OnProfileDownloadFailure( void OnProfileDownloadFailure(
......
...@@ -53,7 +53,7 @@ class ProfileDownloaderMock : public ProfileDownloader { ...@@ -53,7 +53,7 @@ class ProfileDownloaderMock : public ProfileDownloader {
MOCK_CONST_METHOD0(GetProfilePicture, SkBitmap()); MOCK_CONST_METHOD0(GetProfilePicture, SkBitmap());
MOCK_CONST_METHOD0(GetProfilePictureStatus, MOCK_CONST_METHOD0(GetProfilePictureStatus,
ProfileDownloader::PictureStatus()); ProfileDownloader::PictureStatus());
MOCK_CONST_METHOD0(GetProfilePictureURL, std::string()); MOCK_CONST_METHOD0(GetProfilePictureURL, GURL());
MOCK_CONST_METHOD0(GetProfileHostedDomain, base::string16()); MOCK_CONST_METHOD0(GetProfileHostedDomain, base::string16());
}; };
...@@ -120,12 +120,11 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest { ...@@ -120,12 +120,11 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest {
return base::UTF8ToUTF16(FullName(id)); return base::UTF8ToUTF16(FullName(id));
} }
void ProfileDownloadSuccess( void ProfileDownloadSuccess(const base::string16& full_name,
const base::string16& full_name, const base::string16& given_name,
const base::string16& given_name, const gfx::Image& image,
const gfx::Image& image, const GURL& url,
const std::string& url, const base::string16& hosted_domain) {
const base::string16& hosted_domain) {
EXPECT_CALL(*downloader(), GetProfileFullName()). EXPECT_CALL(*downloader(), GetProfileFullName()).
WillOnce(Return(full_name)); WillOnce(Return(full_name));
EXPECT_CALL(*downloader(), GetProfileGivenName()). EXPECT_CALL(*downloader(), GetProfileGivenName()).
...@@ -144,7 +143,7 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest { ...@@ -144,7 +143,7 @@ class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest {
void RenameProfile(const base::string16& full_name, void RenameProfile(const base::string16& full_name,
const base::string16& given_name) { const base::string16& given_name) {
gfx::Image image = gfx::test::CreateImage(256, 256); gfx::Image image = gfx::test::CreateImage(256, 256);
std::string url("foo.com"); GURL url("https://foo.com");
ProfileDownloadSuccess(full_name, given_name, image, url, base::string16()); ProfileDownloadSuccess(full_name, given_name, image, url, base::string16());
// Make sure the right profile was updated correctly. // Make sure the right profile was updated correctly.
...@@ -181,14 +180,14 @@ void GAIAInfoUpdateServiceTest::TearDown() { ...@@ -181,14 +180,14 @@ void GAIAInfoUpdateServiceTest::TearDown() {
TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) { TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) {
// No URL should be cached yet. // No URL should be cached yet.
EXPECT_EQ(std::string(), service()->GetCachedPictureURL()); EXPECT_TRUE(service()->GetCachedPictureURL().is_empty());
EXPECT_EQ(std::string(), profile()->GetPrefs()-> EXPECT_EQ(std::string(), profile()->GetPrefs()->
GetString(prefs::kGoogleServicesHostedDomain)); GetString(prefs::kGoogleServicesHostedDomain));
base::string16 name = base::ASCIIToUTF16("Pat Smith"); base::string16 name = base::ASCIIToUTF16("Pat Smith");
base::string16 given_name = base::ASCIIToUTF16("Pat"); base::string16 given_name = base::ASCIIToUTF16("Pat");
gfx::Image image = gfx::test::CreateImage(256, 256); gfx::Image image = gfx::test::CreateImage(256, 256);
std::string url("foo.com"); GURL url("https://foo.com");
base::string16 hosted_domain(base::ASCIIToUTF16("")); base::string16 hosted_domain(base::ASCIIToUTF16(""));
ProfileDownloadSuccess(name, given_name, image, url, hosted_domain); ProfileDownloadSuccess(name, given_name, image, url, hosted_domain);
...@@ -212,7 +211,7 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) { ...@@ -212,7 +211,7 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
base::string16 old_name = entry->GetName(); base::string16 old_name = entry->GetName();
gfx::Image old_image = entry->GetAvatarIcon(); gfx::Image old_image = entry->GetAvatarIcon();
EXPECT_EQ(std::string(), service()->GetCachedPictureURL()); EXPECT_TRUE(service()->GetCachedPictureURL().is_empty());
service()->OnProfileDownloadFailure(downloader(), service()->OnProfileDownloadFailure(downloader(),
ProfileDownloaderDelegate::SERVICE_ERROR); ProfileDownloaderDelegate::SERVICE_ERROR);
...@@ -223,19 +222,19 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) { ...@@ -223,19 +222,19 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
EXPECT_EQ(base::string16(), entry->GetGAIAGivenName()); EXPECT_EQ(base::string16(), entry->GetGAIAGivenName());
EXPECT_TRUE(gfx::test::AreImagesEqual(old_image, entry->GetAvatarIcon())); EXPECT_TRUE(gfx::test::AreImagesEqual(old_image, entry->GetAvatarIcon()));
EXPECT_EQ(nullptr, entry->GetGAIAPicture()); EXPECT_EQ(nullptr, entry->GetGAIAPicture());
EXPECT_EQ(std::string(), service()->GetCachedPictureURL()); EXPECT_TRUE(service()->GetCachedPictureURL().is_empty());
EXPECT_EQ(std::string(), EXPECT_EQ(std::string(),
profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain)); profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain));
} }
TEST_F(GAIAInfoUpdateServiceTest, ProfileLockEnabledForWhitelist) { TEST_F(GAIAInfoUpdateServiceTest, ProfileLockEnabledForWhitelist) {
// No URL should be cached yet. // No URL should be cached yet.
EXPECT_EQ(std::string(), service()->GetCachedPictureURL()); EXPECT_TRUE(service()->GetCachedPictureURL().is_empty());
base::string16 name = base::ASCIIToUTF16("Pat Smith"); base::string16 name = base::ASCIIToUTF16("Pat Smith");
base::string16 given_name = base::ASCIIToUTF16("Pat"); base::string16 given_name = base::ASCIIToUTF16("Pat");
gfx::Image image = gfx::test::CreateImage(256, 256); gfx::Image image = gfx::test::CreateImage(256, 256);
std::string url("foo.com"); GURL url("https://foo.com");
base::string16 hosted_domain(base::ASCIIToUTF16("google.com")); base::string16 hosted_domain(base::ASCIIToUTF16("google.com"));
ProfileDownloadSuccess(name, given_name, image, url, hosted_domain); ProfileDownloadSuccess(name, given_name, image, url, hosted_domain);
...@@ -316,9 +315,9 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) { ...@@ -316,9 +315,9 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) {
// Set a fake picture URL. // Set a fake picture URL.
profile()->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, profile()->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL,
"example.com"); "https://example.com");
EXPECT_FALSE(service()->GetCachedPictureURL().empty()); EXPECT_FALSE(service()->GetCachedPictureURL().is_empty());
// Log out. // Log out.
identity::ClearPrimaryAccount( identity::ClearPrimaryAccount(
...@@ -327,7 +326,7 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) { ...@@ -327,7 +326,7 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) {
// Verify that the GAIA name and picture, and picture URL are unset. // Verify that the GAIA name and picture, and picture URL are unset.
EXPECT_TRUE(entry->GetGAIAName().empty()); EXPECT_TRUE(entry->GetGAIAName().empty());
EXPECT_EQ(nullptr, entry->GetGAIAPicture()); EXPECT_EQ(nullptr, entry->GetGAIAPicture());
EXPECT_TRUE(service()->GetCachedPictureURL().empty()); EXPECT_TRUE(service()->GetCachedPictureURL().is_empty());
} }
TEST_F(GAIAInfoUpdateServiceTest, LogIn) { TEST_F(GAIAInfoUpdateServiceTest, LogIn) {
......
...@@ -107,14 +107,12 @@ ProfileDownloader::PictureStatus ProfileDownloader::GetProfilePictureStatus() ...@@ -107,14 +107,12 @@ ProfileDownloader::PictureStatus ProfileDownloader::GetProfilePictureStatus()
return picture_status_; return picture_status_;
} }
std::string ProfileDownloader::GetProfilePictureURL() const { GURL ProfileDownloader::GetProfilePictureURL() const {
GURL url(account_info_.picture_url); const GURL url(account_info_.picture_url);
if (!url.is_valid()) if (!url.is_valid())
return std::string(); return GURL();
return signin::GetAvatarImageURLWithOptions( return signin::GetAvatarImageURLWithOptions(
GURL(account_info_.picture_url), url, delegate_->GetDesiredImageSideLength(), true /* no_silhouette */);
delegate_->GetDesiredImageSideLength(), true /* no_silhouette */)
.spec();
} }
void ProfileDownloader::StartFetchingImage() { void ProfileDownloader::StartFetchingImage() {
...@@ -172,16 +170,15 @@ void ProfileDownloader::FetchImageData() { ...@@ -172,16 +170,15 @@ void ProfileDownloader::FetchImageData() {
return; return;
} }
std::string image_url_with_size = GetProfilePictureURL(); GURL image_url_to_fetch = GetProfilePictureURL();
if (!image_url_with_size.empty() && if (image_url_to_fetch.is_valid() &&
image_url_with_size == delegate_->GetCachedPictureURL()) { image_url_to_fetch == delegate_->GetCachedPictureURL()) {
VLOG(1) << "Picture URL matches cached picture URL"; VLOG(1) << "Picture URL matches cached picture URL";
picture_status_ = PICTURE_CACHED; picture_status_ = PICTURE_CACHED;
delegate_->OnProfileDownloadSuccess(this); delegate_->OnProfileDownloadSuccess(this);
return; return;
} }
GURL image_url_to_fetch(image_url_with_size);
if (!image_url_to_fetch.is_valid()) { if (!image_url_to_fetch.is_valid()) {
VLOG(1) << "Profile picture URL with size |" << image_url_to_fetch << "| " VLOG(1) << "Profile picture URL with size |" << image_url_to_fetch << "| "
<< "is not valid (the account picture URL is " << "is not valid (the account picture URL is "
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
namespace identity { namespace identity {
class PrimaryAccountAccessTokenFetcher; class PrimaryAccountAccessTokenFetcher;
} }
class GURL;
class ProfileDownloaderDelegate; class ProfileDownloaderDelegate;
// Downloads user profile information. The profile picture is decoded in a // Downloads user profile information. The profile picture is decoded in a
...@@ -76,7 +77,7 @@ class ProfileDownloader : public ImageDecoder::ImageRequest, ...@@ -76,7 +77,7 @@ class ProfileDownloader : public ImageDecoder::ImageRequest,
// Gets the URL for the profile picture. This can be cached so that the same // Gets the URL for the profile picture. This can be cached so that the same
// picture is not downloaded multiple times. This value should only be used // picture is not downloaded multiple times. This value should only be used
// when the picture status is PICTURE_SUCCESS. // when the picture status is PICTURE_SUCCESS.
virtual std::string GetProfilePictureURL() const; virtual GURL GetProfilePictureURL() const;
private: private:
friend class ProfileDownloaderTest; friend class ProfileDownloaderTest;
......
...@@ -35,9 +35,9 @@ class ProfileDownloaderDelegate { ...@@ -35,9 +35,9 @@ class ProfileDownloaderDelegate {
virtual int GetDesiredImageSideLength() const = 0; virtual int GetDesiredImageSideLength() const = 0;
// Returns the cached URL. If the cache URL matches the new image URL // Returns the cached URL. If the cache URL matches the new image URL
// the image will not be downloaded. Return an empty string when there is no // the image will not be downloaded. Return an empty URL when there is no
// cached URL. // cached URL.
virtual std::string GetCachedPictureURL() const = 0; virtual GURL GetCachedPictureURL() const = 0;
// Returns the browser profile associated with this download request. // Returns the browser profile associated with this download request.
virtual Profile* GetBrowserProfile() = 0; virtual Profile* GetBrowserProfile() = 0;
......
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
namespace { namespace {
const std::string kTestEmail = "test@example.com"; const char kTestEmail[] = "test@example.com";
const std::string kTestGaia = "gaia"; const char kTestGaia[] = "gaia";
const std::string kTestHostedDomain = "google.com"; const char kTestHostedDomain[] = "google.com";
const std::string kTestFullName = "full_name"; const char kTestFullName[] = "full_name";
const std::string kTestGivenName = "given_name"; const char kTestGivenName[] = "given_name";
const std::string kTestLocale = "locale"; const char kTestLocale[] = "locale";
const std::string kTestValidPictureURL = "http://www.google.com/"; const char kTestValidPictureURL[] = "http://www.google.com/";
const std::string kTestInvalidPictureURL = "invalid_picture_url"; const char kTestInvalidPictureURL[] = "invalid_picture_url";
} // namespace } // namespace
...@@ -57,7 +57,7 @@ class ProfileDownloaderTest : public testing::Test, ...@@ -57,7 +57,7 @@ class ProfileDownloaderTest : public testing::Test,
bool NeedsProfilePicture() const override { return true; }; bool NeedsProfilePicture() const override { return true; };
int GetDesiredImageSideLength() const override { return 128; }; int GetDesiredImageSideLength() const override { return 128; };
std::string GetCachedPictureURL() const override { return ""; }; GURL GetCachedPictureURL() const override { return GURL(); };
Profile* GetBrowserProfile() override { return profile_.get(); }; Profile* GetBrowserProfile() override { return profile_.get(); };
bool IsPreSignin() const override { return false; } bool IsPreSignin() const override { return false; }
void OnProfileDownloadSuccess(ProfileDownloader* downloader) override { void OnProfileDownloadSuccess(ProfileDownloader* downloader) override {
...@@ -87,23 +87,25 @@ TEST_F(ProfileDownloaderTest, AccountInfoReady) { ...@@ -87,23 +87,25 @@ TEST_F(ProfileDownloaderTest, AccountInfoReady) {
account_tracker_service_->SeedAccountInfo(kTestGaia, kTestEmail); account_tracker_service_->SeedAccountInfo(kTestGaia, kTestEmail);
SimulateUserInfoSuccess(kTestValidPictureURL); SimulateUserInfoSuccess(kTestValidPictureURL);
ASSERT_EQ(ProfileDownloader::PICTURE_FAILED, EXPECT_EQ(ProfileDownloader::PICTURE_FAILED,
profile_downloader_->GetProfilePictureStatus()); profile_downloader_->GetProfilePictureStatus());
profile_downloader_->StartForAccount(account_id); profile_downloader_->StartForAccount(account_id);
profile_downloader_->StartFetchingImage(); profile_downloader_->StartFetchingImage();
ASSERT_EQ(kTestValidPictureURL, profile_downloader_->GetProfilePictureURL()); EXPECT_EQ(GURL(kTestValidPictureURL),
profile_downloader_->GetProfilePictureURL());
} }
TEST_F(ProfileDownloaderTest, AccountInfoNotReady) { TEST_F(ProfileDownloaderTest, AccountInfoNotReady) {
std::string account_id = std::string account_id =
account_tracker_service_->SeedAccountInfo(kTestGaia, kTestEmail); account_tracker_service_->SeedAccountInfo(kTestGaia, kTestEmail);
ASSERT_EQ(ProfileDownloader::PICTURE_FAILED, EXPECT_EQ(ProfileDownloader::PICTURE_FAILED,
profile_downloader_->GetProfilePictureStatus()); profile_downloader_->GetProfilePictureStatus());
profile_downloader_->StartForAccount(account_id); profile_downloader_->StartForAccount(account_id);
profile_downloader_->StartFetchingImage(); profile_downloader_->StartFetchingImage();
SimulateUserInfoSuccess(kTestValidPictureURL); SimulateUserInfoSuccess(kTestValidPictureURL);
ASSERT_EQ(kTestValidPictureURL, profile_downloader_->GetProfilePictureURL()); EXPECT_EQ(GURL(kTestValidPictureURL),
profile_downloader_->GetProfilePictureURL());
} }
// Regression test for http://crbug.com/854907 // Regression test for http://crbug.com/854907
...@@ -115,8 +117,8 @@ TEST_F(ProfileDownloaderTest, AccountInfoNoPictureDoesNotCrash) { ...@@ -115,8 +117,8 @@ TEST_F(ProfileDownloaderTest, AccountInfoNoPictureDoesNotCrash) {
profile_downloader_->StartForAccount(account_id); profile_downloader_->StartForAccount(account_id);
profile_downloader_->StartFetchingImage(); profile_downloader_->StartFetchingImage();
EXPECT_TRUE(profile_downloader_->GetProfilePictureURL().empty()); EXPECT_FALSE(profile_downloader_->GetProfilePictureURL().is_valid());
ASSERT_EQ(ProfileDownloader::PICTURE_DEFAULT, EXPECT_EQ(ProfileDownloader::PICTURE_DEFAULT,
profile_downloader_->GetProfilePictureStatus()); profile_downloader_->GetProfilePictureStatus());
} }
...@@ -129,7 +131,7 @@ TEST_F(ProfileDownloaderTest, AccountInfoInvalidPictureURLDoesNotCrash) { ...@@ -129,7 +131,7 @@ TEST_F(ProfileDownloaderTest, AccountInfoInvalidPictureURLDoesNotCrash) {
profile_downloader_->StartForAccount(account_id); profile_downloader_->StartForAccount(account_id);
profile_downloader_->StartFetchingImage(); profile_downloader_->StartFetchingImage();
EXPECT_TRUE(profile_downloader_->GetProfilePictureURL().empty()); EXPECT_FALSE(profile_downloader_->GetProfilePictureURL().is_valid());
ASSERT_EQ(ProfileDownloader::PICTURE_FAILED, EXPECT_EQ(ProfileDownloader::PICTURE_FAILED,
profile_downloader_->GetProfilePictureStatus()); profile_downloader_->GetProfilePictureStatus());
} }
...@@ -54,8 +54,8 @@ int CustodianProfileDownloaderService::GetDesiredImageSideLength() const { ...@@ -54,8 +54,8 @@ int CustodianProfileDownloaderService::GetDesiredImageSideLength() const {
return 0; return 0;
} }
std::string CustodianProfileDownloaderService::GetCachedPictureURL() const { GURL CustodianProfileDownloaderService::GetCachedPictureURL() const {
return std::string(); return GURL();
} }
Profile* CustodianProfileDownloaderService::GetBrowserProfile() { Profile* CustodianProfileDownloaderService::GetBrowserProfile() {
......
...@@ -33,7 +33,7 @@ class CustodianProfileDownloaderService : public KeyedService, ...@@ -33,7 +33,7 @@ class CustodianProfileDownloaderService : public KeyedService,
// ProfileDownloaderDelegate: // ProfileDownloaderDelegate:
bool NeedsProfilePicture() const override; bool NeedsProfilePicture() const override;
int GetDesiredImageSideLength() const override; int GetDesiredImageSideLength() const override;
std::string GetCachedPictureURL() const override; GURL GetCachedPictureURL() const override;
Profile* GetBrowserProfile() override; Profile* GetBrowserProfile() override;
bool IsPreSignin() const override; bool IsPreSignin() const override;
void OnProfileDownloadSuccess(ProfileDownloader* downloader) override; void OnProfileDownloadSuccess(ProfileDownloader* downloader) override;
......
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