| 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/display/screen.h" | 13 #include "ui/display/screen.h" |
| 14 #include "ui/gfx/test/test_screen.h" | 14 #include "ui/display/test/test_screen.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 const int DEFAULT_PREFERRED_ICON_SIZE = 48; | 17 const int DEFAULT_PREFERRED_ICON_SIZE = 48; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class ManifestIconSelectorTest : public testing::Test { | 20 class ManifestIconSelectorTest : public testing::Test { |
| 21 protected: | 21 protected: |
| 22 ManifestIconSelectorTest() { | 22 ManifestIconSelectorTest() { |
| 23 test_screen_.display()->set_id(0x1337); | 23 test_screen_.display()->set_id(0x1337); |
| 24 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); | 24 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 content::Manifest::Icon icon; | 63 content::Manifest::Icon icon; |
| 64 icon.src = GURL(url); | 64 icon.src = GURL(url); |
| 65 if (!type.empty()) | 65 if (!type.empty()) |
| 66 icon.type = base::NullableString16(base::UTF8ToUTF16(type), false); | 66 icon.type = base::NullableString16(base::UTF8ToUTF16(type), false); |
| 67 icon.sizes = sizes; | 67 icon.sizes = sizes; |
| 68 | 68 |
| 69 return icon; | 69 return icon; |
| 70 } | 70 } |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 gfx::test::TestScreen test_screen_; | 73 display::test::TestScreen test_screen_; |
| 74 int preferred_icon_size_ = DEFAULT_PREFERRED_ICON_SIZE; | 74 int preferred_icon_size_ = DEFAULT_PREFERRED_ICON_SIZE; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelectorTest); | 76 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelectorTest); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 TEST_F(ManifestIconSelectorTest, NoIcons) { | 79 TEST_F(ManifestIconSelectorTest, NoIcons) { |
| 80 // No icons should return the empty URL. | 80 // No icons should return the empty URL. |
| 81 std::vector<content::Manifest::Icon> icons; | 81 std::vector<content::Manifest::Icon> icons; |
| 82 GURL url = FindBestMatchingIcon(icons); | 82 GURL url = FindBestMatchingIcon(icons); |
| 83 EXPECT_TRUE(url.is_empty()); | 83 EXPECT_TRUE(url.is_empty()); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 std::vector<content::Manifest::Icon> icons; | 455 std::vector<content::Manifest::Icon> icons; |
| 456 icons.push_back(CreateIcon("http://foo.com/icon_no1.png", "", sizes)); | 456 icons.push_back(CreateIcon("http://foo.com/icon_no1.png", "", sizes)); |
| 457 icons.push_back(CreateIcon("http://foo.com/icon_no2.png", "", sizes)); | 457 icons.push_back(CreateIcon("http://foo.com/icon_no2.png", "", sizes)); |
| 458 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes)); | 458 icons.push_back(CreateIcon("http://foo.com/icon.png", "", sizes)); |
| 459 | 459 |
| 460 SetDisplayDeviceScaleFactor(3.0f); | 460 SetDisplayDeviceScaleFactor(3.0f); |
| 461 GURL url = FindBestMatchingIcon(icons); | 461 GURL url = FindBestMatchingIcon(icons); |
| 462 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 462 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 463 } | 463 } |
| 464 } | 464 } |
| OLD | NEW |