Chromium Code Reviews| Index: chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| diff --git a/chrome/browser/manifest/manifest_icon_selector_unittest.cc b/chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| index 6750957c6aeb730431b0d6074a40b4ef67f34308..a2b0ce8a4e1aabba7a5a8d9b399176bc3ec2ac80 100644 |
| --- a/chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| +++ b/chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| @@ -13,6 +13,10 @@ |
| #include "ui/gfx/screen.h" |
| #include "ui/gfx/test/test_screen.h" |
| +namespace { |
| +const int DEFAULT_PREFERRED_ICON_SIZE = 48; |
| +} |
| + |
| class ManifestIconSelectorTest : public testing::Test { |
| protected: |
| ManifestIconSelectorTest() { |
| @@ -25,6 +29,10 @@ class ManifestIconSelectorTest : public testing::Test { |
| gfx::Screen::SetScreenInstance(nullptr); |
| } |
| + void SetUp() override { |
| + SetPreferredIconSizeInDp(DEFAULT_PREFERRED_ICON_SIZE); |
| + } |
| + |
| GURL FindBestMatchingIconWithMinimum( |
| const std::vector<content::Manifest::Icon>& icons, |
| int minimum_icon_size_in_dp) { |
| @@ -51,13 +59,11 @@ class ManifestIconSelectorTest : public testing::Test { |
| static content::Manifest::Icon CreateIcon( |
| const std::string& url, |
| const std::string& type, |
| - double density, |
| const std::vector<gfx::Size> sizes) { |
| content::Manifest::Icon icon; |
| icon.src = GURL(url); |
| if (!type.empty()) |
| icon.type = base::NullableString16(base::UTF8ToUTF16(type), false); |
| - icon.density = density; |
| icon.sizes = sizes; |
| return icon; |
| @@ -65,7 +71,7 @@ class ManifestIconSelectorTest : public testing::Test { |
| private: |
| gfx::test::TestScreen test_screen_; |
| - int preferred_icon_size_ = 48; |
| + int preferred_icon_size_ = DEFAULT_PREFERRED_ICON_SIZE; |
| DISALLOW_COPY_AND_ASSIGN(ManifestIconSelectorTest); |
| }; |
| @@ -81,7 +87,7 @@ TEST_F(ManifestIconSelectorTest, NoSizes) { |
| // Icon with no sizes are ignored. |
| std::vector<content::Manifest::Icon> icons; |
| icons.push_back( |
| - CreateIcon("http://foo.com/icon.png", "", 1.0, std::vector<gfx::Size>())); |
| + CreateIcon("http://foo.com/icon.png", "", std::vector<gfx::Size>())); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_TRUE(url.is_empty()); |
| @@ -95,37 +101,32 @@ TEST_F(ManifestIconSelectorTest, MIMETypeFiltering) { |
| std::vector<content::Manifest::Icon> icons; |
| icons.push_back( |
| - CreateIcon("http://foo.com/icon.png", "image/foo_bar", 1.0, sizes)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", 1.0, sizes)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", 1.0, sizes)); |
| - icons.push_back( |
| - CreateIcon("http://foo.com/icon.png", "video/mp4", 1.0, sizes)); |
| + CreateIcon("http://foo.com/icon.png", "image/foo_bar", sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "video/mp4", sizes)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_TRUE(url.is_empty()); |
| icons.clear(); |
| - icons.push_back( |
| - CreateIcon("http://foo.com/icon.png", "image/png", 1.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "image/png", sizes)); |
| url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| icons.clear(); |
| - icons.push_back( |
| - CreateIcon("http://foo.com/icon.png", "image/gif", 1.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "image/gif", sizes)); |
| url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| icons.clear(); |
| - icons.push_back( |
| - CreateIcon("http://foo.com/icon.png", "image/jpeg", 1.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "image/jpeg", sizes)); |
| url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, PreferredSizeOfCurrentDensityIsUsedFirst) { |
| - // This test has three icons each are marked with sizes set to the preferred |
| - // icon size for the associated density. |
| +TEST_F(ManifestIconSelectorTest, PreferredSizeIsUsedFirst) { |
| + // Each icon is marked with sizes that match the preferred icon size. |
| std::vector<gfx::Size> sizes_1; |
| sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), |
| GetPreferredIconSizeInDp())); |
| @@ -139,9 +140,9 @@ TEST_F(ManifestIconSelectorTest, PreferredSizeOfCurrentDensityIsUsedFirst) { |
| GetPreferredIconSizeInDp() * 3)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes_2)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes_3)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| SetDisplayDeviceScaleFactor(1.0f); |
| GURL url = FindBestMatchingIcon(icons); |
| @@ -156,12 +157,9 @@ TEST_F(ManifestIconSelectorTest, PreferredSizeOfCurrentDensityIsUsedFirst) { |
| EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, PreferredSizeOfDefaultDensityIsUsedSecond) { |
| - // This test has three icons. The first one is of density zero and is marked |
| - // with three sizes which are the preferred icon size for density 1, 2 and 3. |
| - // The icon for density 2 and 3 have a size set to 1024x1024. |
| - // Regardless of the device scale factor, the icon of density 1 is going to be |
| - // used because it matches the preferred size. |
| +TEST_F(ManifestIconSelectorTest, FirstIconWithPreferredSizeIsUsedFirst) { |
| + // This test has three icons. The first icon is going to be used because it |
| + // has sizes which matches the preferred size for each device scale factor. |
| std::vector<gfx::Size> sizes_1; |
| sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), |
| GetPreferredIconSizeInDp())); |
| @@ -177,9 +175,9 @@ TEST_F(ManifestIconSelectorTest, PreferredSizeOfDefaultDensityIsUsedSecond) { |
| sizes_3.push_back(gfx::Size(1024, 1024)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes_2)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes_3)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| SetDisplayDeviceScaleFactor(1.0f); |
| GURL url = FindBestMatchingIcon(icons); |
| @@ -195,17 +193,21 @@ TEST_F(ManifestIconSelectorTest, PreferredSizeOfDefaultDensityIsUsedSecond) { |
| } |
| TEST_F(ManifestIconSelectorTest, DeviceDensityFirst) { |
|
mlamouri (slow - plz ping)
2016/04/21 13:08:40
nit: change test name? Like "UseDeviceDensity"?
dominickn
2016/04/21 14:14:43
Done.
|
| - // If there is no perfect icon but an icon of the current device density is |
| - // present, it will be picked. |
| - // This test has three icons each are marked with sizes set to the preferred |
| - // icon size for the associated density. |
| - std::vector<gfx::Size> sizes; |
| - sizes.push_back(gfx::Size(1024, 1024)); |
| + // If there is no perfect icon, the smallest larger icon will be chosen. |
| + std::vector<gfx::Size> sizes_1; |
| + sizes_1.push_back(gfx::Size(90, 90)); |
| + |
| + std::vector<gfx::Size> sizes_2; |
| + sizes_2.push_back(gfx::Size(128, 128)); |
| + |
| + std::vector<gfx::Size> sizes_3; |
| + sizes_3.push_back(gfx::Size(192, 192)); |
| + |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| SetDisplayDeviceScaleFactor(1.0f); |
| GURL url = FindBestMatchingIcon(icons); |
| @@ -220,25 +222,9 @@ TEST_F(ManifestIconSelectorTest, DeviceDensityFirst) { |
| EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, DeviceDensityFallback) { |
| - // If there is no perfect icon but and no icon of the current display density, |
| - // an icon of density 1.0 will be used. |
| - std::vector<gfx::Size> sizes; |
| - sizes.push_back(gfx::Size(1024, 1024)); |
| - |
| - std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes)); |
| - |
| - SetDisplayDeviceScaleFactor(3.0f); |
| - GURL url = FindBestMatchingIcon(icons); |
| - EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| -} |
| - |
| -TEST_F(ManifestIconSelectorTest, DeviceDensityMatchRejectsTooSmall) { |
| - // If we have to resort to density matching to find icons, then an icon of |
| - // the correct size has not been found. Make sure that the minimum passed |
| - // is enforced. |
| +TEST_F(ManifestIconSelectorTest, CheckDifferentDeviceScaleFactors) { |
| + // When an icon of the correct size has not been found, we fall back to the |
| + // closest non-matching sizes. Make sure that the minimum passed is enforced. |
| std::vector<gfx::Size> sizes_1_2; |
| std::vector<gfx::Size> sizes_3; |
| @@ -249,16 +235,17 @@ TEST_F(ManifestIconSelectorTest, DeviceDensityMatchRejectsTooSmall) { |
| SetPreferredIconSizeInDp(1024); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes_1_2)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes_1_2)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes_3)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_1_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| - // Nothing matches here because the minimum is 48. |
| + // Icon 3 should match. |
| SetDisplayDeviceScaleFactor(1.0f); |
| GURL url = FindBestMatchingIconWithMinimum(icons, 48); |
| - EXPECT_TRUE(url.is_empty()); |
| + EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| - // Nothing matches here because the minimum is 48 again. |
| + // Nothing matches here because the minimum is 48 and all icon sizes are now |
| + // too small. |
| SetDisplayDeviceScaleFactor(2.0f); |
| url = FindBestMatchingIconWithMinimum(icons, 48); |
| EXPECT_TRUE(url.is_empty()); |
| @@ -272,9 +259,10 @@ TEST_F(ManifestIconSelectorTest, DeviceDensityMatchRejectsTooSmall) { |
| TEST_F(ManifestIconSelectorTest, IdealVeryCloseToMinimumMatches) { |
| std::vector<gfx::Size> sizes; |
| sizes.push_back(gfx::Size(2, 2)); |
| + SetPreferredIconSizeInDp(2); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes)); |
| SetDisplayDeviceScaleFactor(1.0f); |
| GURL url = FindBestMatchingIconWithMinimum(icons, 1); |
| @@ -288,43 +276,27 @@ TEST_F(ManifestIconSelectorTest, SizeVeryCloseToMinimumMatches) { |
| SetPreferredIconSizeInDp(200); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes)); |
| SetDisplayDeviceScaleFactor(1.0f); |
| GURL url = FindBestMatchingIconWithMinimum(icons, 1); |
| EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, DoNotUseOtherDensities) { |
| - // If there are only icons of densities that are not the current display |
| - // density or the default density, they are ignored. |
| - std::vector<gfx::Size> sizes; |
| - sizes.push_back(gfx::Size(1024, 1024)); |
| - |
| - std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes)); |
| - |
| - SetDisplayDeviceScaleFactor(3.0f); |
| - GURL url = FindBestMatchingIcon(icons); |
| - EXPECT_TRUE(url.is_empty()); |
| -} |
| - |
| TEST_F(ManifestIconSelectorTest, NotSquareIconsAreIgnored) { |
| std::vector<gfx::Size> sizes; |
| sizes.push_back(gfx::Size(1024, 1023)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_TRUE(url.is_empty()); |
| } |
| TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| - // This test verifies ManifestIconSelector::FindBestMatchingIcon by passing |
| - // different icon sizes and checking which one is picked. |
| - // The Device Scale Factor is 1.0 and the preferred icon size is returned by |
| - // GetPreferredIconSizeInDp(). |
| + // Ensure ManifestIconSelector::FindBestMatchingIcon selects the closest icon |
| + // to the preferred size when presented with a number of options. |
| int very_small = GetPreferredIconSizeInDp() / 4; |
| int small_size = GetPreferredIconSizeInDp() / 2; |
| int bit_small = GetPreferredIconSizeInDp() - 1; |
| @@ -332,6 +304,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| int big = GetPreferredIconSizeInDp() * 2; |
| int very_big = GetPreferredIconSizeInDp() * 4; |
| + SetDisplayDeviceScaleFactor(1.0f); |
| // (very_small, bit_small) => bit_small |
| { |
| std::vector<gfx::Size> sizes_1; |
| @@ -341,14 +314,14 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| sizes_2.push_back(gfx::Size(bit_small, bit_small)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| - // (very_small, bit_small, smaller) => bit_small |
| + // (very_small, bit_small, small_size) => bit_small |
| { |
| std::vector<gfx::Size> sizes_1; |
| sizes_1.push_back(gfx::Size(very_small, very_small)); |
| @@ -360,9 +333,9 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| sizes_3.push_back(gfx::Size(small_size, small_size)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_3)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no_1.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no_2.png", "", sizes_3)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| @@ -377,8 +350,8 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| sizes_2.push_back(gfx::Size(big, big)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| @@ -396,9 +369,9 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| sizes_3.push_back(gfx::Size(bit_big, bit_big)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_2)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_3)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_3)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| @@ -413,8 +386,8 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| sizes_2.push_back(gfx::Size(very_big, very_big)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| @@ -429,8 +402,8 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| sizes_2.push_back(gfx::Size(bit_big, bit_big)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| @@ -442,7 +415,7 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| // preferred size. An icon with the current device scale factor is preferred |
| // over one with the default density. |
| - // 'any' with preferred size => preferred size |
| + // Icon with 'any' and icon with preferred size => preferred size is chosen. |
| { |
| std::vector<gfx::Size> sizes_1; |
| sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), |
| @@ -451,14 +424,14 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| sizes_2.push_back(gfx::Size(0, 0)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_2)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| - // 'any' with nearly preferred size => any |
| + // Icon with 'any' and icon larger than preferred size => any is chosen. |
| { |
| std::vector<gfx::Size> sizes_1; |
| sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() + 1, |
| @@ -467,21 +440,22 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| sizes_2.push_back(gfx::Size(0, 0)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| GURL url = FindBestMatchingIcon(icons); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| - // 'any' on default density and current density => current density. |
| + // Multiple icons with 'any' => the last one is chosen. |
| { |
| std::vector<gfx::Size> sizes; |
| sizes.push_back(gfx::Size(0, 0)); |
| std::vector<content::Manifest::Icon> icons; |
| - icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes)); |
| - icons.push_back(CreateIcon("http://foo.com/icon.png", "", 3.0, sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no1.png", "", sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_no2.png", "", sizes)); |
| + icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes)); |
| SetDisplayDeviceScaleFactor(3.0f); |
| GURL url = FindBestMatchingIcon(icons); |