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

Unified Diff: ui/gfx/screen_unittest.cc

Issue 1133523003: Ensure that forced device-scale-factor is taken into account. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/screen_unittest.cc
diff --git a/ui/gfx/screen_unittest.cc b/ui/gfx/screen_unittest.cc
index db5a03ffec90ad987f9886e458d74339c558ef01..7dc52faeae079ca8e701fe1be82f3ced9e161b28 100644
--- a/ui/gfx/screen_unittest.cc
+++ b/ui/gfx/screen_unittest.cc
@@ -4,7 +4,10 @@
#include "ui/gfx/screen.h"
+#include "base/command_line.h"
+#include "base/strings/stringprintf.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/switches.h"
namespace {
@@ -21,4 +24,26 @@ TEST(ScreenTest, GetNumDisplays) {
EXPECT_GE(gfx::Screen::GetNativeScreen()->GetNumDisplays(), 1);
}
+TEST(ScreenTest, ForceDeviceScaleFactor) {
+ gfx::Display::ResetForceDeviceScaleFactorForTesting();
+
+ const gfx::Display old_display =
+ gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
+ const float new_scale = 1.5f * old_display.device_scale_factor();
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
+ base::StringPrintf("%f", new_scale));
+ EXPECT_TRUE(gfx::Display::HasForceDeviceScaleFactor());
+ EXPECT_EQ(new_scale, gfx::Display::GetForcedDeviceScaleFactor());
+
+ const gfx::Display new_display =
+ gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
+ EXPECT_EQ(new_scale, new_display.device_scale_factor());
+ EXPECT_EQ(old_display.size().width(), 1.5f * new_display.size().width());
+ EXPECT_EQ(old_display.size().height(), 1.5f * new_display.size().width());
+
+ gfx::Display::ResetForceDeviceScaleFactorForTesting();
+}
+
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698