Commit 102f1058 authored by nancylingwang's avatar nancylingwang Committed by Commit Bot

Disable the adaptive icon feature for M87

Fix unit tests when the flag is disabled.

BUG=1083331

Change-Id: Ic4cdc5a089ca672b4a79b345eff18ebcb4ccd82b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442989Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813027}
parent cca2bfcf
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/arc/icon_decode_request.h" #include "chrome/browser/chromeos/arc/icon_decode_request.h"
#include "chrome/browser/ui/app_list/icon_standardizer.h" #include "chrome/browser/ui/app_list/icon_standardizer.h"
#include "chrome/browser/ui/app_list/md_icon_normalizer.h"
#include "chrome/grit/chrome_unscaled_resources.h" #include "chrome/grit/chrome_unscaled_resources.h"
#include "components/arc/mojom/intent_helper.mojom.h" #include "components/arc/mojom/intent_helper.mojom.h"
#endif #endif
...@@ -612,6 +613,7 @@ class WebAppIconFactoryTest : public ChromeRenderViewHostTestHarness { ...@@ -612,6 +613,7 @@ class WebAppIconFactoryTest : public ChromeRenderViewHostTestHarness {
run_loop.QuitClosure())); run_loop.QuitClosure()));
run_loop.Run(); run_loop.Run();
extensions::ChromeAppIcon::ResizeFunction resize_function;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) { if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
if (purpose == IconPurpose::ANY) { if (purpose == IconPurpose::ANY) {
...@@ -621,13 +623,16 @@ class WebAppIconFactoryTest : public ChromeRenderViewHostTestHarness { ...@@ -621,13 +623,16 @@ class WebAppIconFactoryTest : public ChromeRenderViewHostTestHarness {
if (purpose == IconPurpose::MASKABLE) { if (purpose == IconPurpose::MASKABLE) {
output_image_skia = apps::ApplyBackgroundAndMask(output_image_skia); output_image_skia = apps::ApplyBackgroundAndMask(output_image_skia);
} }
} else {
resize_function =
base::BindRepeating(&app_list::MaybeResizeAndPadIconForMd);
} }
#endif #endif
extensions::ChromeAppIcon::ApplyEffects( extensions::ChromeAppIcon::ApplyEffects(
kSizeInDip, extensions::ChromeAppIcon::ResizeFunction(), kSizeInDip, resize_function, true /* app_launchable */,
true /* app_launchable */, true /* from_bookmark */, true /* from_bookmark */, extensions::ChromeAppIcon::Badge::kNone,
extensions::ChromeAppIcon::Badge::kNone, &output_image_skia); &output_image_skia);
EnsureRepresentationsLoaded(output_image_skia); EnsureRepresentationsLoaded(output_image_skia);
} }
...@@ -729,10 +734,17 @@ TEST_F(WebAppIconFactoryTest, LoadNonMaskableIcon) { ...@@ -729,10 +734,17 @@ TEST_F(WebAppIconFactoryTest, LoadNonMaskableIcon) {
{{1.0, kIconSize1}, {2.0, kIconSize2}}, src_image_skia); {{1.0, kIconSize1}, {2.0, kIconSize2}}, src_image_skia);
gfx::ImageSkia dst_image_skia; gfx::ImageSkia dst_image_skia;
LoadIconFromWebApp( apps::IconEffects icon_effect = apps::IconEffects::kRoundCorners;
app_id,
apps::IconEffects::kRoundCorners | apps::IconEffects::kCrOsStandardIcon, #if defined(OS_CHROMEOS)
dst_image_skia); if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
icon_effect |= apps::IconEffects::kCrOsStandardIcon;
} else {
icon_effect |= apps::IconEffects::kResizeAndPad;
}
#endif
LoadIconFromWebApp(app_id, icon_effect, dst_image_skia);
VerifyIcon(src_image_skia, dst_image_skia); VerifyIcon(src_image_skia, dst_image_skia);
} }
...@@ -758,10 +770,17 @@ TEST_F(WebAppIconFactoryTest, LoadNonMaskableCompressedIcon) { ...@@ -758,10 +770,17 @@ TEST_F(WebAppIconFactoryTest, LoadNonMaskableCompressedIcon) {
src_data); src_data);
apps::mojom::IconValuePtr icon; apps::mojom::IconValuePtr icon;
LoadCompressedIconBlockingFromWebApp( apps::IconEffects icon_effect = apps::IconEffects::kRoundCorners;
app_id,
apps::IconEffects::kRoundCorners | apps::IconEffects::kCrOsStandardIcon, #if defined(OS_CHROMEOS)
icon); if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
icon_effect |= apps::IconEffects::kCrOsStandardIcon;
} else {
icon_effect |= apps::IconEffects::kResizeAndPad;
}
#endif
LoadCompressedIconBlockingFromWebApp(app_id, icon_effect, icon);
VerifyCompressedIcon(src_data, icon); VerifyCompressedIcon(src_data, icon);
} }
...@@ -783,20 +802,25 @@ TEST_F(WebAppIconFactoryTest, LoadMaskableIcon) { ...@@ -783,20 +802,25 @@ TEST_F(WebAppIconFactoryTest, LoadMaskableIcon) {
RegisterApp(std::move(web_app)); RegisterApp(std::move(web_app));
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
ASSERT_TRUE( if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
icon_manager().HasIcons(app_id, IconPurpose::MASKABLE, {kIconSize2})); ASSERT_TRUE(
icon_manager().HasIcons(app_id, IconPurpose::MASKABLE, {kIconSize2}));
gfx::ImageSkia src_image_skia;
GenerateWebAppIcon(app_id, IconPurpose::MASKABLE, {kIconSize2}, gfx::ImageSkia src_image_skia;
{{1.0, kIconSize2}, {2.0, kIconSize2}}, src_image_skia); GenerateWebAppIcon(app_id, IconPurpose::MASKABLE, {kIconSize2},
{{1.0, kIconSize2}, {2.0, kIconSize2}}, src_image_skia);
gfx::ImageSkia dst_image_skia;
LoadIconFromWebApp(app_id,
apps::IconEffects::kRoundCorners |
apps::IconEffects::kCrOsStandardBackground |
apps::IconEffects::kCrOsStandardMask,
dst_image_skia);
VerifyIcon(src_image_skia, dst_image_skia);
return;
}
#endif
gfx::ImageSkia dst_image_skia;
LoadIconFromWebApp(app_id,
apps::IconEffects::kRoundCorners |
apps::IconEffects::kCrOsStandardBackground |
apps::IconEffects::kCrOsStandardMask,
dst_image_skia);
#else
ASSERT_TRUE(icon_manager().HasIcons(app_id, IconPurpose::ANY, {kIconSize1})); ASSERT_TRUE(icon_manager().HasIcons(app_id, IconPurpose::ANY, {kIconSize1}));
gfx::ImageSkia src_image_skia; gfx::ImageSkia src_image_skia;
...@@ -805,7 +829,6 @@ TEST_F(WebAppIconFactoryTest, LoadMaskableIcon) { ...@@ -805,7 +829,6 @@ TEST_F(WebAppIconFactoryTest, LoadMaskableIcon) {
gfx::ImageSkia dst_image_skia; gfx::ImageSkia dst_image_skia;
LoadIconFromWebApp(app_id, apps::IconEffects::kRoundCorners, dst_image_skia); LoadIconFromWebApp(app_id, apps::IconEffects::kRoundCorners, dst_image_skia);
#endif
VerifyIcon(src_image_skia, dst_image_skia); VerifyIcon(src_image_skia, dst_image_skia);
} }
...@@ -828,30 +851,33 @@ TEST_F(WebAppIconFactoryTest, LoadMaskableCompressedIcon) { ...@@ -828,30 +851,33 @@ TEST_F(WebAppIconFactoryTest, LoadMaskableCompressedIcon) {
std::vector<uint8_t> src_data; std::vector<uint8_t> src_data;
apps::mojom::IconValuePtr icon; apps::mojom::IconValuePtr icon;
apps::IconEffects icon_effect = apps::IconEffects::kRoundCorners;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
ASSERT_TRUE( if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
icon_manager().HasIcons(app_id, IconPurpose::MASKABLE, {kIconSize2})); icon_effect |= apps::IconEffects::kCrOsStandardBackground |
apps::IconEffects::kCrOsStandardMask;
ASSERT_TRUE(
icon_manager().HasIcons(app_id, IconPurpose::MASKABLE, {kIconSize2}));
GenerateWebAppCompressedIcon(app_id, IconPurpose::MASKABLE, {kIconSize2}, GenerateWebAppCompressedIcon(app_id, IconPurpose::MASKABLE, {kIconSize2},
{{1.0, kIconSize2}, {2.0, kIconSize2}}, {{1.0, kIconSize2}, {2.0, kIconSize2}},
src_data); src_data);
LoadCompressedIconBlockingFromWebApp(app_id, icon_effect, icon);
VerifyCompressedIcon(src_data, icon);
return;
}
icon_effect |= apps::IconEffects::kResizeAndPad;
#endif
LoadCompressedIconBlockingFromWebApp(
app_id,
apps::IconEffects::kRoundCorners |
apps::IconEffects::kCrOsStandardBackground |
apps::IconEffects::kCrOsStandardMask,
icon);
#else
ASSERT_TRUE(icon_manager().HasIcons(app_id, IconPurpose::ANY, {kIconSize1})); ASSERT_TRUE(icon_manager().HasIcons(app_id, IconPurpose::ANY, {kIconSize1}));
GenerateWebAppCompressedIcon(app_id, IconPurpose::ANY, {kIconSize1}, GenerateWebAppCompressedIcon(app_id, IconPurpose::ANY, {kIconSize1},
{{1.0, kIconSize1}, {2.0, kIconSize1}}, {{1.0, kIconSize1}, {2.0, kIconSize1}},
src_data); src_data);
LoadCompressedIconBlockingFromWebApp(app_id, apps::IconEffects::kRoundCorners, LoadCompressedIconBlockingFromWebApp(app_id, icon_effect, icon);
icon);
#endif
VerifyCompressedIcon(src_data, icon); VerifyCompressedIcon(src_data, icon);
} }
...@@ -879,10 +905,17 @@ TEST_F(WebAppIconFactoryTest, LoadNonMaskableIconWithMaskableIcon) { ...@@ -879,10 +905,17 @@ TEST_F(WebAppIconFactoryTest, LoadNonMaskableIconWithMaskableIcon) {
{{1.0, kIconSize2}, {2.0, kIconSize2}}, src_image_skia); {{1.0, kIconSize2}, {2.0, kIconSize2}}, src_image_skia);
gfx::ImageSkia dst_image_skia; gfx::ImageSkia dst_image_skia;
LoadIconFromWebApp( apps::IconEffects icon_effect = apps::IconEffects::kRoundCorners;
app_id,
apps::IconEffects::kRoundCorners | apps::IconEffects::kCrOsStandardIcon, #if defined(OS_CHROMEOS)
dst_image_skia); if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
icon_effect |= apps::IconEffects::kCrOsStandardIcon;
} else {
icon_effect |= apps::IconEffects::kResizeAndPad;
}
#endif
LoadIconFromWebApp(app_id, icon_effect, dst_image_skia);
VerifyIcon(src_image_skia, dst_image_skia); VerifyIcon(src_image_skia, dst_image_skia);
} }
...@@ -944,10 +977,17 @@ TEST_F(WebAppIconFactoryTest, LoadExactSizeIcon) { ...@@ -944,10 +977,17 @@ TEST_F(WebAppIconFactoryTest, LoadExactSizeIcon) {
{{1.0, kIconSize2}, {2.0, kIconSize4}}, src_image_skia); {{1.0, kIconSize2}, {2.0, kIconSize4}}, src_image_skia);
gfx::ImageSkia dst_image_skia; gfx::ImageSkia dst_image_skia;
LoadIconFromWebApp( apps::IconEffects icon_effect = apps::IconEffects::kRoundCorners;
app_id,
apps::IconEffects::kRoundCorners | apps::IconEffects::kCrOsStandardIcon, #if defined(OS_CHROMEOS)
dst_image_skia); if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
icon_effect |= apps::IconEffects::kCrOsStandardIcon;
} else {
icon_effect |= apps::IconEffects::kResizeAndPad;
}
#endif
LoadIconFromWebApp(app_id, icon_effect, dst_image_skia);
VerifyIcon(src_image_skia, dst_image_skia); VerifyIcon(src_image_skia, dst_image_skia);
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "chrome/browser/ui/app_list/chrome_app_list_item.h" #include "chrome/browser/ui/app_list/chrome_app_list_item.h"
#include "chrome/browser/ui/app_list/icon_standardizer.h" #include "chrome/browser/ui/app_list/icon_standardizer.h"
#include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h"
#include "chrome/browser/ui/app_list/md_icon_normalizer.h"
#include "chrome/browser/ui/app_list/test/fake_app_list_model_updater.h" #include "chrome/browser/ui/app_list/test/fake_app_list_model_updater.h"
#include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h" #include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
...@@ -281,8 +282,15 @@ class ExtensionAppTest : public AppServiceAppModelBuilderTest { ...@@ -281,8 +282,15 @@ class ExtensionAppTest : public AppServiceAppModelBuilderTest {
&output_image_skia, run_loop.QuitClosure())); &output_image_skia, run_loop.QuitClosure()));
run_loop.Run(); run_loop.Run();
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
output_image_skia = app_list::CreateStandardIconImage(output_image_skia); output_image_skia = app_list::CreateStandardIconImage(output_image_skia);
} else {
extensions::ChromeAppIcon::ApplyEffects(
size_in_dip,
base::BindRepeating(&app_list::MaybeResizeAndPadIconForMd),
true /* app_launchable */, false /* from_bookmark */,
extensions::ChromeAppIcon::Badge::kNone, &output_image_skia);
}
} }
void GenerateExtensionAppCompressedIcon(const std::string app_id, void GenerateExtensionAppCompressedIcon(const std::string app_id,
...@@ -602,7 +610,7 @@ TEST_P(ExtensionAppTest, LoadCompressedIcon) { ...@@ -602,7 +610,7 @@ TEST_P(ExtensionAppTest, LoadCompressedIcon) {
apps::IconEffects icon_effects = apps::IconEffects icon_effects =
(base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon))
? apps::IconEffects::kCrOsStandardIcon ? apps::IconEffects::kCrOsStandardIcon
: apps::IconEffects::kNone; : apps::IconEffects::kResizeAndPad;
base::RunLoop run_loop; base::RunLoop run_loop;
apps::mojom::IconValuePtr dst_icon; apps::mojom::IconValuePtr dst_icon;
......
...@@ -66,7 +66,7 @@ const base::Feature kAppActivityReporting{"AppActivityReporting", ...@@ -66,7 +66,7 @@ const base::Feature kAppActivityReporting{"AppActivityReporting",
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// App Service related flags. See components/services/app_service/README.md. // App Service related flags. See components/services/app_service/README.md.
const base::Feature kAppServiceAdaptiveIcon{"AppServiceAdaptiveIcon", const base::Feature kAppServiceAdaptiveIcon{"AppServiceAdaptiveIcon",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAppServiceExternalProtocol{ const base::Feature kAppServiceExternalProtocol{
"AppServiceExternalProtocol", base::FEATURE_DISABLED_BY_DEFAULT}; "AppServiceExternalProtocol", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAppServiceIntentHandling{"AppServiceIntentHandling", const base::Feature kAppServiceIntentHandling{"AppServiceIntentHandling",
......
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