| 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 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 DISALLOW_COPY_AND_ASSIGN(FontTestHelper); | 1590 DISALLOW_COPY_AND_ASSIGN(FontTestHelper); |
| 1591 }; | 1591 }; |
| 1592 | 1592 |
| 1593 | 1593 |
| 1594 bool IsTextSubpixelPositioningEnabled() { | 1594 bool IsTextSubpixelPositioningEnabled() { |
| 1595 gfx::FontRenderParams params = | 1595 gfx::FontRenderParams params = |
| 1596 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); | 1596 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); |
| 1597 return params.subpixel_positioning; | 1597 return params.subpixel_positioning; |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 gfx::FontRenderParams::Hinting GetFontHintingParams() { |
| 1601 gfx::FontRenderParams params = |
| 1602 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); |
| 1603 return params.hinting; |
| 1604 } |
| 1605 |
| 1600 } // namespace | 1606 } // namespace |
| 1601 | 1607 |
| 1602 typedef testing::Test DisplayManagerFontTest; | 1608 typedef testing::Test DisplayManagerFontTest; |
| 1603 | 1609 |
| 1604 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { | 1610 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { |
| 1605 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); | 1611 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); |
| 1606 ASSERT_DOUBLE_EQ( | 1612 ASSERT_DOUBLE_EQ( |
| 1607 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1613 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1608 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1614 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1615 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1609 } | 1616 } |
| 1610 | 1617 |
| 1611 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { | 1618 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { |
| 1612 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); | 1619 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); |
| 1613 ASSERT_DOUBLE_EQ( | 1620 ASSERT_DOUBLE_EQ( |
| 1614 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1621 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1615 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 1622 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1623 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1616 } | 1624 } |
| 1617 | 1625 |
| 1618 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { | 1626 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { |
| 1619 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); | 1627 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); |
| 1620 ASSERT_DOUBLE_EQ( | 1628 ASSERT_DOUBLE_EQ( |
| 1621 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1629 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1622 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 1630 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1631 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1632 |
| 1633 Shell::GetInstance()->display_manager()->SetDisplayUIScale( |
| 1634 Shell::GetScreen()->GetPrimaryDisplay().id(), 2.0f); |
| 1635 |
| 1636 ASSERT_DOUBLE_EQ( |
| 1637 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1638 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1639 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1623 } | 1640 } |
| 1624 | 1641 |
| 1625 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { | 1642 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { |
| 1626 FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL); | 1643 FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL); |
| 1627 ASSERT_DOUBLE_EQ( | 1644 ASSERT_DOUBLE_EQ( |
| 1628 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1645 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1629 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1646 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1647 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1630 } | 1648 } |
| 1631 | 1649 |
| 1632 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { | 1650 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { |
| 1633 FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL); | 1651 FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL); |
| 1634 ASSERT_DOUBLE_EQ( | 1652 ASSERT_DOUBLE_EQ( |
| 1635 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1653 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1636 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1654 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1655 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1637 } | 1656 } |
| 1638 | 1657 |
| 1639 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { | 1658 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { |
| 1640 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); | 1659 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); |
| 1641 ASSERT_DOUBLE_EQ( | 1660 ASSERT_DOUBLE_EQ( |
| 1642 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1661 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1643 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1662 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1663 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1644 } | 1664 } |
| 1645 | 1665 |
| 1646 TEST_F(DisplayManagerFontTest, | 1666 TEST_F(DisplayManagerFontTest, |
| 1647 TextSubpixelPositioningWithDsf125InternalWithScaling) { | 1667 TextSubpixelPositioningWithDsf125InternalWithScaling) { |
| 1648 DisplayInfo::SetUse125DSFForUIScaling(true); | 1668 DisplayInfo::SetUse125DSFForUIScaling(true); |
| 1649 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); | 1669 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); |
| 1650 ASSERT_DOUBLE_EQ( | 1670 ASSERT_DOUBLE_EQ( |
| 1651 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1671 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1652 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1672 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1673 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1674 |
| 1675 Shell::GetInstance()->display_manager()->SetDisplayUIScale( |
| 1676 Shell::GetScreen()->GetPrimaryDisplay().id(), 0.8f); |
| 1677 |
| 1678 ASSERT_DOUBLE_EQ( |
| 1679 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1680 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1681 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1682 |
| 1653 DisplayInfo::SetUse125DSFForUIScaling(false); | 1683 DisplayInfo::SetUse125DSFForUIScaling(false); |
| 1654 } | 1684 } |
| 1655 | 1685 |
| 1656 #endif // OS_CHROMEOS | 1686 #endif // OS_CHROMEOS |
| 1657 | 1687 |
| 1658 } // namespace ash | 1688 } // namespace ash |
| OLD | NEW |