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 36bd1d44812848de8d1b7ddefcca4a83eeb4d36b..9cad2b09a7dac2421279a8c71cb3199f08280334 100644 |
| --- a/chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| +++ b/chrome/browser/manifest/manifest_icon_selector_unittest.cc |
| @@ -28,9 +28,15 @@ class ManifestIconSelectorTest : public testing::Test { |
| ~ManifestIconSelectorTest() override {} |
| - GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { |
| + GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons, |
|
mlamouri (slow - plz ping)
2015/09/16 09:58:29
Could you name this FindBestMatchingIconWithMinimu
Lalit Maganti
2015/09/16 11:45:26
Done.
|
| + int minimum_icon_size_in_dp) { |
| return ManifestIconSelector::FindBestMatchingIcon( |
| - icons, GetPreferredIconSizeInDp(), &test_screen_); |
| + icons, GetPreferredIconSizeInDp(), |
| + minimum_icon_size_in_dp, &test_screen_); |
| + } |
| + |
| + GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { |
| + return FindBestMatchingIcon(icons, 0); |
| } |
| void SetDisplayDeviceScaleFactor(float device_scale_factor) { |
| @@ -243,23 +249,19 @@ TEST_F(ManifestIconSelectorTest, DeviceDensityMatchRejectsTooSmall) { |
| 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)); |
| - // Nothing matches here because there is a density scale factor lower bound of |
| - // of 1.0 which since there is no density bucket smaller than the one |
| - // associated with this scale factor. |
| + // Nothing matches here because the minimum is 48. |
| SetDisplayDeviceScaleFactor(1.0f); |
| - GURL url = FindBestMatchingIcon(icons); |
| + GURL url = FindBestMatchingIcon(icons, 48); |
| EXPECT_TRUE(url.is_empty()); |
| - // Nothing matches here as the icon is just smaller than the icon size |
| - // one density bucket below (i.e. 96 is expected and 48 is the minimum). |
| + // Nothing matches here because the minimum is 48 again. |
| SetDisplayDeviceScaleFactor(2.0f); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, 48); |
| EXPECT_TRUE(url.is_empty()); |
| - // Nothing matches here as the icon is just smaller than the icon size |
| - // one density bucket below (i.e. 144 is expected and 96 is the minimum). |
| + // Nothing matches here as the minimum is 96. |
| SetDisplayDeviceScaleFactor(3.0f); |
| - url = FindBestMatchingIcon(icons); |
| + url = FindBestMatchingIcon(icons, 96); |
| EXPECT_TRUE(url.is_empty()); |
| } |
| @@ -300,7 +302,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| int big = GetPreferredIconSizeInDp() * 2; |
| int very_big = GetPreferredIconSizeInDp() * 4; |
| - // (very_small, bit_small) => empty (since both are too small) |
| + // (very_small, bit_small) => bit_small |
| { |
| std::vector<gfx::Size> sizes_1; |
| sizes_1.push_back(gfx::Size(very_small, very_small)); |
| @@ -313,10 +315,10 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); |
| GURL url = FindBestMatchingIcon(icons); |
| - EXPECT_EQ("", url.spec()); |
| + EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| - // (very_small, bit_small, smaller) => empty (since both are too small) |
| + // (very_small, bit_small, smaller) => bit_small |
| { |
| std::vector<gfx::Size> sizes_1; |
| sizes_1.push_back(gfx::Size(very_small, very_small)); |
| @@ -333,7 +335,7 @@ TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_3)); |
| GURL url = FindBestMatchingIcon(icons); |
| - EXPECT_EQ("", url.spec()); |
| + EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| } |
| // (very_big, big) => big |
|
mlamouri (slow - plz ping)
2015/09/16 09:58:29
Could you add a test where the minimum is 1 and ha
mlamouri (slow - plz ping)
2015/09/16 09:58:29
Could you add a test where the minimum is 1, ideal
Lalit Maganti
2015/09/16 11:45:26
Done.
|