| 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/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_builder.h" | 10 #include "ash/display/display_layout_builder.h" |
| (...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 | 1693 |
| 1694 UpdateDisplay("400x500,300x200"); | 1694 UpdateDisplay("400x500,300x200"); |
| 1695 | 1695 |
| 1696 // Enable after extended mode. | 1696 // Enable after extended mode. |
| 1697 display_manager()->SetUnifiedDesktopEnabled(true); | 1697 display_manager()->SetUnifiedDesktopEnabled(true); |
| 1698 | 1698 |
| 1699 // Defaults to the unified desktop. | 1699 // Defaults to the unified desktop. |
| 1700 gfx::Screen* screen = gfx::Screen::GetScreen(); | 1700 gfx::Screen* screen = gfx::Screen::GetScreen(); |
| 1701 // The 2nd display is scaled so that it has the same height as 1st display. | 1701 // The 2nd display is scaled so that it has the same height as 1st display. |
| 1702 // 300 * 500 / 200 + 400 = 1150. | 1702 // 300 * 500 / 200 + 400 = 1150. |
| 1703 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); | 1703 EXPECT_EQ(gfx::Size(1150, 500), screen->GetPrimaryDisplay().size()); |
| 1704 | 1704 |
| 1705 display_manager()->SetMirrorMode(true); | 1705 display_manager()->SetMirrorMode(true); |
| 1706 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); | 1706 EXPECT_EQ(gfx::Size(400, 500), screen->GetPrimaryDisplay().size()); |
| 1707 | 1707 |
| 1708 display_manager()->SetMirrorMode(false); | 1708 display_manager()->SetMirrorMode(false); |
| 1709 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); | 1709 EXPECT_EQ(gfx::Size(1150, 500), screen->GetPrimaryDisplay().size()); |
| 1710 | 1710 |
| 1711 // Switch to single desktop. | 1711 // Switch to single desktop. |
| 1712 UpdateDisplay("500x300"); | 1712 UpdateDisplay("500x300"); |
| 1713 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); | 1713 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); |
| 1714 | 1714 |
| 1715 // Switch to unified desktop. | 1715 // Switch to unified desktop. |
| 1716 UpdateDisplay("500x300,400x500"); | 1716 UpdateDisplay("500x300,400x500"); |
| 1717 // 400 * 300 / 500 + 500 ~= 739. | 1717 // 400 * 300 / 500 + 500 ~= 739. |
| 1718 EXPECT_EQ("739x300", screen->GetPrimaryDisplay().size().ToString()); | 1718 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); |
| 1719 | 1719 |
| 1720 // The default should fit to the internal display. | 1720 // The default should fit to the internal display. |
| 1721 std::vector<DisplayInfo> display_info_list; | 1721 std::vector<DisplayInfo> display_info_list; |
| 1722 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); | 1722 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); |
| 1723 display_info_list.push_back( | 1723 display_info_list.push_back( |
| 1724 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); | 1724 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); |
| 1725 { | 1725 { |
| 1726 test::ScopedSetInternalDisplayId set_internal(11); | 1726 test::ScopedSetInternalDisplayId set_internal(11); |
| 1727 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1727 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1728 // 500 * 500 / 300 + 400 ~= 1233. | 1728 // 500 * 500 / 300 + 400 ~= 1233. |
| 1729 EXPECT_EQ("1233x500", screen->GetPrimaryDisplay().size().ToString()); | 1729 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); |
| 1730 } | 1730 } |
| 1731 | 1731 |
| 1732 // Switch to 3 displays. |
| 1733 UpdateDisplay("500x300,400x500,500x300"); |
| 1734 EXPECT_EQ(gfx::Size(1239, 300), screen->GetPrimaryDisplay().size()); |
| 1735 |
| 1732 // Switch back to extended desktop. | 1736 // Switch back to extended desktop. |
| 1733 display_manager()->SetUnifiedDesktopEnabled(false); | 1737 display_manager()->SetUnifiedDesktopEnabled(false); |
| 1734 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); | 1738 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); |
| 1735 EXPECT_EQ("400x500", ScreenUtil::GetSecondaryDisplay().size().ToString()); | 1739 EXPECT_EQ(gfx::Size(400, 500), ScreenUtil::GetSecondaryDisplay().size()); |
| 1740 EXPECT_EQ(gfx::Size(500, 300), |
| 1741 display_manager() |
| 1742 ->GetDisplayForId(ScreenUtil::GetSecondaryDisplay().id() + 1) |
| 1743 .size()); |
| 1736 } | 1744 } |
| 1737 | 1745 |
| 1738 TEST_F(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { | 1746 TEST_F(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { |
| 1739 if (!SupportsMultipleDisplays()) | 1747 if (!SupportsMultipleDisplays()) |
| 1740 return; | 1748 return; |
| 1741 // Don't check root window destruction in unified mode. | 1749 // Don't check root window destruction in unified mode. |
| 1742 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1750 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
| 1743 | 1751 |
| 1744 // Enter to hardware mirroring. | 1752 // Enter to hardware mirroring. |
| 1745 DisplayInfo d1(1, "", false); | 1753 DisplayInfo d1(1, "", false); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); | 2231 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); |
| 2224 const DisplayLayout& stored = layout_store->GetRegisteredDisplayLayout(list); | 2232 const DisplayLayout& stored = layout_store->GetRegisteredDisplayLayout(list); |
| 2225 | 2233 |
| 2226 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); | 2234 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); |
| 2227 EXPECT_EQ(id2, stored.placement_list[0].display_id); | 2235 EXPECT_EQ(id2, stored.placement_list[0].display_id); |
| 2228 } | 2236 } |
| 2229 | 2237 |
| 2230 #endif // OS_CHROMEOS | 2238 #endif // OS_CHROMEOS |
| 2231 | 2239 |
| 2232 } // namespace ash | 2240 } // namespace ash |
| OLD | NEW |