Commit 5a0adcbe authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

WebApp: Check pixel at the center of the generated icon.

We generate an icon placeholder using a letter with some solid
background color.

Let the test check if letter_color is actually presented in the icon.

This is a follow up test enhancement for the previous CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1888234

Bug: 1019102
Change-Id: I10e196926dff78032dcd8f00e93e24715d1be913
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891816
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711143}
parent 3225265d
...@@ -369,6 +369,7 @@ TEST_F(WebAppIconGeneratorTest, GenerateIconLetterFromUrl) { ...@@ -369,6 +369,7 @@ TEST_F(WebAppIconGeneratorTest, GenerateIconLetterFromUrl) {
TEST_F(WebAppIconGeneratorTest, GenerateIcons) { TEST_F(WebAppIconGeneratorTest, GenerateIcons) {
std::set<int> sizes = SizesToGenerate(); std::set<int> sizes = SizesToGenerate();
const SkColor bg_color = SK_ColorCYAN; const SkColor bg_color = SK_ColorCYAN;
const SkColor letter_color = color_utils::GetColorWithMaxContrast(bg_color);
// This is Unicode "Black Large Circle" U+2B24 character encoded as UTF8. // This is Unicode "Black Large Circle" U+2B24 character encoded as UTF8.
// Guarantees that there is some letter_color area at the center of the // Guarantees that there is some letter_color area at the center of the
...@@ -393,7 +394,15 @@ TEST_F(WebAppIconGeneratorTest, GenerateIcons) { ...@@ -393,7 +394,15 @@ TEST_F(WebAppIconGeneratorTest, GenerateIcons) {
// We don't check corner colors here: the icon is rounded by border_radius. // We don't check corner colors here: the icon is rounded by border_radius.
EXPECT_EQ(bg_color, icon_info.data.getColor(border_radius * 2, center_y)); EXPECT_EQ(bg_color, icon_info.data.getColor(border_radius * 2, center_y));
EXPECT_EQ(bg_color, icon_info.data.getColor(center_x, border_radius * 2)); EXPECT_EQ(bg_color, icon_info.data.getColor(center_x, border_radius * 2));
// TODO(loyso): Peek a pixel at the center of icon and check the color.
// Only for large icons with a sharp letter: Peek a pixel at the center of
// icon.
if (icon_info.width >= icon_size::k256) {
SkColor center_color = icon_info.data.getColor(center_x, center_y);
SCOPED_TRACE(letter_color);
SCOPED_TRACE(center_color);
EXPECT_TRUE(AreColorsEqual(letter_color, center_color, /*threshold=*/50));
}
sizes.erase(icon_info.width); sizes.erase(icon_info.width);
} }
......
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