Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/manifest/manifest_icon_selector.h" | 5 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/gfx/screen.h" | 13 #include "ui/gfx/screen.h" |
| 14 #include "ui/gfx/test/test_screen.h" | 14 #include "ui/gfx/test/test_screen.h" |
| 15 | 15 |
| 16 namespace { | |
| 17 const int DEFAULT_PREFERRED_ICON_SIZE = 48; | |
| 18 } | |
| 19 | |
| 16 class ManifestIconSelectorTest : public testing::Test { | 20 class ManifestIconSelectorTest : public testing::Test { |
| 17 protected: | 21 protected: |
| 18 ManifestIconSelectorTest() { | 22 ManifestIconSelectorTest() { |
| 19 test_screen_.display()->set_id(0x1337); | 23 test_screen_.display()->set_id(0x1337); |
| 20 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); | 24 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); |
| 21 gfx::Screen::SetScreenInstance(&test_screen_); | 25 gfx::Screen::SetScreenInstance(&test_screen_); |
| 22 } | 26 } |
| 23 | 27 |
| 24 ~ManifestIconSelectorTest() override { | 28 ~ManifestIconSelectorTest() override { |
| 25 gfx::Screen::SetScreenInstance(nullptr); | 29 gfx::Screen::SetScreenInstance(nullptr); |
| 26 } | 30 } |
| 27 | 31 |
| 32 void SetUp() override { | |
| 33 SetPreferredIconSizeInDp(DEFAULT_PREFERRED_ICON_SIZE); | |
| 34 } | |
| 35 | |
| 28 GURL FindBestMatchingIconWithMinimum( | 36 GURL FindBestMatchingIconWithMinimum( |
| 29 const std::vector<content::Manifest::Icon>& icons, | 37 const std::vector<content::Manifest::Icon>& icons, |
| 30 int minimum_icon_size_in_dp) { | 38 int minimum_icon_size_in_dp) { |
| 31 return ManifestIconSelector::FindBestMatchingIcon( | 39 return ManifestIconSelector::FindBestMatchingIcon( |
| 32 icons, GetPreferredIconSizeInDp(), minimum_icon_size_in_dp); | 40 icons, GetPreferredIconSizeInDp(), minimum_icon_size_in_dp); |
| 33 } | 41 } |
| 34 | 42 |
| 35 GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { | 43 GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { |
| 36 return FindBestMatchingIconWithMinimum(icons, 0); | 44 return FindBestMatchingIconWithMinimum(icons, 0); |
| 37 } | 45 } |
| 38 | 46 |
| 39 void SetDisplayDeviceScaleFactor(float device_scale_factor) { | 47 void SetDisplayDeviceScaleFactor(float device_scale_factor) { |
| 40 test_screen_.display()->set_device_scale_factor(device_scale_factor); | 48 test_screen_.display()->set_device_scale_factor(device_scale_factor); |
| 41 } | 49 } |
| 42 | 50 |
| 43 int GetPreferredIconSizeInDp() { | 51 int GetPreferredIconSizeInDp() { |
| 44 return preferred_icon_size_; | 52 return preferred_icon_size_; |
| 45 } | 53 } |
| 46 | 54 |
| 47 void SetPreferredIconSizeInDp(int new_size) { | 55 void SetPreferredIconSizeInDp(int new_size) { |
| 48 preferred_icon_size_ = new_size; | 56 preferred_icon_size_ = new_size; |
| 49 } | 57 } |
| 50 | 58 |
| 51 static content::Manifest::Icon CreateIcon( | 59 static content::Manifest::Icon CreateIcon( |
| 52 const std::string& url, | 60 const std::string& url, |
| 53 const std::string& type, | 61 const std::string& type, |
| 54 double density, | |
| 55 const std::vector<gfx::Size> sizes) { | 62 const std::vector<gfx::Size> sizes) { |
| 56 content::Manifest::Icon icon; | 63 content::Manifest::Icon icon; |
| 57 icon.src = GURL(url); | 64 icon.src = GURL(url); |
| 58 if (!type.empty()) | 65 if (!type.empty()) |
| 59 icon.type = base::NullableString16(base::UTF8ToUTF16(type), false); | 66 icon.type = base::NullableString16(base::UTF8ToUTF16(type), false); |
| 60 icon.density = density; | |
| 61 icon.sizes = sizes; | 67 icon.sizes = sizes; |
| 62 | 68 |
| 63 return icon; | 69 return icon; |
| 64 } | 70 } |
| 65 | 71 |
| 66 private: | 72 private: |
| 67 gfx::test::TestScreen test_screen_; | 73 gfx::test::TestScreen test_screen_; |
| 68 int preferred_icon_size_ = 48; | 74 int preferred_icon_size_ = DEFAULT_PREFERRED_ICON_SIZE; |
| 69 | 75 |
| 70 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelectorTest); | 76 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelectorTest); |
| 71 }; | 77 }; |
| 72 | 78 |
| 73 TEST_F(ManifestIconSelectorTest, NoIcons) { | 79 TEST_F(ManifestIconSelectorTest, NoIcons) { |
| 74 // No icons should return the empty URL. | 80 // No icons should return the empty URL. |
| 75 std::vector<content::Manifest::Icon> icons; | 81 std::vector<content::Manifest::Icon> icons; |
| 76 GURL url = FindBestMatchingIcon(icons); | 82 GURL url = FindBestMatchingIcon(icons); |
| 77 EXPECT_TRUE(url.is_empty()); | 83 EXPECT_TRUE(url.is_empty()); |
| 78 } | 84 } |
| 79 | 85 |
| 80 TEST_F(ManifestIconSelectorTest, NoSizes) { | 86 TEST_F(ManifestIconSelectorTest, NoSizes) { |
| 81 // Icon with no sizes are ignored. | 87 // Icon with no sizes are ignored. |
| 82 std::vector<content::Manifest::Icon> icons; | 88 std::vector<content::Manifest::Icon> icons; |
| 83 icons.push_back( | 89 icons.push_back( |
| 84 CreateIcon("http://foo.com/icon.png", "", 1.0, std::vector<gfx::Size>())); | 90 CreateIcon("http://foo.com/icon.png", "", std::vector<gfx::Size>())); |
| 85 | 91 |
| 86 GURL url = FindBestMatchingIcon(icons); | 92 GURL url = FindBestMatchingIcon(icons); |
| 87 EXPECT_TRUE(url.is_empty()); | 93 EXPECT_TRUE(url.is_empty()); |
| 88 } | 94 } |
| 89 | 95 |
| 90 TEST_F(ManifestIconSelectorTest, MIMETypeFiltering) { | 96 TEST_F(ManifestIconSelectorTest, MIMETypeFiltering) { |
| 91 // Icons with type specified to a MIME type that isn't a valid image MIME type | 97 // Icons with type specified to a MIME type that isn't a valid image MIME type |
| 92 // are ignored. | 98 // are ignored. |
| 93 std::vector<gfx::Size> sizes; | 99 std::vector<gfx::Size> sizes; |
| 94 sizes.push_back(gfx::Size(1024, 1024)); | 100 sizes.push_back(gfx::Size(1024, 1024)); |
| 95 | 101 |
| 96 std::vector<content::Manifest::Icon> icons; | 102 std::vector<content::Manifest::Icon> icons; |
| 97 icons.push_back( | 103 icons.push_back( |
| 98 CreateIcon("http://foo.com/icon.png", "image/foo_bar", 1.0, sizes)); | 104 CreateIcon("http://foo.com/icon.png", "image/foo_bar", sizes)); |
| 99 icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", 1.0, sizes)); | 105 icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", sizes)); |
| 100 icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", 1.0, sizes)); | 106 icons.push_back(CreateIcon("http://foo.com/icon.png", "image/", sizes)); |
| 101 icons.push_back( | 107 icons.push_back(CreateIcon("http://foo.com/icon.png", "video/mp4", sizes)); |
| 102 CreateIcon("http://foo.com/icon.png", "video/mp4", 1.0, sizes)); | |
| 103 | 108 |
| 104 GURL url = FindBestMatchingIcon(icons); | 109 GURL url = FindBestMatchingIcon(icons); |
| 105 EXPECT_TRUE(url.is_empty()); | 110 EXPECT_TRUE(url.is_empty()); |
| 106 | 111 |
| 107 icons.clear(); | 112 icons.clear(); |
| 108 icons.push_back( | 113 icons.push_back(CreateIcon("http://foo.com/icon.png", "image/png", sizes)); |
| 109 CreateIcon("http://foo.com/icon.png", "image/png", 1.0, sizes)); | |
| 110 url = FindBestMatchingIcon(icons); | 114 url = FindBestMatchingIcon(icons); |
| 111 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 115 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 112 | 116 |
| 113 icons.clear(); | 117 icons.clear(); |
| 114 icons.push_back( | 118 icons.push_back(CreateIcon("http://foo.com/icon.png", "image/gif", sizes)); |
| 115 CreateIcon("http://foo.com/icon.png", "image/gif", 1.0, sizes)); | |
| 116 url = FindBestMatchingIcon(icons); | 119 url = FindBestMatchingIcon(icons); |
| 117 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 120 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 118 | 121 |
| 119 icons.clear(); | 122 icons.clear(); |
| 120 icons.push_back( | 123 icons.push_back(CreateIcon("http://foo.com/icon.png", "image/jpeg", sizes)); |
| 121 CreateIcon("http://foo.com/icon.png", "image/jpeg", 1.0, sizes)); | |
| 122 url = FindBestMatchingIcon(icons); | 124 url = FindBestMatchingIcon(icons); |
| 123 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 125 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 124 } | 126 } |
| 125 | 127 |
| 126 TEST_F(ManifestIconSelectorTest, PreferredSizeOfCurrentDensityIsUsedFirst) { | 128 TEST_F(ManifestIconSelectorTest, PreferredSizeIsUsedFirst) { |
| 127 // This test has three icons each are marked with sizes set to the preferred | 129 // Each icon is marked with sizes that match the preferred icon size. |
| 128 // icon size for the associated density. | |
| 129 std::vector<gfx::Size> sizes_1; | 130 std::vector<gfx::Size> sizes_1; |
| 130 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), | 131 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), |
| 131 GetPreferredIconSizeInDp())); | 132 GetPreferredIconSizeInDp())); |
| 132 | 133 |
| 133 std::vector<gfx::Size> sizes_2; | 134 std::vector<gfx::Size> sizes_2; |
| 134 sizes_2.push_back(gfx::Size(GetPreferredIconSizeInDp() * 2, | 135 sizes_2.push_back(gfx::Size(GetPreferredIconSizeInDp() * 2, |
| 135 GetPreferredIconSizeInDp() * 2)); | 136 GetPreferredIconSizeInDp() * 2)); |
| 136 | 137 |
| 137 std::vector<gfx::Size> sizes_3; | 138 std::vector<gfx::Size> sizes_3; |
| 138 sizes_3.push_back(gfx::Size(GetPreferredIconSizeInDp() * 3, | 139 sizes_3.push_back(gfx::Size(GetPreferredIconSizeInDp() * 3, |
| 139 GetPreferredIconSizeInDp() * 3)); | 140 GetPreferredIconSizeInDp() * 3)); |
| 140 | 141 |
| 141 std::vector<content::Manifest::Icon> icons; | 142 std::vector<content::Manifest::Icon> icons; |
| 142 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes_1)); | 143 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1)); |
| 143 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes_2)); | 144 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_2)); |
| 144 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes_3)); | 145 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| 145 | 146 |
| 146 SetDisplayDeviceScaleFactor(1.0f); | 147 SetDisplayDeviceScaleFactor(1.0f); |
| 147 GURL url = FindBestMatchingIcon(icons); | 148 GURL url = FindBestMatchingIcon(icons); |
| 148 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | 149 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| 149 | 150 |
| 150 SetDisplayDeviceScaleFactor(2.0f); | 151 SetDisplayDeviceScaleFactor(2.0f); |
| 151 url = FindBestMatchingIcon(icons); | 152 url = FindBestMatchingIcon(icons); |
| 152 EXPECT_EQ("http://foo.com/icon_x2.png", url.spec()); | 153 EXPECT_EQ("http://foo.com/icon_x2.png", url.spec()); |
| 153 | 154 |
| 154 SetDisplayDeviceScaleFactor(3.0f); | 155 SetDisplayDeviceScaleFactor(3.0f); |
| 155 url = FindBestMatchingIcon(icons); | 156 url = FindBestMatchingIcon(icons); |
| 156 EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); | 157 EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 TEST_F(ManifestIconSelectorTest, PreferredSizeOfDefaultDensityIsUsedSecond) { | 160 TEST_F(ManifestIconSelectorTest, FirstIconWithPreferredSizeIsUsedFirst) { |
| 160 // This test has three icons. The first one is of density zero and is marked | 161 // This test has three icons. The first icon is going to be used because it |
| 161 // with three sizes which are the preferred icon size for density 1, 2 and 3. | 162 // has sizes which matches the preferred size for each device scale factor. |
| 162 // The icon for density 2 and 3 have a size set to 1024x1024. | |
| 163 // Regardless of the device scale factor, the icon of density 1 is going to be | |
| 164 // used because it matches the preferred size. | |
| 165 std::vector<gfx::Size> sizes_1; | 163 std::vector<gfx::Size> sizes_1; |
| 166 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), | 164 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), |
| 167 GetPreferredIconSizeInDp())); | 165 GetPreferredIconSizeInDp())); |
| 168 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() * 2, | 166 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() * 2, |
| 169 GetPreferredIconSizeInDp() * 2)); | 167 GetPreferredIconSizeInDp() * 2)); |
| 170 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() * 3, | 168 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() * 3, |
| 171 GetPreferredIconSizeInDp() * 3)); | 169 GetPreferredIconSizeInDp() * 3)); |
| 172 | 170 |
| 173 std::vector<gfx::Size> sizes_2; | 171 std::vector<gfx::Size> sizes_2; |
| 174 sizes_2.push_back(gfx::Size(1024, 1024)); | 172 sizes_2.push_back(gfx::Size(1024, 1024)); |
| 175 | 173 |
| 176 std::vector<gfx::Size> sizes_3; | 174 std::vector<gfx::Size> sizes_3; |
| 177 sizes_3.push_back(gfx::Size(1024, 1024)); | 175 sizes_3.push_back(gfx::Size(1024, 1024)); |
| 178 | 176 |
| 179 std::vector<content::Manifest::Icon> icons; | 177 std::vector<content::Manifest::Icon> icons; |
| 180 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes_1)); | 178 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1)); |
| 181 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes_2)); | 179 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_2)); |
| 182 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes_3)); | 180 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| 183 | 181 |
| 184 SetDisplayDeviceScaleFactor(1.0f); | 182 SetDisplayDeviceScaleFactor(1.0f); |
| 185 GURL url = FindBestMatchingIcon(icons); | 183 GURL url = FindBestMatchingIcon(icons); |
| 186 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | 184 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| 187 | 185 |
| 188 SetDisplayDeviceScaleFactor(2.0f); | 186 SetDisplayDeviceScaleFactor(2.0f); |
| 189 url = FindBestMatchingIcon(icons); | 187 url = FindBestMatchingIcon(icons); |
| 190 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | 188 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| 191 | 189 |
| 192 SetDisplayDeviceScaleFactor(3.0f); | 190 SetDisplayDeviceScaleFactor(3.0f); |
| 193 url = FindBestMatchingIcon(icons); | 191 url = FindBestMatchingIcon(icons); |
| 194 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | 192 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| 195 } | 193 } |
| 196 | 194 |
| 197 TEST_F(ManifestIconSelectorTest, DeviceDensityFirst) { | 195 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.
| |
| 198 // If there is no perfect icon but an icon of the current device density is | 196 // If there is no perfect icon, the smallest larger icon will be chosen. |
| 199 // present, it will be picked. | 197 std::vector<gfx::Size> sizes_1; |
| 200 // This test has three icons each are marked with sizes set to the preferred | 198 sizes_1.push_back(gfx::Size(90, 90)); |
| 201 // icon size for the associated density. | 199 |
| 202 std::vector<gfx::Size> sizes; | 200 std::vector<gfx::Size> sizes_2; |
| 203 sizes.push_back(gfx::Size(1024, 1024)); | 201 sizes_2.push_back(gfx::Size(128, 128)); |
| 202 | |
| 203 std::vector<gfx::Size> sizes_3; | |
| 204 sizes_3.push_back(gfx::Size(192, 192)); | |
| 205 | |
| 204 | 206 |
| 205 std::vector<content::Manifest::Icon> icons; | 207 std::vector<content::Manifest::Icon> icons; |
| 206 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); | 208 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1)); |
| 207 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes)); | 209 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_2)); |
| 208 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes)); | 210 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| 209 | 211 |
| 210 SetDisplayDeviceScaleFactor(1.0f); | 212 SetDisplayDeviceScaleFactor(1.0f); |
| 211 GURL url = FindBestMatchingIcon(icons); | 213 GURL url = FindBestMatchingIcon(icons); |
| 212 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | 214 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| 213 | 215 |
| 214 SetDisplayDeviceScaleFactor(2.0f); | 216 SetDisplayDeviceScaleFactor(2.0f); |
| 215 url = FindBestMatchingIcon(icons); | 217 url = FindBestMatchingIcon(icons); |
| 216 EXPECT_EQ("http://foo.com/icon_x2.png", url.spec()); | 218 EXPECT_EQ("http://foo.com/icon_x2.png", url.spec()); |
| 217 | 219 |
| 218 SetDisplayDeviceScaleFactor(3.0f); | 220 SetDisplayDeviceScaleFactor(3.0f); |
| 219 url = FindBestMatchingIcon(icons); | 221 url = FindBestMatchingIcon(icons); |
| 220 EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); | 222 EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| 221 } | 223 } |
| 222 | 224 |
| 223 TEST_F(ManifestIconSelectorTest, DeviceDensityFallback) { | 225 TEST_F(ManifestIconSelectorTest, CheckDifferentDeviceScaleFactors) { |
| 224 // If there is no perfect icon but and no icon of the current display density, | 226 // When an icon of the correct size has not been found, we fall back to the |
| 225 // an icon of density 1.0 will be used. | 227 // closest non-matching sizes. Make sure that the minimum passed is enforced. |
| 226 std::vector<gfx::Size> sizes; | |
| 227 sizes.push_back(gfx::Size(1024, 1024)); | |
| 228 | |
| 229 std::vector<content::Manifest::Icon> icons; | |
| 230 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); | |
| 231 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes)); | |
| 232 | |
| 233 SetDisplayDeviceScaleFactor(3.0f); | |
| 234 GURL url = FindBestMatchingIcon(icons); | |
| 235 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | |
| 236 } | |
| 237 | |
| 238 TEST_F(ManifestIconSelectorTest, DeviceDensityMatchRejectsTooSmall) { | |
| 239 // If we have to resort to density matching to find icons, then an icon of | |
| 240 // the correct size has not been found. Make sure that the minimum passed | |
| 241 // is enforced. | |
| 242 std::vector<gfx::Size> sizes_1_2; | 228 std::vector<gfx::Size> sizes_1_2; |
| 243 std::vector<gfx::Size> sizes_3; | 229 std::vector<gfx::Size> sizes_3; |
| 244 | 230 |
| 245 sizes_1_2.push_back(gfx::Size(47, 47)); | 231 sizes_1_2.push_back(gfx::Size(47, 47)); |
| 246 sizes_3.push_back(gfx::Size(95, 95)); | 232 sizes_3.push_back(gfx::Size(95, 95)); |
| 247 | 233 |
| 248 // Set to a value which will not affect the calculations. | 234 // Set to a value which will not affect the calculations. |
| 249 SetPreferredIconSizeInDp(1024); | 235 SetPreferredIconSizeInDp(1024); |
| 250 | 236 |
| 251 std::vector<content::Manifest::Icon> icons; | 237 std::vector<content::Manifest::Icon> icons; |
| 252 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes_1_2)); | 238 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes_1_2)); |
| 253 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes_1_2)); | 239 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", sizes_1_2)); |
| 254 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", 3.0, sizes_3)); | 240 icons.push_back(CreateIcon("http://foo.com/icon_x3.png", "", sizes_3)); |
| 255 | 241 |
| 256 // Nothing matches here because the minimum is 48. | 242 // Icon 3 should match. |
| 257 SetDisplayDeviceScaleFactor(1.0f); | 243 SetDisplayDeviceScaleFactor(1.0f); |
| 258 GURL url = FindBestMatchingIconWithMinimum(icons, 48); | 244 GURL url = FindBestMatchingIconWithMinimum(icons, 48); |
| 259 EXPECT_TRUE(url.is_empty()); | 245 EXPECT_EQ("http://foo.com/icon_x3.png", url.spec()); |
| 260 | 246 |
| 261 // Nothing matches here because the minimum is 48 again. | 247 // Nothing matches here because the minimum is 48 and all icon sizes are now |
| 248 // too small. | |
| 262 SetDisplayDeviceScaleFactor(2.0f); | 249 SetDisplayDeviceScaleFactor(2.0f); |
| 263 url = FindBestMatchingIconWithMinimum(icons, 48); | 250 url = FindBestMatchingIconWithMinimum(icons, 48); |
| 264 EXPECT_TRUE(url.is_empty()); | 251 EXPECT_TRUE(url.is_empty()); |
| 265 | 252 |
| 266 // Nothing matches here as the minimum is 96. | 253 // Nothing matches here as the minimum is 96. |
| 267 SetDisplayDeviceScaleFactor(3.0f); | 254 SetDisplayDeviceScaleFactor(3.0f); |
| 268 url = FindBestMatchingIconWithMinimum(icons, 96); | 255 url = FindBestMatchingIconWithMinimum(icons, 96); |
| 269 EXPECT_TRUE(url.is_empty()); | 256 EXPECT_TRUE(url.is_empty()); |
| 270 } | 257 } |
| 271 | 258 |
| 272 TEST_F(ManifestIconSelectorTest, IdealVeryCloseToMinimumMatches) { | 259 TEST_F(ManifestIconSelectorTest, IdealVeryCloseToMinimumMatches) { |
| 273 std::vector<gfx::Size> sizes; | 260 std::vector<gfx::Size> sizes; |
| 274 sizes.push_back(gfx::Size(2, 2)); | 261 sizes.push_back(gfx::Size(2, 2)); |
| 262 SetPreferredIconSizeInDp(2); | |
| 275 | 263 |
| 276 std::vector<content::Manifest::Icon> icons; | 264 std::vector<content::Manifest::Icon> icons; |
| 277 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); | 265 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes)); |
| 278 | 266 |
| 279 SetDisplayDeviceScaleFactor(1.0f); | 267 SetDisplayDeviceScaleFactor(1.0f); |
| 280 GURL url = FindBestMatchingIconWithMinimum(icons, 1); | 268 GURL url = FindBestMatchingIconWithMinimum(icons, 1); |
| 281 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | 269 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| 282 } | 270 } |
| 283 | 271 |
| 284 TEST_F(ManifestIconSelectorTest, SizeVeryCloseToMinimumMatches) { | 272 TEST_F(ManifestIconSelectorTest, SizeVeryCloseToMinimumMatches) { |
| 285 std::vector<gfx::Size> sizes; | 273 std::vector<gfx::Size> sizes; |
| 286 sizes.push_back(gfx::Size(2, 2)); | 274 sizes.push_back(gfx::Size(2, 2)); |
| 287 | 275 |
| 288 SetPreferredIconSizeInDp(200); | 276 SetPreferredIconSizeInDp(200); |
| 289 | 277 |
| 290 std::vector<content::Manifest::Icon> icons; | 278 std::vector<content::Manifest::Icon> icons; |
| 291 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", 1.0, sizes)); | 279 icons.push_back(CreateIcon("http://foo.com/icon_x1.png", "", sizes)); |
| 292 | 280 |
| 293 SetDisplayDeviceScaleFactor(1.0f); | 281 SetDisplayDeviceScaleFactor(1.0f); |
| 294 GURL url = FindBestMatchingIconWithMinimum(icons, 1); | 282 GURL url = FindBestMatchingIconWithMinimum(icons, 1); |
| 295 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); | 283 EXPECT_EQ("http://foo.com/icon_x1.png", url.spec()); |
| 296 } | 284 } |
| 297 | 285 |
| 298 TEST_F(ManifestIconSelectorTest, DoNotUseOtherDensities) { | |
| 299 // If there are only icons of densities that are not the current display | |
| 300 // density or the default density, they are ignored. | |
| 301 std::vector<gfx::Size> sizes; | |
| 302 sizes.push_back(gfx::Size(1024, 1024)); | |
| 303 | |
| 304 std::vector<content::Manifest::Icon> icons; | |
| 305 icons.push_back(CreateIcon("http://foo.com/icon_x2.png", "", 2.0, sizes)); | |
| 306 | |
| 307 SetDisplayDeviceScaleFactor(3.0f); | |
| 308 GURL url = FindBestMatchingIcon(icons); | |
| 309 EXPECT_TRUE(url.is_empty()); | |
| 310 } | |
| 311 | |
| 312 TEST_F(ManifestIconSelectorTest, NotSquareIconsAreIgnored) { | 286 TEST_F(ManifestIconSelectorTest, NotSquareIconsAreIgnored) { |
| 313 std::vector<gfx::Size> sizes; | 287 std::vector<gfx::Size> sizes; |
| 314 sizes.push_back(gfx::Size(1024, 1023)); | 288 sizes.push_back(gfx::Size(1024, 1023)); |
| 315 | 289 |
| 316 std::vector<content::Manifest::Icon> icons; | 290 std::vector<content::Manifest::Icon> icons; |
| 317 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes)); | 291 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes)); |
| 318 | 292 |
| 319 GURL url = FindBestMatchingIcon(icons); | 293 GURL url = FindBestMatchingIcon(icons); |
| 320 EXPECT_TRUE(url.is_empty()); | 294 EXPECT_TRUE(url.is_empty()); |
| 321 } | 295 } |
| 322 | 296 |
| 323 TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { | 297 TEST_F(ManifestIconSelectorTest, ClosestIconToPreferred) { |
| 324 // This test verifies ManifestIconSelector::FindBestMatchingIcon by passing | 298 // Ensure ManifestIconSelector::FindBestMatchingIcon selects the closest icon |
| 325 // different icon sizes and checking which one is picked. | 299 // to the preferred size when presented with a number of options. |
| 326 // The Device Scale Factor is 1.0 and the preferred icon size is returned by | |
| 327 // GetPreferredIconSizeInDp(). | |
| 328 int very_small = GetPreferredIconSizeInDp() / 4; | 300 int very_small = GetPreferredIconSizeInDp() / 4; |
| 329 int small_size = GetPreferredIconSizeInDp() / 2; | 301 int small_size = GetPreferredIconSizeInDp() / 2; |
| 330 int bit_small = GetPreferredIconSizeInDp() - 1; | 302 int bit_small = GetPreferredIconSizeInDp() - 1; |
| 331 int bit_big = GetPreferredIconSizeInDp() + 1; | 303 int bit_big = GetPreferredIconSizeInDp() + 1; |
| 332 int big = GetPreferredIconSizeInDp() * 2; | 304 int big = GetPreferredIconSizeInDp() * 2; |
| 333 int very_big = GetPreferredIconSizeInDp() * 4; | 305 int very_big = GetPreferredIconSizeInDp() * 4; |
| 334 | 306 |
| 307 SetDisplayDeviceScaleFactor(1.0f); | |
| 335 // (very_small, bit_small) => bit_small | 308 // (very_small, bit_small) => bit_small |
| 336 { | 309 { |
| 337 std::vector<gfx::Size> sizes_1; | 310 std::vector<gfx::Size> sizes_1; |
| 338 sizes_1.push_back(gfx::Size(very_small, very_small)); | 311 sizes_1.push_back(gfx::Size(very_small, very_small)); |
| 339 | 312 |
| 340 std::vector<gfx::Size> sizes_2; | 313 std::vector<gfx::Size> sizes_2; |
| 341 sizes_2.push_back(gfx::Size(bit_small, bit_small)); | 314 sizes_2.push_back(gfx::Size(bit_small, bit_small)); |
| 342 | 315 |
| 343 std::vector<content::Manifest::Icon> icons; | 316 std::vector<content::Manifest::Icon> icons; |
| 344 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); | 317 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| 345 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); | 318 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| 346 | 319 |
| 347 GURL url = FindBestMatchingIcon(icons); | 320 GURL url = FindBestMatchingIcon(icons); |
| 348 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 321 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 349 } | 322 } |
| 350 | 323 |
| 351 // (very_small, bit_small, smaller) => bit_small | 324 // (very_small, bit_small, small_size) => bit_small |
| 352 { | 325 { |
| 353 std::vector<gfx::Size> sizes_1; | 326 std::vector<gfx::Size> sizes_1; |
| 354 sizes_1.push_back(gfx::Size(very_small, very_small)); | 327 sizes_1.push_back(gfx::Size(very_small, very_small)); |
| 355 | 328 |
| 356 std::vector<gfx::Size> sizes_2; | 329 std::vector<gfx::Size> sizes_2; |
| 357 sizes_2.push_back(gfx::Size(bit_small, bit_small)); | 330 sizes_2.push_back(gfx::Size(bit_small, bit_small)); |
| 358 | 331 |
| 359 std::vector<gfx::Size> sizes_3; | 332 std::vector<gfx::Size> sizes_3; |
| 360 sizes_3.push_back(gfx::Size(small_size, small_size)); | 333 sizes_3.push_back(gfx::Size(small_size, small_size)); |
| 361 | 334 |
| 362 std::vector<content::Manifest::Icon> icons; | 335 std::vector<content::Manifest::Icon> icons; |
| 363 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); | 336 icons.push_back(CreateIcon("http://foo.com/icon_no_1.png", "", sizes_1)); |
| 364 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); | 337 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| 365 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_3)); | 338 icons.push_back(CreateIcon("http://foo.com/icon_no_2.png", "", sizes_3)); |
| 366 | 339 |
| 367 GURL url = FindBestMatchingIcon(icons); | 340 GURL url = FindBestMatchingIcon(icons); |
| 368 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 341 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 369 } | 342 } |
| 370 | 343 |
| 371 // (very_big, big) => big | 344 // (very_big, big) => big |
| 372 { | 345 { |
| 373 std::vector<gfx::Size> sizes_1; | 346 std::vector<gfx::Size> sizes_1; |
| 374 sizes_1.push_back(gfx::Size(very_big, very_big)); | 347 sizes_1.push_back(gfx::Size(very_big, very_big)); |
| 375 | 348 |
| 376 std::vector<gfx::Size> sizes_2; | 349 std::vector<gfx::Size> sizes_2; |
| 377 sizes_2.push_back(gfx::Size(big, big)); | 350 sizes_2.push_back(gfx::Size(big, big)); |
| 378 | 351 |
| 379 std::vector<content::Manifest::Icon> icons; | 352 std::vector<content::Manifest::Icon> icons; |
| 380 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); | 353 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| 381 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); | 354 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| 382 | 355 |
| 383 GURL url = FindBestMatchingIcon(icons); | 356 GURL url = FindBestMatchingIcon(icons); |
| 384 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 357 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 385 } | 358 } |
| 386 | 359 |
| 387 // (very_big, big, bit_big) => bit_big | 360 // (very_big, big, bit_big) => bit_big |
| 388 { | 361 { |
| 389 std::vector<gfx::Size> sizes_1; | 362 std::vector<gfx::Size> sizes_1; |
| 390 sizes_1.push_back(gfx::Size(very_big, very_big)); | 363 sizes_1.push_back(gfx::Size(very_big, very_big)); |
| 391 | 364 |
| 392 std::vector<gfx::Size> sizes_2; | 365 std::vector<gfx::Size> sizes_2; |
| 393 sizes_2.push_back(gfx::Size(big, big)); | 366 sizes_2.push_back(gfx::Size(big, big)); |
| 394 | 367 |
| 395 std::vector<gfx::Size> sizes_3; | 368 std::vector<gfx::Size> sizes_3; |
| 396 sizes_3.push_back(gfx::Size(bit_big, bit_big)); | 369 sizes_3.push_back(gfx::Size(bit_big, bit_big)); |
| 397 | 370 |
| 398 std::vector<content::Manifest::Icon> icons; | 371 std::vector<content::Manifest::Icon> icons; |
| 399 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); | 372 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| 400 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_2)); | 373 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_2)); |
| 401 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_3)); | 374 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_3)); |
| 402 | 375 |
| 403 GURL url = FindBestMatchingIcon(icons); | 376 GURL url = FindBestMatchingIcon(icons); |
| 404 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 377 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 405 } | 378 } |
| 406 | 379 |
| 407 // (bit_small, very_big) => very_big | 380 // (bit_small, very_big) => very_big |
| 408 { | 381 { |
| 409 std::vector<gfx::Size> sizes_1; | 382 std::vector<gfx::Size> sizes_1; |
| 410 sizes_1.push_back(gfx::Size(bit_small, bit_small)); | 383 sizes_1.push_back(gfx::Size(bit_small, bit_small)); |
| 411 | 384 |
| 412 std::vector<gfx::Size> sizes_2; | 385 std::vector<gfx::Size> sizes_2; |
| 413 sizes_2.push_back(gfx::Size(very_big, very_big)); | 386 sizes_2.push_back(gfx::Size(very_big, very_big)); |
| 414 | 387 |
| 415 std::vector<content::Manifest::Icon> icons; | 388 std::vector<content::Manifest::Icon> icons; |
| 416 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); | 389 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| 417 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); | 390 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| 418 | 391 |
| 419 GURL url = FindBestMatchingIcon(icons); | 392 GURL url = FindBestMatchingIcon(icons); |
| 420 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 393 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 421 } | 394 } |
| 422 | 395 |
| 423 // (bit_small, bit_big) => bit_big | 396 // (bit_small, bit_big) => bit_big |
| 424 { | 397 { |
| 425 std::vector<gfx::Size> sizes_1; | 398 std::vector<gfx::Size> sizes_1; |
| 426 sizes_1.push_back(gfx::Size(bit_small, bit_small)); | 399 sizes_1.push_back(gfx::Size(bit_small, bit_small)); |
| 427 | 400 |
| 428 std::vector<gfx::Size> sizes_2; | 401 std::vector<gfx::Size> sizes_2; |
| 429 sizes_2.push_back(gfx::Size(bit_big, bit_big)); | 402 sizes_2.push_back(gfx::Size(bit_big, bit_big)); |
| 430 | 403 |
| 431 std::vector<content::Manifest::Icon> icons; | 404 std::vector<content::Manifest::Icon> icons; |
| 432 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); | 405 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| 433 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); | 406 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| 434 | 407 |
| 435 GURL url = FindBestMatchingIcon(icons); | 408 GURL url = FindBestMatchingIcon(icons); |
| 436 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 409 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 437 } | 410 } |
| 438 } | 411 } |
| 439 | 412 |
| 440 TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { | 413 TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) { |
| 441 // 'any' (ie. gfx::Size(0,0)) should be used if there is no icon of a | 414 // 'any' (ie. gfx::Size(0,0)) should be used if there is no icon of a |
| 442 // preferred size. An icon with the current device scale factor is preferred | 415 // preferred size. An icon with the current device scale factor is preferred |
| 443 // over one with the default density. | 416 // over one with the default density. |
| 444 | 417 |
| 445 // 'any' with preferred size => preferred size | 418 // Icon with 'any' and icon with preferred size => preferred size is chosen. |
| 446 { | 419 { |
| 447 std::vector<gfx::Size> sizes_1; | 420 std::vector<gfx::Size> sizes_1; |
| 448 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), | 421 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(), |
| 449 GetPreferredIconSizeInDp())); | 422 GetPreferredIconSizeInDp())); |
| 450 std::vector<gfx::Size> sizes_2; | 423 std::vector<gfx::Size> sizes_2; |
| 451 sizes_2.push_back(gfx::Size(0, 0)); | 424 sizes_2.push_back(gfx::Size(0, 0)); |
| 452 | 425 |
| 453 std::vector<content::Manifest::Icon> icons; | 426 std::vector<content::Manifest::Icon> icons; |
| 454 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_1)); | 427 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_1)); |
| 455 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_2)); | 428 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_2)); |
| 456 | 429 |
| 457 GURL url = FindBestMatchingIcon(icons); | 430 GURL url = FindBestMatchingIcon(icons); |
| 458 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 431 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 459 } | 432 } |
| 460 | 433 |
| 461 // 'any' with nearly preferred size => any | 434 // Icon with 'any' and icon larger than preferred size => any is chosen. |
| 462 { | 435 { |
| 463 std::vector<gfx::Size> sizes_1; | 436 std::vector<gfx::Size> sizes_1; |
| 464 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() + 1, | 437 sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() + 1, |
| 465 GetPreferredIconSizeInDp() + 1)); | 438 GetPreferredIconSizeInDp() + 1)); |
| 466 std::vector<gfx::Size> sizes_2; | 439 std::vector<gfx::Size> sizes_2; |
| 467 sizes_2.push_back(gfx::Size(0, 0)); | 440 sizes_2.push_back(gfx::Size(0, 0)); |
| 468 | 441 |
| 469 std::vector<content::Manifest::Icon> icons; | 442 std::vector<content::Manifest::Icon> icons; |
| 470 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1)); | 443 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", sizes_1)); |
| 471 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_2)); | 444 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes_2)); |
| 472 | 445 |
| 473 GURL url = FindBestMatchingIcon(icons); | 446 GURL url = FindBestMatchingIcon(icons); |
| 474 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 447 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 475 } | 448 } |
| 476 | 449 |
| 477 // 'any' on default density and current density => current density. | 450 // Multiple icons with 'any' => the last one is chosen. |
| 478 { | 451 { |
| 479 std::vector<gfx::Size> sizes; | 452 std::vector<gfx::Size> sizes; |
| 480 sizes.push_back(gfx::Size(0, 0)); | 453 sizes.push_back(gfx::Size(0, 0)); |
| 481 | 454 |
| 482 std::vector<content::Manifest::Icon> icons; | 455 std::vector<content::Manifest::Icon> icons; |
| 483 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes)); | 456 icons.push_back(CreateIcon("http://foo.com/icon_no1.png", "", sizes)); |
| 484 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 3.0, sizes)); | 457 icons.push_back(CreateIcon("http://foo.com/icon_no2.png", "", sizes)); |
| 458 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes)); | |
| 485 | 459 |
| 486 SetDisplayDeviceScaleFactor(3.0f); | 460 SetDisplayDeviceScaleFactor(3.0f); |
| 487 GURL url = FindBestMatchingIcon(icons); | 461 GURL url = FindBestMatchingIcon(icons); |
| 488 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 462 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 489 } | 463 } |
| 490 } | 464 } |
| OLD | NEW |