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/display/screen.h" |
14 #include "ui/gfx/test/test_screen.h" | 14 #include "ui/gfx/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)); |
25 gfx::Screen::SetScreenInstance(&test_screen_); | 25 display::Screen::SetScreenInstance(&test_screen_); |
26 } | 26 } |
27 | 27 |
28 ~ManifestIconSelectorTest() override { | 28 ~ManifestIconSelectorTest() override { |
29 gfx::Screen::SetScreenInstance(nullptr); | 29 display::Screen::SetScreenInstance(nullptr); |
30 } | 30 } |
31 | 31 |
32 void SetUp() override { | 32 void SetUp() override { |
33 SetPreferredIconSizeInDp(DEFAULT_PREFERRED_ICON_SIZE); | 33 SetPreferredIconSizeInDp(DEFAULT_PREFERRED_ICON_SIZE); |
34 } | 34 } |
35 | 35 |
36 GURL FindBestMatchingIconWithMinimum( | 36 GURL FindBestMatchingIconWithMinimum( |
37 const std::vector<content::Manifest::Icon>& icons, | 37 const std::vector<content::Manifest::Icon>& icons, |
38 int minimum_icon_size_in_dp) { | 38 int minimum_icon_size_in_dp) { |
39 return ManifestIconSelector::FindBestMatchingIcon( | 39 return ManifestIconSelector::FindBestMatchingIcon( |
(...skipping 415 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 |