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

Unified Diff: ui/base/l10n/l10n_util_win_unittest.cc

Issue 2695523002: Fix font sizes being incorrect when using --force-device-scale-factor. (Closed)
Patch Set: fix test link Created 3 years, 10 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 | « ui/base/l10n/l10n_util_win.cc ('k') | ui/display/win/dpi.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/l10n_util_win_unittest.cc
diff --git a/ui/base/l10n/l10n_util_win_unittest.cc b/ui/base/l10n/l10n_util_win_unittest.cc
index 2f1da59247164f7734cf15ee4d6661993991e6ac..29ab718535d8323afa1279cca3aa05d334713c35 100644
--- a/ui/base/l10n/l10n_util_win_unittest.cc
+++ b/ui/base/l10n/l10n_util_win_unittest.cc
@@ -6,9 +6,13 @@
#include <windows.h>
+#include "base/command_line.h"
#include "base/win/win_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+#include "ui/display/display.h"
+#include "ui/display/display_switches.h"
+#include "ui/display/win/screen_win.h"
typedef PlatformTest L10nUtilWinTest;
@@ -34,3 +38,23 @@ TEST_F(L10nUtilWinTest, TestDPIScaling) {
l10n_util::AdjustUIFontForDIP(1.8f, &lf);
EXPECT_NEAR(size, lf.lfHeight, 1);
}
+
+// Test for crbug.com/675933. Since font size is a Windows metric we need to
+// normalize to DIPs based on the real device scale factor, not the forced one.
+TEST_F(L10nUtilWinTest, TestForcedScaling) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kForceDeviceScaleFactor, "4");
+ display::Display::ResetForceDeviceScaleFactorForTesting();
+
+ NONCLIENTMETRICS_XP metrics;
+ base::win::GetNonClientMetrics(&metrics);
+ LOGFONT lf = metrics.lfMessageFont;
+
+ // Set the font size to an arbitrary value and make sure it comes through
+ // correctly on the other end.
+ constexpr int test_font_size = 18;
+ lf.lfHeight = test_font_size;
+ l10n_util::AdjustUIFont(&lf);
+ EXPECT_EQ(test_font_size / display::win::ScreenWin::GetSystemScaleFactor(),
+ lf.lfHeight);
+}
« no previous file with comments | « ui/base/l10n/l10n_util_win.cc ('k') | ui/display/win/dpi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698