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

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

Issue 1263853002: Unified Desktop: Support 2xDSF display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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/accelerators/accelerator_commands.h"
7 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
8 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
9 #include "ash/display/display_layout_store.h" 10 #include "ash/display/display_layout_store.h"
10 #include "ash/display/display_util.h" 11 #include "ash/display/display_util.h"
11 #include "ash/display/mirror_window_controller.h" 12 #include "ash/display/mirror_window_controller.h"
12 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
13 #include "ash/screen_util.h" 14 #include "ash/screen_util.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
16 #include "ash/test/display_manager_test_api.h" 17 #include "ash/test/display_manager_test_api.h"
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 // 500 * 500 / 300 + 400 ~= 1233. 1545 // 500 * 500 / 300 + 400 ~= 1233.
1545 EXPECT_EQ("1233x500", screen->GetPrimaryDisplay().size().ToString()); 1546 EXPECT_EQ("1233x500", screen->GetPrimaryDisplay().size().ToString());
1546 1547
1547 // Switch back to extended desktop. 1548 // Switch back to extended desktop.
1548 display_manager()->SetDefaultMultiDisplayMode(DisplayManager::EXTENDED); 1549 display_manager()->SetDefaultMultiDisplayMode(DisplayManager::EXTENDED);
1549 display_manager()->ReconfigureDisplays(); 1550 display_manager()->ReconfigureDisplays();
1550 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); 1551 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString());
1551 EXPECT_EQ("400x500", ScreenUtil::GetSecondaryDisplay().size().ToString()); 1552 EXPECT_EQ("400x500", ScreenUtil::GetSecondaryDisplay().size().ToString());
1552 } 1553 }
1553 1554
1555 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) {
1556 if (!SupportsMultipleDisplays())
1557 return;
1558 // Don't check root window destruction in unified mode.
1559 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1560
1561 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest();
1562 gfx::Screen* screen =
1563 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1564
1565 // 2nd display is 2x.
1566 UpdateDisplay("400x500,1000x800*2");
1567 DisplayInfo info =
1568 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
1569 EXPECT_EQ(2u, info.display_modes().size());
1570 EXPECT_EQ("1640x800", info.display_modes()[0].size.ToString());
1571 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
1572 EXPECT_EQ("1025x500", info.display_modes()[1].size.ToString());
1573 EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
1574
1575 // It defaults to the highest resolution. With 2x DSF,
1576 // (800 / 500 * 400 + 500) /2 = 820
1577 EXPECT_EQ("820x400", screen->GetPrimaryDisplay().size().ToString());
1578 EXPECT_EQ("820x400",
1579 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1580 accelerators::ZoomInternalDisplay(true);
1581 // For 1x, 400 + 500 / 800 * 100 = 1025.
1582 EXPECT_EQ("1025x500", screen->GetPrimaryDisplay().size().ToString());
1583 EXPECT_EQ("1025x500",
1584 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1585
1586 // 1st display is 2x.
1587 UpdateDisplay("1200x800*2,1000x1000");
1588 info = display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
1589 EXPECT_EQ(2u, info.display_modes().size());
1590 EXPECT_EQ("2000x800", info.display_modes()[0].size.ToString());
1591 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
1592 EXPECT_EQ("2500x1000", info.display_modes()[1].size.ToString());
1593 EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
1594
1595 // It defaults to the highest resolution (1x).
1596 // 1000 / 800 * 1200 + 1000 = 2500
1597 EXPECT_EQ("2500x1000", screen->GetPrimaryDisplay().size().ToString());
1598 EXPECT_EQ("2500x1000",
1599 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1600 accelerators::ZoomInternalDisplay(false);
1601 // For 2x, (800 / 1000 * 1000 + 1200) / 2 = 1000
1602 EXPECT_EQ("1000x400", screen->GetPrimaryDisplay().size().ToString());
1603 EXPECT_EQ("1000x400",
1604 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1605
1606 // Both displays are 2x.
1607 // 1st display is 2x.
1608 UpdateDisplay("1200x800*2,1000x1000*2");
1609 info = display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
1610 EXPECT_EQ(2u, info.display_modes().size());
1611 EXPECT_EQ("2000x800", info.display_modes()[0].size.ToString());
1612 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
1613 EXPECT_EQ("2500x1000", info.display_modes()[1].size.ToString());
1614 EXPECT_EQ(2.0f, info.display_modes()[1].device_scale_factor);
1615
1616 EXPECT_EQ("1250x500", screen->GetPrimaryDisplay().size().ToString());
1617 EXPECT_EQ("1250x500",
1618 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1619 accelerators::ZoomInternalDisplay(false);
1620 EXPECT_EQ("1000x400", screen->GetPrimaryDisplay().size().ToString());
1621 EXPECT_EQ("1000x400",
1622 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1623
1624 // Both displays have the same physical height, with the first display
1625 // being 2x.
1626 UpdateDisplay("1000x800*2,300x800");
1627 info = display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
1628 EXPECT_EQ(2u, info.display_modes().size());
1629 EXPECT_EQ("1300x800", info.display_modes()[0].size.ToString());
1630 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
1631 EXPECT_EQ("1300x800", info.display_modes()[1].size.ToString());
1632 EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
1633
1634 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString());
1635 EXPECT_EQ("650x400",
1636 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1637 accelerators::ZoomInternalDisplay(true);
1638 EXPECT_EQ("1300x800", screen->GetPrimaryDisplay().size().ToString());
1639 EXPECT_EQ("1300x800",
1640 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1641
1642 // Both displays have the same physical height, with the second display
1643 // being 2x.
1644 UpdateDisplay("1000x800,300x800*2");
1645 EXPECT_EQ(2u, info.display_modes().size());
1646 EXPECT_EQ("1300x800", info.display_modes()[0].size.ToString());
1647 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
1648 EXPECT_EQ("1300x800", info.display_modes()[1].size.ToString());
1649 EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
1650
1651 EXPECT_EQ("1300x800", screen->GetPrimaryDisplay().size().ToString());
1652 EXPECT_EQ("1300x800",
1653 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1654 accelerators::ZoomInternalDisplay(false);
1655 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString());
1656 EXPECT_EQ("650x400",
1657 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1658 }
1659
1554 // Updating displays again in unified desktop mode should not crash. 1660 // Updating displays again in unified desktop mode should not crash.
1555 // crbug.com/491094. 1661 // crbug.com/491094.
1556 TEST_F(DisplayManagerTest, ConfigureUnifiedTwice) { 1662 TEST_F(DisplayManagerTest, ConfigureUnifiedTwice) {
1557 if (!SupportsMultipleDisplays()) 1663 if (!SupportsMultipleDisplays())
1558 return; 1664 return;
1559 // Don't check root window destruction in unified mode. 1665 // Don't check root window destruction in unified mode.
1560 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1666 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1561 1667
1562 UpdateDisplay("300x200,400x500"); 1668 UpdateDisplay("300x200,400x500");
1563 // Mirror windows are created in a posted task. 1669 // Mirror windows are created in a posted task.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 1886
1781 EXPECT_EQ(gfx::Display::ROTATE_90, 1887 EXPECT_EQ(gfx::Display::ROTATE_90,
1782 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER)); 1888 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER));
1783 EXPECT_EQ(gfx::Display::ROTATE_90, 1889 EXPECT_EQ(gfx::Display::ROTATE_90,
1784 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); 1890 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE));
1785 } 1891 }
1786 1892
1787 #endif // OS_CHROMEOS 1893 #endif // OS_CHROMEOS
1788 1894
1789 } // namespace ash 1895 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698