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

Unified Diff: ash/display/display_manager_unittest.cc

Issue 417113012: Introduce user customization of external HighDPI mode for 4K monitor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 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 | « ash/display/display_manager.cc ('k') | ash/display/resolution_notification_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_manager_unittest.cc
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
index 55ccd03a6c856ea2364c4d1c5fba4cc4e62d90d6..2d3fc3e185920c9ce9196ec2f3398dbc1d5b649f 100644
--- a/ash/display/display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -736,13 +736,19 @@ TEST_F(DisplayManagerTest, DontRememberBestResolution) {
display_manager()->OnNativeDisplaysChanged(display_info_list);
DisplayMode mode;
+ DisplayMode expected_mode;
+ expected_mode.size = gfx::Size(1000, 500);
EXPECT_FALSE(
display_manager()->GetSelectedModeForDisplayId(display_id, &mode));
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
// Unsupported resolution.
display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 4000));
EXPECT_FALSE(
display_manager()->GetSelectedModeForDisplayId(display_id, &mode));
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
// Supported resolution.
display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 300));
@@ -751,6 +757,9 @@ TEST_F(DisplayManagerTest, DontRememberBestResolution) {
EXPECT_EQ("800x300", mode.size.ToString());
EXPECT_EQ(59.0f, mode.refresh_rate);
EXPECT_FALSE(mode.native);
+ expected_mode.size = gfx::Size(800, 300);
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
// Best resolution.
display_manager()->SetDisplayResolution(display_id, gfx::Size(1000, 500));
@@ -759,6 +768,9 @@ TEST_F(DisplayManagerTest, DontRememberBestResolution) {
EXPECT_EQ("1000x500", mode.size.ToString());
EXPECT_EQ(58.0f, mode.refresh_rate);
EXPECT_TRUE(mode.native);
+ expected_mode.size = gfx::Size(1000, 500);
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
}
TEST_F(DisplayManagerTest, ResolutionFallback) {
@@ -965,6 +977,88 @@ TEST_F(DisplayManagerTest, UIScale) {
EXPECT_EQ("1280x850", display.bounds().size().ToString());
}
+TEST_F(DisplayManagerTest, UIScaleWithDisplayMode) {
+ int display_id = 1000;
+
+ // Setup the display modes with UI-scale.
+ DisplayInfo native_display_info =
+ CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800));
+ std::vector<DisplayMode> display_modes;
+ const DisplayMode base_mode(gfx::Size(1280, 800), 60.0f, false, false);
+ std::vector<float> scales =
+ DisplayManager::GetScalesForDisplay(native_display_info);
+ for (size_t i = 0; i < scales.size(); i++) {
+ DisplayMode mode = base_mode;
+ mode.ui_scale = scales[i];
+ mode.native = (scales[i] == 1.0f);
+ display_modes.push_back(mode);
+ }
+ native_display_info.set_display_modes(display_modes);
+ std::vector<DisplayInfo> display_info_list;
+ display_info_list.push_back(native_display_info);
+ display_manager()->OnNativeDisplaysChanged(display_info_list);
+
+ DisplayMode expected_mode = base_mode;
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+
+ display_manager()->SetDisplayUIScale(display_id, 1.125f);
+ EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.8f);
+ EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.75f);
+ EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.625f);
+ EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+
+ gfx::Display::SetInternalDisplayId(display_id);
+
+ display_manager()->SetDisplayUIScale(display_id, 1.5f);
+ EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 1.25f);
+ EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 1.125f);
+ EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
+ expected_mode.ui_scale = 1.125f;
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.8f);
+ EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
+ expected_mode.ui_scale = 0.8f;
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.75f);
+ EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.625f);
+ EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
+ expected_mode.ui_scale = 0.625f;
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.6f);
+ EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+ display_manager()->SetDisplayUIScale(display_id, 0.5f);
+ EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
+ expected_mode.ui_scale = 0.5f;
+ EXPECT_TRUE(expected_mode.IsEquivalent(
+ display_manager()->GetActiveModeForDisplayId(display_id)));
+}
+
TEST_F(DisplayManagerTest, UIScaleUpgradeToHighDPI) {
int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id();
gfx::Display::SetInternalDisplayId(display_id);
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/display/resolution_notification_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698