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

Side by Side Diff: ash/display/display_manager_unittest.cc

Issue 1251573006: Cleanup: Enable 125DSFForUIScaling on by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/test/display_manager_test_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 display_manager()->SetDisplayRotation(internal_display_id, 935 display_manager()->SetDisplayRotation(internal_display_id,
936 gfx::Display::ROTATE_180, 936 gfx::Display::ROTATE_180,
937 gfx::Display::ROTATION_SOURCE_ACTIVE); 937 gfx::Display::ROTATION_SOURCE_ACTIVE);
938 const DisplayInfo post_rotation_info = 938 const DisplayInfo post_rotation_info =
939 display_manager()->display_info_[internal_display_id]; 939 display_manager()->display_info_[internal_display_id];
940 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); 940 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation());
941 EXPECT_EQ(gfx::Display::ROTATE_180, post_rotation_info.GetActiveRotation()); 941 EXPECT_EQ(gfx::Display::ROTATE_180, post_rotation_info.GetActiveRotation());
942 } 942 }
943 943
944 TEST_F(DisplayManagerTest, UIScale) { 944 TEST_F(DisplayManagerTest, UIScale) {
945 DisplayInfo::SetUse125DSFForUIScaling(false); 945 test::ScopedDisable125DSFForUIScaling disable;
946 946
947 UpdateDisplay("1280x800"); 947 UpdateDisplay("1280x800");
948 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 948 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id();
949 display_manager()->SetDisplayUIScale(display_id, 1.125f); 949 display_manager()->SetDisplayUIScale(display_id, 1.125f);
950 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 950 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
951 display_manager()->SetDisplayUIScale(display_id, 0.8f); 951 display_manager()->SetDisplayUIScale(display_id, 0.8f);
952 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 952 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
953 display_manager()->SetDisplayUIScale(display_id, 0.75f); 953 display_manager()->SetDisplayUIScale(display_id, 0.75f);
954 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 954 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
955 display_manager()->SetDisplayUIScale(display_id, 0.625f); 955 display_manager()->SetDisplayUIScale(display_id, 0.625f);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1106 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1107 EXPECT_TRUE(expected_mode.IsEquivalent( 1107 EXPECT_TRUE(expected_mode.IsEquivalent(
1108 display_manager()->GetActiveModeForDisplayId(display_id))); 1108 display_manager()->GetActiveModeForDisplayId(display_id)));
1109 display_manager()->SetDisplayUIScale(display_id, 0.5f); 1109 display_manager()->SetDisplayUIScale(display_id, 0.5f);
1110 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1110 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1111 expected_mode.ui_scale = 0.5f; 1111 expected_mode.ui_scale = 0.5f;
1112 EXPECT_TRUE(expected_mode.IsEquivalent( 1112 EXPECT_TRUE(expected_mode.IsEquivalent(
1113 display_manager()->GetActiveModeForDisplayId(display_id))); 1113 display_manager()->GetActiveModeForDisplayId(display_id)));
1114 } 1114 }
1115 1115
1116 TEST_F(DisplayManagerTest, Use125DSFRorUIScaling) { 1116 TEST_F(DisplayManagerTest, Use125DSFForUIScaling) {
1117 DisplayInfo::SetUse125DSFForUIScaling(true);
1118
1119 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 1117 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id();
1120 test::DisplayManagerTestApi(display_manager()) 1118 test::DisplayManagerTestApi(display_manager())
1121 .SetInternalDisplayId(display_id); 1119 .SetInternalDisplayId(display_id);
1122 1120
1123 UpdateDisplay("1920x1080*1.25"); 1121 UpdateDisplay("1920x1080*1.25");
1124 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1122 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1125 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1123 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1126 1124
1127 display_manager()->SetDisplayUIScale(display_id, 0.8f); 1125 display_manager()->SetDisplayUIScale(display_id, 0.8f);
1128 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1126 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1129 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1127 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1130 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1128 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1131 1129
1132 display_manager()->SetDisplayUIScale(display_id, 0.5f); 1130 display_manager()->SetDisplayUIScale(display_id, 0.5f);
1133 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1131 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1134 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1132 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1135 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1133 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1136 1134
1137 display_manager()->SetDisplayUIScale(display_id, 1.25f); 1135 display_manager()->SetDisplayUIScale(display_id, 1.25f);
1138 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1136 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1139 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1137 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1140 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1138 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1141
1142 DisplayInfo::SetUse125DSFForUIScaling(false);
1143 } 1139 }
1144 1140
1145 TEST_F(DisplayManagerTest, UIScaleInUnifiedMode) { 1141 TEST_F(DisplayManagerTest, UIScaleInUnifiedMode) {
1146 if (!SupportsMultipleDisplays()) 1142 if (!SupportsMultipleDisplays())
1147 return; 1143 return;
1148 1144
1149 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest(); 1145 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest();
1150 1146
1151 // Don't check root window destruction in unified mode. 1147 // Don't check root window destruction in unified mode.
1152 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1148 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 1716
1721 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { 1717 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) {
1722 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); 1718 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL);
1723 ASSERT_DOUBLE_EQ( 1719 ASSERT_DOUBLE_EQ(
1724 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 1720 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1725 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 1721 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
1726 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 1722 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
1727 } 1723 }
1728 1724
1729 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { 1725 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) {
1726 test::ScopedDisable125DSFForUIScaling disable;
1730 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); 1727 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
1731 ASSERT_DOUBLE_EQ( 1728 ASSERT_DOUBLE_EQ(
1732 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 1729 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1733 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 1730 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
1734 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 1731 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
1735 } 1732 }
1736 1733
1737 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { 1734 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) {
1738 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); 1735 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL);
1739 ASSERT_DOUBLE_EQ( 1736 ASSERT_DOUBLE_EQ(
(...skipping 29 matching lines...) Expand all
1769 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { 1766 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) {
1770 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); 1767 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL);
1771 ASSERT_DOUBLE_EQ( 1768 ASSERT_DOUBLE_EQ(
1772 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 1769 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1773 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 1770 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
1774 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 1771 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
1775 } 1772 }
1776 1773
1777 TEST_F(DisplayManagerFontTest, 1774 TEST_F(DisplayManagerFontTest,
1778 TextSubpixelPositioningWithDsf125InternalWithScaling) { 1775 TextSubpixelPositioningWithDsf125InternalWithScaling) {
1779 DisplayInfo::SetUse125DSFForUIScaling(true);
1780 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); 1776 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
1781 ASSERT_DOUBLE_EQ( 1777 ASSERT_DOUBLE_EQ(
1782 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 1778 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1783 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 1779 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
1784 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 1780 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
1785 1781
1786 Shell::GetInstance()->display_manager()->SetDisplayUIScale( 1782 Shell::GetInstance()->display_manager()->SetDisplayUIScale(
1787 Shell::GetScreen()->GetPrimaryDisplay().id(), 0.8f); 1783 Shell::GetScreen()->GetPrimaryDisplay().id(), 0.8f);
1788 1784
1789 ASSERT_DOUBLE_EQ( 1785 ASSERT_DOUBLE_EQ(
1790 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 1786 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1791 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 1787 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
1792 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 1788 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
1793
1794 DisplayInfo::SetUse125DSFForUIScaling(false);
1795 } 1789 }
1796 1790
1797 TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) { 1791 TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) {
1798 int64_t id = display_manager()->GetDisplayAt(0).id(); 1792 int64_t id = display_manager()->GetDisplayAt(0).id();
1799 display_manager()->RegisterDisplayProperty(id, gfx::Display::ROTATE_90, 1.0f, 1793 display_manager()->RegisterDisplayProperty(id, gfx::Display::ROTATE_90, 1.0f,
1800 nullptr, gfx::Size(), 1.0f, 1794 nullptr, gfx::Size(), 1.0f,
1801 ui::COLOR_PROFILE_STANDARD); 1795 ui::COLOR_PROFILE_STANDARD);
1802 1796
1803 const DisplayInfo& info = display_manager()->GetDisplayInfo(id); 1797 const DisplayInfo& info = display_manager()->GetDisplayInfo(id);
1804 1798
1805 EXPECT_EQ(gfx::Display::ROTATE_90, 1799 EXPECT_EQ(gfx::Display::ROTATE_90,
1806 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER)); 1800 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER));
1807 EXPECT_EQ(gfx::Display::ROTATE_90, 1801 EXPECT_EQ(gfx::Display::ROTATE_90,
1808 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); 1802 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE));
1809 } 1803 }
1810 1804
1811 #endif // OS_CHROMEOS 1805 #endif // OS_CHROMEOS
1812 1806
1813 } // namespace ash 1807 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/test/display_manager_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698