| 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/screen_type_delegate.h" | |
| 15 #include "ui/gfx/test/test_screen.h" | 14 #include "ui/gfx/test/test_screen.h" |
| 16 | 15 |
| 17 class ManifestIconSelectorTest : public testing::Test { | 16 class ManifestIconSelectorTest : public testing::Test { |
| 18 protected: | 17 protected: |
| 19 ManifestIconSelectorTest() { | 18 ManifestIconSelectorTest() { |
| 20 test_screen_.display()->set_id(0x1337); | 19 test_screen_.display()->set_id(0x1337); |
| 21 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); | 20 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); |
| 21 gfx::Screen::SetScreenInstance(&test_screen_); |
| 22 } | 22 } |
| 23 | 23 |
| 24 ~ManifestIconSelectorTest() override {} | 24 ~ManifestIconSelectorTest() override { |
| 25 gfx::Screen::SetScreenInstance(nullptr); |
| 26 } |
| 25 | 27 |
| 26 GURL FindBestMatchingIconWithMinimum( | 28 GURL FindBestMatchingIconWithMinimum( |
| 27 const std::vector<content::Manifest::Icon>& icons, | 29 const std::vector<content::Manifest::Icon>& icons, |
| 28 int minimum_icon_size_in_dp) { | 30 int minimum_icon_size_in_dp) { |
| 29 return ManifestIconSelector::FindBestMatchingIcon( | 31 return ManifestIconSelector::FindBestMatchingIcon( |
| 30 icons, GetPreferredIconSizeInDp(), | 32 icons, GetPreferredIconSizeInDp(), minimum_icon_size_in_dp); |
| 31 minimum_icon_size_in_dp, &test_screen_); | |
| 32 } | 33 } |
| 33 | 34 |
| 34 GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { | 35 GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { |
| 35 return FindBestMatchingIconWithMinimum(icons, 0); | 36 return FindBestMatchingIconWithMinimum(icons, 0); |
| 36 } | 37 } |
| 37 | 38 |
| 38 void SetDisplayDeviceScaleFactor(float device_scale_factor) { | 39 void SetDisplayDeviceScaleFactor(float device_scale_factor) { |
| 39 test_screen_.display()->set_device_scale_factor(device_scale_factor); | 40 test_screen_.display()->set_device_scale_factor(device_scale_factor); |
| 40 } | 41 } |
| 41 | 42 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 481 |
| 481 std::vector<content::Manifest::Icon> icons; | 482 std::vector<content::Manifest::Icon> icons; |
| 482 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes)); | 483 icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes)); |
| 483 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 3.0, sizes)); | 484 icons.push_back(CreateIcon("http://foo.com/icon.png", "", 3.0, sizes)); |
| 484 | 485 |
| 485 SetDisplayDeviceScaleFactor(3.0f); | 486 SetDisplayDeviceScaleFactor(3.0f); |
| 486 GURL url = FindBestMatchingIcon(icons); | 487 GURL url = FindBestMatchingIcon(icons); |
| 487 EXPECT_EQ("http://foo.com/icon.png", url.spec()); | 488 EXPECT_EQ("http://foo.com/icon.png", url.spec()); |
| 488 } | 489 } |
| 489 } | 490 } |
| OLD | NEW |