Commit cf4971dd authored by Jacques Chen's avatar Jacques Chen Committed by Commit Bot

Remove many profile avatars from Android (52kB)

-Profile avatar images not used on Android
-Removed all except one placeholder avatar icon
-Last avatar not removed due to having large part of
profiles code still being dependent on avatar icon code
-Configured some profile tests not to run on Android
-Removed profile_avatar_icon_util unit tests on Android

Bug: 799078
Change-Id: Ic7b726c3ac58f8f1f6b24c48d95ac81d08aa9eb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1652193Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Jacques Chen <jacqueschen@google.com>
Cr-Commit-Position: refs/heads/master@{#672084}
parent 8f7c4ee8
......@@ -184,33 +184,34 @@
</if>
<structure type="chrome_scaled_image" name="IDR_PRODUCT_LOGO_ENTERPRISE" file="google_chrome/product_logo_enterprise.png" />
</if>
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_0" file="common/profile_avatar_generic.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_1" file="common/profile_avatar_generic_aqua.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_2" file="common/profile_avatar_generic_blue.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_3" file="common/profile_avatar_generic_green.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_4" file="common/profile_avatar_generic_orange.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_5" file="common/profile_avatar_generic_purple.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_6" file="common/profile_avatar_generic_red.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_7" file="common/profile_avatar_generic_yellow.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_8" file="common/profile_avatar_secret_agent.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_9" file="common/profile_avatar_superhero.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_10" file="common/profile_avatar_volley_ball.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_11" file="common/profile_avatar_businessman.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_12" file="common/profile_avatar_ninja.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_13" file="common/profile_avatar_alien.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_14" file="common/profile_avatar_awesome.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_15" file="common/profile_avatar_flower.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_16" file="common/profile_avatar_pizza.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_17" file="common/profile_avatar_soccer.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_18" file="common/profile_avatar_burger.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_19" file="common/profile_avatar_cat.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_20" file="common/profile_avatar_cupcake.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_21" file="common/profile_avatar_dog.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_22" file="common/profile_avatar_horse.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_23" file="common/profile_avatar_margarita.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_24" file="common/profile_avatar_note.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_25" file="common/profile_avatar_sun_cloud.png" />
<if expr="not is_android">
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_0" file="common/profile_avatar_generic.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_1" file="common/profile_avatar_generic_aqua.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_2" file="common/profile_avatar_generic_blue.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_3" file="common/profile_avatar_generic_green.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_4" file="common/profile_avatar_generic_orange.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_5" file="common/profile_avatar_generic_purple.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_6" file="common/profile_avatar_generic_red.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_7" file="common/profile_avatar_generic_yellow.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_8" file="common/profile_avatar_secret_agent.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_9" file="common/profile_avatar_superhero.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_10" file="common/profile_avatar_volley_ball.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_11" file="common/profile_avatar_businessman.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_12" file="common/profile_avatar_ninja.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_13" file="common/profile_avatar_alien.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_14" file="common/profile_avatar_awesome.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_15" file="common/profile_avatar_flower.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_16" file="common/profile_avatar_pizza.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_17" file="common/profile_avatar_soccer.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_18" file="common/profile_avatar_burger.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_19" file="common/profile_avatar_cat.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_20" file="common/profile_avatar_cupcake.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_21" file="common/profile_avatar_dog.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_22" file="common/profile_avatar_horse.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_23" file="common/profile_avatar_margarita.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_24" file="common/profile_avatar_note.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_25" file="common/profile_avatar_sun_cloud.png" />
</if>
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_26" file="common/profile_avatar_placeholder.png" />
<if expr="not is_android and not chromeos">
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_27" file="common/modern_avatars/origami/avatar_cat.png" />
......
......@@ -654,6 +654,8 @@ TEST_F(ProfileAttributesStorageTest, ProfileForceSigninLock) {
ASSERT_FALSE(entry->IsSigninRequired());
}
// Avatar icons not used on Android.
#if !defined(OS_ANDROID)
TEST_F(ProfileAttributesStorageTest, AvatarIconIndex) {
AddTestingProfile();
......@@ -673,6 +675,7 @@ TEST_F(ProfileAttributesStorageTest, AvatarIconIndex) {
VerifyAndResetCallExpectations();
ASSERT_EQ(3U, entry->GetAvatarIconIndex());
}
#endif
// High res avatar downloading is only supported on desktop.
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
......
......@@ -260,17 +260,27 @@ constexpr char kGAIAPictureFileName[] = "Google Profile Picture.png";
constexpr char kHighResAvatarFolderName[] = "Avatars";
// The size of the function-static kDefaultAvatarIconResources array below.
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
constexpr size_t kDefaultAvatarIconsCount = 56;
#else
#if defined(OS_ANDROID)
constexpr size_t kDefaultAvatarIconsCount = 1;
#elif defined(OS_CHROMEOS)
constexpr size_t kDefaultAvatarIconsCount = 27;
#else
constexpr size_t kDefaultAvatarIconsCount = 56;
#endif
#if !defined(OS_ANDROID)
// The first 8 icons are generic.
constexpr size_t kGenericAvatarIconsCount = 8;
#else
constexpr size_t kGenericAvatarIconsCount = 0;
#endif
// The avatar used as a placeholder (grey silhouette).
#if !defined(OS_ANDROID)
// The avatar used as a placeholder.
constexpr size_t kPlaceholderAvatarIndex = 26;
#else
constexpr size_t kPlaceholderAvatarIndex = 0;
#endif
gfx::Image GetSizedAvatarIcon(const gfx::Image& image,
bool is_rectangle,
......@@ -388,7 +398,8 @@ std::string GetPlaceholderAvatarIconUrl() {
const IconResourceInfo* GetDefaultAvatarIconResourceInfo(size_t index) {
CHECK_LT(index, kDefaultAvatarIconsCount);
static const IconResourceInfo resource_info[kDefaultAvatarIconsCount] = {
// Old avatar icons:
// Old avatar icons:
#if !defined(OS_ANDROID)
{IDR_PROFILE_AVATAR_0, "avatar_generic.png", IDS_DEFAULT_AVATAR_LABEL_0},
{IDR_PROFILE_AVATAR_1, "avatar_generic_aqua.png",
IDS_DEFAULT_AVATAR_LABEL_1},
......@@ -427,7 +438,7 @@ const IconResourceInfo* GetDefaultAvatarIconResourceInfo(size_t index) {
{IDR_PROFILE_AVATAR_24, "avatar_note.png", IDS_DEFAULT_AVATAR_LABEL_24},
{IDR_PROFILE_AVATAR_25, "avatar_sun_cloud.png",
IDS_DEFAULT_AVATAR_LABEL_25},
#endif
// Placeholder avatar icon:
{IDR_PROFILE_AVATAR_26, NULL, -1},
......@@ -514,7 +525,9 @@ base::FilePath GetPathOfHighResAvatarAtIndex(size_t index) {
}
std::string GetDefaultAvatarIconUrl(size_t index) {
#if !defined(OS_ANDROID)
CHECK(IsDefaultAvatarIconIndex(index));
#endif
return base::StringPrintf("%s%" PRIuS, kDefaultUrlPrefix, index);
}
......
......@@ -131,16 +131,21 @@ void ProfileInfoCacheTest::ResetCache() {
TEST_F(ProfileInfoCacheTest, AddProfiles) {
EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
// Avatar icons not used on Android.
#if !defined(OS_ANDROID)
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
#endif
for (uint32_t i = 0; i < 4; ++i) {
base::FilePath profile_path =
GetProfilePath(base::StringPrintf("path_%ud", i));
base::string16 profile_name =
ASCIIToUTF16(base::StringPrintf("name_%ud", i));
#if !defined(OS_ANDROID)
const SkBitmap* icon = rb.GetImageNamed(
profiles::GetDefaultAvatarIconResourceIDAtIndex(
i)).ToSkBitmap();
#endif
std::string supervised_user_id = "";
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
if (i == 3)
......@@ -157,10 +162,12 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) {
EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles());
EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i));
#if !defined(OS_ANDROID)
const SkBitmap* actual_icon =
GetCache()->GetAvatarIconOfProfileAtIndex(i).ToSkBitmap();
EXPECT_EQ(icon->width(), actual_icon->width());
EXPECT_EQ(icon->height(), actual_icon->height());
#endif
EXPECT_EQ(i == 3, GetCache()->ProfileIsSupervisedAtIndex(i));
EXPECT_EQ(i == 3, GetCache()->IsOmittedProfileAtIndex(i));
EXPECT_EQ(supervised_user_id,
......@@ -178,7 +185,9 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) {
base::string16 profile_name =
ASCIIToUTF16(base::StringPrintf("name_%ud", i));
EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
#if !defined(OS_ANDROID)
EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i));
#endif
EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i));
base::string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i));
EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i));
......@@ -228,6 +237,8 @@ TEST_F(ProfileInfoCacheTest, MutateProfile) {
EXPECT_EQ(new_gaia_id, GetCache()->GetGAIAIdOfProfileAtIndex(1));
EXPECT_NE(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(0));
// Avatar icons not used on Android.
#if !defined(OS_ANDROID)
const size_t new_icon_index = 3;
GetCache()->SetAvatarIconOfProfileAtIndex(1, new_icon_index);
EXPECT_EQ(new_icon_index, GetCache()->GetAvatarIconIndexOfProfileAtIndex(1));
......@@ -239,6 +250,7 @@ TEST_F(ProfileInfoCacheTest, MutateProfile) {
GetCache()->SetAvatarIconOfProfileAtIndex(1, wrong_icon_index);
EXPECT_EQ(generic_icon_index,
GetCache()->GetAvatarIconIndexOfProfileAtIndex(1));
#endif
}
TEST_F(ProfileInfoCacheTest, Sort) {
......@@ -397,12 +409,15 @@ TEST_F(ProfileInfoCacheTest, GAIAPicture) {
GetCache()->SetProfileIsUsingDefaultAvatarAtIndex(1, false);
EXPECT_FALSE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1));
EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1));
// Avatar icons not used on Android.
#if !defined(OS_ANDROID)
int other_avatar_id =
profiles::GetDefaultAvatarIconResourceIDAtIndex(kOtherAvatarIndex);
const gfx::Image& other_avatar_image(
ui::ResourceBundle::GetSharedInstance().GetImageNamed(other_avatar_id));
EXPECT_TRUE(gfx::test::AreImagesEqual(
other_avatar_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
#endif
// Explicitly setting the GAIA picture should make it preferred again.
GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, true);
......@@ -418,8 +433,10 @@ TEST_F(ProfileInfoCacheTest, GAIAPicture) {
EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1));
EXPECT_TRUE(gfx::test::AreImagesEqual(
gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
#if !defined(OS_ANDROID)
EXPECT_TRUE(gfx::test::AreImagesEqual(
other_avatar_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
#endif
}
TEST_F(ProfileInfoCacheTest, PersistGAIAPicture) {
......
......@@ -3008,7 +3008,6 @@ test("unit_tests") {
"../browser/profiles/guest_mode_policy_handler_unittest.cc",
"../browser/profiles/incognito_mode_policy_handler_unittest.cc",
"../browser/profiles/profile_attributes_storage_unittest.cc",
"../browser/profiles/profile_avatar_icon_util_unittest.cc",
"../browser/profiles/profile_downloader_unittest.cc",
"../browser/profiles/profile_info_cache_unittest.cc",
"../browser/profiles/profile_info_cache_unittest.h",
......@@ -3202,6 +3201,7 @@ test("unit_tests") {
# CRLSets are not supported on Android or iOS, but available on all other
# platforms.
"../browser/component_updater/crl_set_component_installer_unittest.cc",
"../browser/profiles/profile_avatar_icon_util_unittest.cc",
"../browser/ui/autofill/payments/autofill_dialog_models_unittest.cc",
"../browser/ui/bookmarks/bookmark_editor_unittest.cc",
"../browser/ui/bookmarks/bookmark_ui_utils_desktop_unittest.cc",
......
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