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 2d8499e0985334ceae49600d1f62404e36250c75..968f7ff09b814911fdd0745bc585fac5d2616234 100644 |
| --- a/chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| +++ b/chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| @@ -10,96 +10,55 @@ |
| #include "base/macros.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| -#include "ui/display/screen.h" |
| -#include "ui/display/test/test_screen.h" |
| namespace { |
| -const int DEFAULT_PREFERRED_ICON_SIZE = 48; |
| -} |
| -class ManifestIconSelectorTest : public testing::Test { |
| - protected: |
| - ManifestIconSelectorTest() { |
| - const display::Display test_display = test_screen_.GetPrimaryDisplay(); |
| - display::Display display(test_display); |
| - display.set_id(0x1337); |
| - display.set_bounds(gfx::Rect(0, 0, 2560, 1440)); |
| - test_screen_.display_list().RemoveDisplay(test_display.id()); |
| - test_screen_.display_list().AddDisplay(display, |
| - display::DisplayList::Type::PRIMARY); |
| - display::Screen::SetScreenInstance(&test_screen_); |
| - } |
| +const int kDefaultIconSize = 48; |
|
dominickn
2016/12/19 06:23:32
Change to 144.
|
| - ~ManifestIconSelectorTest() override { |
| - display::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) { |
| - return ManifestIconSelector::FindBestMatchingIcon( |
| - icons, GetPreferredIconSizeInDp(), minimum_icon_size_in_dp); |
| - } |
| - |
| - GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { |
| - return FindBestMatchingIconWithMinimum(icons, 0); |
| - } |
| - |
| - void SetDisplayDeviceScaleFactor(float device_scale_factor) { |
| - display::Display display(test_screen_.GetPrimaryDisplay()); |
| - display.set_device_scale_factor(device_scale_factor); |
| - test_screen_.display_list().UpdateDisplay(display); |
| - } |
| - |
| - int GetPreferredIconSizeInDp() { |
| - return preferred_icon_size_; |
| - } |
| - |
| - void SetPreferredIconSizeInDp(int new_size) { |
| - preferred_icon_size_ = new_size; |
| - } |
| +GURL FindBestMatchingIconWithMinimum( |
| + const std::vector<content::Manifest::Icon>& icons, |
| + int ideal_icon_size_in_px, |
| + int minimum_icon_size_in_px) { |
| + return ManifestIconSelector::FindBestMatchingIcon( |
| + icons, ideal_icon_size_in_px, minimum_icon_size_in_px); |
| +} |
| - static content::Manifest::Icon CreateIcon( |
| - const std::string& url, |
| - const std::string& type, |
| - const std::vector<gfx::Size> sizes) { |
| - content::Manifest::Icon icon; |
| - icon.src = GURL(url); |
| - icon.type = base::UTF8ToUTF16(type); |
| - icon.sizes = sizes; |
| +GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons, |
| + int ideal_icon_size_in_px) { |
| + return FindBestMatchingIconWithMinimum(icons, ideal_icon_size_in_px, 0); |
| +} |
| - return icon; |
| - } |
| +static content::Manifest::Icon CreateIcon(const std::string& url, |
| + const std::string& type, |
| + const std::vector<gfx::Size> sizes) { |
| + content::Manifest::Icon icon; |
| + icon.src = GURL(url); |
| + icon.type = base::UTF8ToUTF16(type); |
| + icon.sizes = sizes; |
| - private: |
| - display::test::TestScreen test_screen_; |
| - int preferred_icon_size_ = DEFAULT_PREFERRED_ICON_SIZE; |
| + return icon; |
| +} |
| - DISALLOW_COPY_AND_ASSIGN(ManifestIconSelectorTest); |
| -}; |
| +} // anonymous namespace |
| -TEST_F(ManifestIconSelectorTest, NoIcons) { |
| +TEST(ManifestIconSelector, NoIcons) { |
| // No icons should return the empty URL. |
| std::vector<content::Manifest::Icon> icons; |
| - GURL url = FindBestMatchingIcon(icons); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_TRUE(url.is_empty()); |
| } |
| -TEST_F(ManifestIconSelectorTest, NoSizes) { |
| +TEST(ManifestIconSelector, NoSizes) { |
| // Icon with no sizes are ignored. |
| std::vector<content::Manifest::Icon> icons; |
| icons.push_back( |
| CreateIcon("http://foo.com/icon.png", "", std::vector<gfx::Size>())); |
| - GURL url = FindBestMatchingIcon(icons); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_TRUE(url.is_empty()); |
| } |
| -TEST_F(ManifestIconSelectorTest, MIMETypeFiltering) { |
| +TEST(ManifestIconSelector, MIMETypeFiltering) { |
| // Icons with type specified to a MIME type that isn't a valid image MIME type |
| // are ignored. |
| std::vector<gfx::Size> sizes; |
| @@ -112,67 +71,58 @@ TEST_F(ManifestIconSelectorTest, MIMETypeFiltering) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_TRUE(url.is_empty()); |
| icons.clear(); |
| icons.push_back(CreateIcon("http://foo.com/icon.png", "image/png", sizes)); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| icons.clear(); |
| icons.push_back(CreateIcon("http://foo.com/icon.png", "image/gif", sizes)); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| icons.clear(); |
| icons.push_back(CreateIcon("http://foo.com/icon.png", "image/jpeg", sizes)); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, PreferredSizeIsUsedFirst) { |
| +TEST(ManifestIconSelector, 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())); |
| + std::vector<gfx::Size> sizes_48; |
| + sizes_48.push_back(gfx::Size(48, 48)); |
| - std::vector<gfx::Size> sizes_2; |
| - sizes_2.push_back(gfx::Size(GetPreferredIconSizeInDp() * 2, |
| - GetPreferredIconSizeInDp() * 2)); |
| + std::vector<gfx::Size> sizes_96; |
| + sizes_96.push_back(gfx::Size(96, 96)); |
| - std::vector<gfx::Size> sizes_3; |
| - sizes_3.push_back(gfx::Size(GetPreferredIconSizeInDp() * 3, |
| - GetPreferredIconSizeInDp() * 3)); |
| + std::vector<gfx::Size> sizes_144; |
| + sizes_144.push_back(gfx::Size(144, 144)); |
| std::vector<content::Manifest::Icon> icons; |
| - 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)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_48.png", "", sizes_48)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_96.png", "", sizes_96)); |
| + icons.push_back(CreateIcon("http://foo.com/icon_144.png", "", sizes_144)); |
| - SetDisplayDeviceScaleFactor(1.0f); |
| - GURL url = FindBestMatchingIcon(icons); |
| - EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| + GURL url = FindBestMatchingIcon(icons, 48); |
| + EXPECT_EQ("http://foo.com/icon_48.png", url.spec()); |
| - SetDisplayDeviceScaleFactor(2.0f); |
| - url = FindBestMatchingIcon(icons); |
| - EXPECT_EQ("http://foo.com/icon_x2.png", url.spec()); |
| + url = FindBestMatchingIcon(icons, 96); |
| + EXPECT_EQ("http://foo.com/icon_96.png", url.spec()); |
| - SetDisplayDeviceScaleFactor(3.0f); |
| - url = FindBestMatchingIcon(icons); |
| - EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| + url = FindBestMatchingIcon(icons, 144); |
| + EXPECT_EQ("http://foo.com/icon_144.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, FirstIconWithPreferredSizeIsUsedFirst) { |
| +TEST(ManifestIconSelector, 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. |
|
dominickn
2016/12/19 06:23:32
Update the comment: "because it contains a preferr
|
| std::vector<gfx::Size> sizes_1; |
| - sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), |
| - GetPreferredIconSizeInDp())); |
| - sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() * 2, |
| - GetPreferredIconSizeInDp() * 2)); |
| - sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() * 3, |
| - GetPreferredIconSizeInDp() * 3)); |
| + sizes_1.push_back(gfx::Size(kDefaultIconSize, kDefaultIconSize)); |
| + sizes_1.push_back(gfx::Size(kDefaultIconSize * 2, kDefaultIconSize * 2)); |
| + sizes_1.push_back(gfx::Size(kDefaultIconSize * 3, kDefaultIconSize * 3)); |
| std::vector<gfx::Size> sizes_2; |
| sizes_2.push_back(gfx::Size(1024, 1024)); |
| @@ -185,20 +135,17 @@ TEST_F(ManifestIconSelectorTest, FirstIconWithPreferredSizeIsUsedFirst) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| - SetDisplayDeviceScaleFactor(2.0f); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, kDefaultIconSize * 2); |
| EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| - SetDisplayDeviceScaleFactor(3.0f); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, kDefaultIconSize * 3); |
| EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, UseDeviceDensity) { |
| +TEST(ManifestIconSelector, UseDeviceDensity) { |
|
dominickn
2016/12/19 06:23:32
Call this "FallbackToSmallestLargerIcon"
|
| // 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)); |
| @@ -209,26 +156,22 @@ TEST_F(ManifestIconSelectorTest, UseDeviceDensity) { |
| 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", "", 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); |
| + GURL url = FindBestMatchingIcon(icons, 48); |
| EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| - SetDisplayDeviceScaleFactor(2.0f); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, 96); |
| EXPECT_EQ("http://foo.com/icon_x2.png", url.spec()); |
| - SetDisplayDeviceScaleFactor(3.0f); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, 144); |
| EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, CheckDifferentDeviceScaleFactors) { |
| +TEST(ManifestIconSelector, CheckDifferentDeviceScaleFactors) { |
|
dominickn
2016/12/19 06:23:32
"FallbackToLargestIconLargerThanMinimum"
|
| // 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; |
| @@ -237,80 +180,63 @@ TEST_F(ManifestIconSelectorTest, CheckDifferentDeviceScaleFactors) { |
| sizes_1_2.push_back(gfx::Size(47, 47)); |
| sizes_3.push_back(gfx::Size(95, 95)); |
| - // Set to a value which will not affect the calculations. |
| - SetPreferredIconSizeInDp(1024); |
| - |
| std::vector<content::Manifest::Icon> icons; |
| 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)); |
| // Icon 3 should match. |
| - SetDisplayDeviceScaleFactor(1.0f); |
| - GURL url = FindBestMatchingIconWithMinimum(icons, 48); |
| + GURL url = FindBestMatchingIconWithMinimum(icons, 1024, 48); |
| EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| - // 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()); |
| - |
| // Nothing matches here as the minimum is 96. |
| - SetDisplayDeviceScaleFactor(3.0f); |
| - url = FindBestMatchingIconWithMinimum(icons, 96); |
| + url = FindBestMatchingIconWithMinimum(icons, 1024, 96); |
| EXPECT_TRUE(url.is_empty()); |
| } |
| -TEST_F(ManifestIconSelectorTest, IdealVeryCloseToMinimumMatches) { |
| +TEST(ManifestIconSelector, 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", "", sizes)); |
| - SetDisplayDeviceScaleFactor(1.0f); |
| - GURL url = FindBestMatchingIconWithMinimum(icons, 1); |
| + GURL url = FindBestMatchingIconWithMinimum(icons, 2, 1); |
| EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, SizeVeryCloseToMinimumMatches) { |
| +TEST(ManifestIconSelector, SizeVeryCloseToMinimumMatches) { |
| std::vector<gfx::Size> sizes; |
| sizes.push_back(gfx::Size(2, 2)); |
| - SetPreferredIconSizeInDp(200); |
| - |
| std::vector<content::Manifest::Icon> icons; |
| icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes)); |
| - SetDisplayDeviceScaleFactor(1.0f); |
| - GURL url = FindBestMatchingIconWithMinimum(icons, 1); |
| + GURL url = FindBestMatchingIconWithMinimum(icons, 200, 1); |
| EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| } |
| -TEST_F(ManifestIconSelectorTest, NotSquareIconsAreIgnored) { |
| +TEST(ManifestIconSelector, 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", "", sizes)); |
| - GURL url = FindBestMatchingIcon(icons); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_TRUE(url.is_empty()); |
| } |
| -TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| +TEST(ManifestIconSelector, ClosestIconToPreferred) { |
| // 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; |
| - int bit_big = GetPreferredIconSizeInDp() + 1; |
| - int big = GetPreferredIconSizeInDp() * 2; |
| - int very_big = GetPreferredIconSizeInDp() * 4; |
| - |
| - SetDisplayDeviceScaleFactor(1.0f); |
| + int very_small = kDefaultIconSize / 4; |
| + int small_size = kDefaultIconSize / 2; |
| + int bit_small = kDefaultIconSize - 1; |
| + int bit_big = kDefaultIconSize + 1; |
| + int big = kDefaultIconSize * 2; |
| + int very_big = kDefaultIconSize * 4; |
| + |
| // (very_small, bit_small) => bit_small |
| { |
| std::vector<gfx::Size> sizes_1; |
| @@ -323,7 +249,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| @@ -343,7 +269,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| @@ -359,7 +285,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| @@ -379,7 +305,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| @@ -395,7 +321,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| @@ -411,12 +337,12 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| } |
| -TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| +TEST(ManifestIconSelector, UseAnyIfNoPreferredSize) { |
| // 'any' (ie. gfx::Size(0,0)) should be used if there is no icon of a |
| // preferred size. An icon with the current device scale factor is preferred |
| // over one with the default density. |
| @@ -424,8 +350,7 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| // 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(), |
| - GetPreferredIconSizeInDp())); |
| + sizes_1.push_back(gfx::Size(kDefaultIconSize, kDefaultIconSize)); |
| std::vector<gfx::Size> sizes_2; |
| sizes_2.push_back(gfx::Size(0, 0)); |
| @@ -433,15 +358,14 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| // 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, |
| - GetPreferredIconSizeInDp() + 1)); |
| + sizes_1.push_back(gfx::Size(kDefaultIconSize + 1, kDefaultIconSize + 1)); |
| std::vector<gfx::Size> sizes_2; |
| sizes_2.push_back(gfx::Size(0, 0)); |
| @@ -449,7 +373,7 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| @@ -463,8 +387,7 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| 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); |
| + GURL url = FindBestMatchingIcon(icons, kDefaultIconSize * 3); |
| EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| } |