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

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

Issue 1261693004: Allow dynamic enabling/disabling of unified desktop (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
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/display/display_util.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/accelerators/accelerator_commands.h" 7 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 651
652 UpdateDisplay("100+0-500x500,0+501-400x400"); 652 UpdateDisplay("100+0-500x500,0+501-400x400");
653 653
654 const int64 primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); 654 const int64 primary_id = WindowTreeHostManager::GetPrimaryDisplayId();
655 const int64 secondary_id = ScreenUtil::GetSecondaryDisplay().id(); 655 const int64 secondary_id = ScreenUtil::GetSecondaryDisplay().id();
656 656
657 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); 657 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id);
658 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); 658 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id);
659 659
660 // An id which is different from primary and secondary. 660 // An id which is different from primary and secondary.
661 const int64 third_id = primary_id + secondary_id; 661 const int64 third_id = secondary_id + 1;
662 662
663 DisplayInfo third_info = 663 DisplayInfo third_info =
664 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); 664 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600));
665 665
666 std::vector<DisplayInfo> display_info_list; 666 std::vector<DisplayInfo> display_info_list;
667 display_info_list.push_back(third_info); 667 display_info_list.push_back(third_info);
668 display_info_list.push_back(secondary_info); 668 display_info_list.push_back(secondary_info);
669 display_manager()->OnNativeDisplaysChanged(display_info_list); 669 display_manager()->OnNativeDisplaysChanged(display_info_list);
670 670
671 // Secondary seconary_id becomes the primary as it has smaller output index. 671 // Secondary seconary_id becomes the primary as it has smaller output index.
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1113
1114 SetDisplayUIScale(display_id, 1.25f); 1114 SetDisplayUIScale(display_id, 1.25f);
1115 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1115 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1116 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1116 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1117 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1117 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1118 } 1118 }
1119 1119
1120 TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) { 1120 TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) {
1121 if (!SupportsMultipleDisplays()) 1121 if (!SupportsMultipleDisplays())
1122 return; 1122 return;
1123
1124 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest();
1125
1126 // Don't check root window destruction in unified mode. 1123 // Don't check root window destruction in unified mode.
1127 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1124 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1128 1125
1129 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1126 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1127 display_manager->SetUnifiedDesktopEnabled(true);
1130 1128
1131 UpdateDisplay("200x200, 400x400"); 1129 UpdateDisplay("200x200, 400x400");
1132 1130
1133 int64 unified_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 1131 int64 unified_id = Shell::GetScreen()->GetPrimaryDisplay().id();
1134 DisplayInfo info = display_manager->GetDisplayInfo(unified_id); 1132 DisplayInfo info = display_manager->GetDisplayInfo(unified_id);
1135 ASSERT_EQ(2u, info.display_modes().size()); 1133 ASSERT_EQ(2u, info.display_modes().size());
1136 EXPECT_EQ("400x200", info.display_modes()[0].size.ToString()); 1134 EXPECT_EQ("400x200", info.display_modes()[0].size.ToString());
1137 EXPECT_TRUE(info.display_modes()[0].native); 1135 EXPECT_TRUE(info.display_modes()[0].native);
1138 EXPECT_EQ("800x400", info.display_modes()[1].size.ToString()); 1136 EXPECT_EQ("800x400", info.display_modes()[1].size.ToString());
1139 EXPECT_FALSE(info.display_modes()[1].native); 1137 EXPECT_FALSE(info.display_modes()[1].native);
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 1511 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1514 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString()); 1512 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString());
1515 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1513 EXPECT_EQ("100x200", host0->GetBounds().size().ToString());
1516 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); 1514 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString());
1517 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); 1515 EXPECT_EQ("200x300", host1->GetBounds().size().ToString());
1518 } 1516 }
1519 1517
1520 TEST_F(DisplayManagerTest, UnifiedDesktopBasic) { 1518 TEST_F(DisplayManagerTest, UnifiedDesktopBasic) {
1521 if (!SupportsMultipleDisplays()) 1519 if (!SupportsMultipleDisplays())
1522 return; 1520 return;
1523 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest();
1524 1521
1525 // Don't check root window destruction in unified mode. 1522 // Don't check root window destruction in unified mode.
1526 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1523 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1527 1524
1528 UpdateDisplay("400x500,300x200"); 1525 UpdateDisplay("400x500,300x200");
1529 1526
1527 // Enable after extended mode.
1528 display_manager()->SetUnifiedDesktopEnabled(true);
1529
1530 // Defaults to the unified desktop. 1530 // Defaults to the unified desktop.
1531 gfx::Screen* screen = 1531 gfx::Screen* screen =
1532 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); 1532 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1533 // The 2nd display is scaled so that it has the same height as 1st display. 1533 // The 2nd display is scaled so that it has the same height as 1st display.
1534 // 300 * 500 / 200 + 400 = 1150. 1534 // 300 * 500 / 200 + 400 = 1150.
1535 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 1535 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
1536 1536
1537 display_manager()->SetMirrorMode(true); 1537 display_manager()->SetMirrorMode(true);
1538 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); 1538 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString());
1539 1539
(...skipping 15 matching lines...) Expand all
1555 display_info_list.push_back( 1555 display_info_list.push_back(
1556 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); 1556 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500)));
1557 { 1557 {
1558 test::ScopedSetInternalDisplayId set_internal(11); 1558 test::ScopedSetInternalDisplayId set_internal(11);
1559 display_manager()->OnNativeDisplaysChanged(display_info_list); 1559 display_manager()->OnNativeDisplaysChanged(display_info_list);
1560 // 500 * 500 / 300 + 400 ~= 1233. 1560 // 500 * 500 / 300 + 400 ~= 1233.
1561 EXPECT_EQ("1233x500", screen->GetPrimaryDisplay().size().ToString()); 1561 EXPECT_EQ("1233x500", screen->GetPrimaryDisplay().size().ToString());
1562 } 1562 }
1563 1563
1564 // Switch back to extended desktop. 1564 // Switch back to extended desktop.
1565 display_manager()->SetDefaultMultiDisplayMode(DisplayManager::EXTENDED); 1565 display_manager()->SetUnifiedDesktopEnabled(false);
1566 display_manager()->ReconfigureDisplays();
1567 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); 1566 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString());
1568 EXPECT_EQ("400x500", ScreenUtil::GetSecondaryDisplay().size().ToString()); 1567 EXPECT_EQ("400x500", ScreenUtil::GetSecondaryDisplay().size().ToString());
1569 } 1568 }
1570 1569
1570 TEST_F(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) {
1571 if (!SupportsMultipleDisplays())
1572 return;
1573 // Don't check root window destruction in unified mode.
1574 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1575
1576 UpdateDisplay("400x500,300x200");
1577 DisplayIdPair pair = display_manager()->GetCurrentDisplayIdPair();
1578 DisplayLayout layout =
1579 display_manager()->layout_store()->GetRegisteredDisplayLayout(pair);
1580 layout.default_unified = false;
1581 display_manager()->layout_store()->RegisterLayoutForDisplayIdPair(
1582 pair.first, pair.second, layout);
1583 display_manager()->SetUnifiedDesktopEnabled(true);
1584 EXPECT_FALSE(display_manager()->IsInUnifiedMode());
1585 }
1586
1571 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) { 1587 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) {
1572 if (!SupportsMultipleDisplays()) 1588 if (!SupportsMultipleDisplays())
1573 return; 1589 return;
1574 // Don't check root window destruction in unified mode. 1590 // Don't check root window destruction in unified mode.
1575 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1591 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1576 1592
1577 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest(); 1593 display_manager()->SetUnifiedDesktopEnabled(true);
1578 gfx::Screen* screen = 1594 gfx::Screen* screen =
1579 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); 1595 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1580 1596
1581 // 2nd display is 2x. 1597 // 2nd display is 2x.
1582 UpdateDisplay("400x500,1000x800*2"); 1598 UpdateDisplay("400x500,1000x800*2");
1583 DisplayInfo info = 1599 DisplayInfo info =
1584 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); 1600 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
1585 EXPECT_EQ(2u, info.display_modes().size()); 1601 EXPECT_EQ(2u, info.display_modes().size());
1586 EXPECT_EQ("1640x800", info.display_modes()[0].size.ToString()); 1602 EXPECT_EQ("1640x800", info.display_modes()[0].size.ToString());
1587 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor); 1603 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 // Mirror windows are created in a posted task. 1699 // Mirror windows are created in a posted task.
1684 RunAllPendingInMessageLoop(); 1700 RunAllPendingInMessageLoop();
1685 1701
1686 UpdateDisplay("300x250,400x550"); 1702 UpdateDisplay("300x250,400x550");
1687 RunAllPendingInMessageLoop(); 1703 RunAllPendingInMessageLoop();
1688 } 1704 }
1689 1705
1690 TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) { 1706 TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) {
1691 if (!SupportsMultipleDisplays()) 1707 if (!SupportsMultipleDisplays())
1692 return; 1708 return;
1693 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest(); 1709 display_manager()->SetUnifiedDesktopEnabled(true);
1694 1710
1695 // Don't check root window destruction in unified mode. 1711 // Don't check root window destruction in unified mode.
1696 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1712 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1697 1713
1698 UpdateDisplay("400x500,300x200"); 1714 UpdateDisplay("400x500,300x200");
1699 1715
1700 gfx::Screen* screen = 1716 gfx::Screen* screen =
1701 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); 1717 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1702 const gfx::Display& display = screen->GetPrimaryDisplay(); 1718 const gfx::Display& display = screen->GetPrimaryDisplay();
1703 EXPECT_EQ("1150x500", display.size().ToString()); 1719 EXPECT_EQ("1150x500", display.size().ToString());
1704 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_90, 1720 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_90,
1705 gfx::Display::ROTATION_SOURCE_ACTIVE); 1721 gfx::Display::ROTATION_SOURCE_ACTIVE);
1706 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 1722 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
1707 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_0, 1723 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_0,
1708 gfx::Display::ROTATION_SOURCE_ACTIVE); 1724 gfx::Display::ROTATION_SOURCE_ACTIVE);
1709 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 1725 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
1710 1726
1711 UpdateDisplay("400x500"); 1727 UpdateDisplay("400x500");
1712 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); 1728 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString());
1713 } 1729 }
1714 1730
1715 // Makes sure the transition from unified to single won't crash 1731 // Makes sure the transition from unified to single won't crash
1716 // with docked windows. 1732 // with docked windows.
1717 TEST_F(DisplayManagerTest, UnifiedWithDockWindows) { 1733 TEST_F(DisplayManagerTest, UnifiedWithDockWindows) {
1718 if (!SupportsMultipleDisplays()) 1734 if (!SupportsMultipleDisplays())
1719 return; 1735 return;
1720 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest(); 1736 display_manager()->SetUnifiedDesktopEnabled(true);
1721 1737
1722 // Don't check root window destruction in unified mode. 1738 // Don't check root window destruction in unified mode.
1723 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1739 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1724 1740
1725 UpdateDisplay("400x500,300x200"); 1741 UpdateDisplay("400x500,300x200");
1726 1742
1727 scoped_ptr<aura::Window> docked( 1743 scoped_ptr<aura::Window> docked(
1728 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50))); 1744 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50)));
1729 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); 1745 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED);
1730 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); 1746 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 1916
1901 EXPECT_EQ(gfx::Display::ROTATE_90, 1917 EXPECT_EQ(gfx::Display::ROTATE_90,
1902 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER)); 1918 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER));
1903 EXPECT_EQ(gfx::Display::ROTATE_90, 1919 EXPECT_EQ(gfx::Display::ROTATE_90,
1904 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); 1920 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE));
1905 } 1921 }
1906 1922
1907 #endif // OS_CHROMEOS 1923 #endif // OS_CHROMEOS
1908 1924
1909 } // namespace ash 1925 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/display/display_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698