OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
10 #include "ash/display/display_layout_store.h" | 10 #include "ash/display/display_layout_store.h" |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); | 1058 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); |
1059 EXPECT_TRUE(expected_mode.IsEquivalent( | 1059 EXPECT_TRUE(expected_mode.IsEquivalent( |
1060 display_manager()->GetActiveModeForDisplayId(display_id))); | 1060 display_manager()->GetActiveModeForDisplayId(display_id))); |
1061 display_manager()->SetDisplayUIScale(display_id, 0.5f); | 1061 display_manager()->SetDisplayUIScale(display_id, 0.5f); |
1062 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); | 1062 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); |
1063 expected_mode.ui_scale = 0.5f; | 1063 expected_mode.ui_scale = 0.5f; |
1064 EXPECT_TRUE(expected_mode.IsEquivalent( | 1064 EXPECT_TRUE(expected_mode.IsEquivalent( |
1065 display_manager()->GetActiveModeForDisplayId(display_id))); | 1065 display_manager()->GetActiveModeForDisplayId(display_id))); |
1066 } | 1066 } |
1067 | 1067 |
1068 TEST_F(DisplayManagerTest, UIScaleUpgradeToHighDPI) { | |
1069 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | |
1070 gfx::Display::SetInternalDisplayId(display_id); | |
1071 UpdateDisplay("1920x1080"); | |
1072 | |
1073 DisplayInfo::SetAllowUpgradeToHighDPI(false); | |
1074 display_manager()->SetDisplayUIScale(display_id, 1.125f); | |
1075 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | |
1076 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | |
1077 EXPECT_EQ("2160x1215", GetDisplayForId(display_id).size().ToString()); | |
1078 | |
1079 display_manager()->SetDisplayUIScale(display_id, 0.5f); | |
1080 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | |
1081 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | |
1082 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); | |
1083 | |
1084 DisplayInfo::SetAllowUpgradeToHighDPI(true); | |
1085 display_manager()->SetDisplayUIScale(display_id, 1.125f); | |
1086 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | |
1087 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | |
1088 EXPECT_EQ("2160x1215", GetDisplayForId(display_id).size().ToString()); | |
1089 | |
1090 display_manager()->SetDisplayUIScale(display_id, 0.5f); | |
1091 EXPECT_EQ(2.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | |
1092 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | |
1093 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); | |
1094 | |
1095 // Upgrade only works on 1.0f DSF. | |
1096 UpdateDisplay("1920x1080*2"); | |
1097 display_manager()->SetDisplayUIScale(display_id, 1.125f); | |
1098 EXPECT_EQ(2.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | |
1099 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | |
1100 EXPECT_EQ("1080x607", GetDisplayForId(display_id).size().ToString()); | |
1101 | |
1102 display_manager()->SetDisplayUIScale(display_id, 0.5f); | |
1103 EXPECT_EQ(2.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | |
1104 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | |
1105 EXPECT_EQ("480x270", GetDisplayForId(display_id).size().ToString()); | |
1106 } | |
1107 | 1068 |
1108 TEST_F(DisplayManagerTest, Use125DSFRorUIScaling) { | 1069 TEST_F(DisplayManagerTest, Use125DSFRorUIScaling) { |
1109 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 1070 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
1110 gfx::Display::SetInternalDisplayId(display_id); | 1071 gfx::Display::SetInternalDisplayId(display_id); |
1111 DisplayInfo::SetUse125DSFForUIScaling(true); | 1072 DisplayInfo::SetUse125DSFForUIScaling(true); |
1112 | 1073 |
1113 UpdateDisplay("1920x1080*1.25"); | 1074 UpdateDisplay("1920x1080*1.25"); |
1114 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1075 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1115 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1076 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1116 | 1077 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); | 1471 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); |
1511 ASSERT_DOUBLE_EQ( | 1472 ASSERT_DOUBLE_EQ( |
1512 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1473 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1513 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1474 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
1514 DisplayInfo::SetUse125DSFForUIScaling(false); | 1475 DisplayInfo::SetUse125DSFForUIScaling(false); |
1515 } | 1476 } |
1516 | 1477 |
1517 #endif // OS_CHROMEOS | 1478 #endif // OS_CHROMEOS |
1518 | 1479 |
1519 } // namespace ash | 1480 } // namespace ash |
OLD | NEW |