Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(853)

Unified Diff: chrome/browser/manifest/manifest_icon_selector_unittest.cc

Issue 1182303005: Fixed the Touchscreen.TouchEventsEnabled histogram to record the correct values on X11 and Ozone ba… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added logging.h include to device_data_manager_test_api_stub.cc. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 de0d394c2580eede65067ac131c43d23545584fc..cff4263a61b2b4c4bee34e54d036b466339bcdb2 100644
--- a/chrome/browser/manifest/manifest_icon_selector_unittest.cc
+++ b/chrome/browser/manifest/manifest_icon_selector_unittest.cc
@@ -4,10 +4,14 @@
#include "chrome/browser/manifest/manifest_icon_selector.h"
+#include <string>
+#include <vector>
+
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/screen_type_delegate.h"
+#include "ui/gfx/test/test_screen.h"
namespace {
@@ -15,67 +19,22 @@ const int kPreferredIconSize = 48;
}
-// A dummy implementation of gfx::Screen, since ManifestIconSelector needs
-// access to a gfx::Display's device scale factor.
-// This is inspired by web_contents_video_capture_device_unittest.cc
-// A bug has been opened to merge all those mocks: http://crbug.com/417227
-class FakeScreen : public gfx::Screen {
- public:
- FakeScreen() : display_(0x1337, gfx::Rect(0, 0, 2560, 1440)) {
- }
- ~FakeScreen() override {}
-
- void SetDisplayDeviceScaleFactor(float device_scale_factor) {
- display_.set_device_scale_factor(device_scale_factor);
- }
-
- // gfx::Screen implementation (only what's needed for testing).
- gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
- gfx::NativeWindow GetWindowUnderCursor() override { return nullptr; }
- gfx::NativeWindow GetWindowAtScreenPoint(
- const gfx::Point& point) override { return nullptr; }
- int GetNumDisplays() const override { return 1; }
- std::vector<gfx::Display> GetAllDisplays() const override {
- return std::vector<gfx::Display>(1, display_);
- }
- gfx::Display GetDisplayNearestWindow(
- gfx::NativeView view) const override {
- return display_;
- }
- gfx::Display GetDisplayNearestPoint(
- const gfx::Point& point) const override {
- return display_;
- }
- gfx::Display GetDisplayMatching(
- const gfx::Rect& match_rect) const override {
- return display_;
- }
- gfx::Display GetPrimaryDisplay() const override {
- return display_;
- }
- void AddObserver(gfx::DisplayObserver* observer) override {}
- void RemoveObserver(gfx::DisplayObserver* observer) override {}
-
- private:
- gfx::Display display_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeScreen);
-};
-
class ManifestIconSelectorTest : public testing::Test {
protected:
- ManifestIconSelectorTest() {}
+ ManifestIconSelectorTest() {
+ test_screen_.display()->set_id(0x1337);
+ test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440));
+ }
+
~ManifestIconSelectorTest() override {}
GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) {
return ManifestIconSelector::FindBestMatchingIcon(
- icons,
- GetPreferredIconSizeInDp(),
- &fake_screen_);
+ icons, GetPreferredIconSizeInDp(), &test_screen_);
}
void SetDisplayDeviceScaleFactor(float device_scale_factor) {
- fake_screen_.SetDisplayDeviceScaleFactor(device_scale_factor);
+ test_screen_.display()->set_device_scale_factor(device_scale_factor);
}
static int GetPreferredIconSizeInDp() {
@@ -98,7 +57,7 @@ class ManifestIconSelectorTest : public testing::Test {
}
private:
- FakeScreen fake_screen_;
+ gfx::test::TestScreen test_screen_;
DISALLOW_COPY_AND_ASSIGN(ManifestIconSelectorTest);
};
@@ -421,7 +380,7 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) {
sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp(),
GetPreferredIconSizeInDp()));
std::vector<gfx::Size> sizes_2;
- sizes_2.push_back(gfx::Size(0,0));
+ sizes_2.push_back(gfx::Size(0, 0));
std::vector<content::Manifest::Icon> icons;
icons.push_back(CreateIcon("http://foo.com/icon.png", "", 1.0, sizes_1));
@@ -437,7 +396,7 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) {
sizes_1.push_back(gfx::Size(GetPreferredIconSizeInDp() + 1,
GetPreferredIconSizeInDp() + 1));
std::vector<gfx::Size> sizes_2;
- sizes_2.push_back(gfx::Size(0,0));
+ sizes_2.push_back(gfx::Size(0, 0));
std::vector<content::Manifest::Icon> icons;
icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes_1));
@@ -450,7 +409,7 @@ TEST_F(ManifestIconSelectorTest, UseAnyIfNoPreferredSize) {
// 'any' on default density and current density => current density.
{
std::vector<gfx::Size> sizes;
- sizes.push_back(gfx::Size(0,0));
+ sizes.push_back(gfx::Size(0, 0));
std::vector<content::Manifest::Icon> icons;
icons.push_back(CreateIcon("http://foo.com/icon_no.png", "", 1.0, sizes));
« no previous file with comments | « no previous file | chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698