| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "ash/common/accessibility_delegate.h" | 8 #include "ash/common/accessibility_delegate.h" |
| 9 #include "ash/common/accessibility_types.h" | 9 #include "ash/common/accessibility_types.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 widget->Restore(); | 1100 widget->Restore(); |
| 1101 EXPECT_FALSE(widget->IsMinimized()); | 1101 EXPECT_FALSE(widget->IsMinimized()); |
| 1102 | 1102 |
| 1103 EXPECT_FALSE(GetOverviewWindowForMinimizedState(0, window)); | 1103 EXPECT_FALSE(GetOverviewWindowForMinimizedState(0, window)); |
| 1104 EXPECT_TRUE(IsSelecting()); | 1104 EXPECT_TRUE(IsSelecting()); |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 // Tests that clicking on the close button on a secondary display effectively | 1107 // Tests that clicking on the close button on a secondary display effectively |
| 1108 // closes the window. | 1108 // closes the window. |
| 1109 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) { | 1109 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) { |
| 1110 if (!SupportsMultipleDisplays()) | |
| 1111 return; | |
| 1112 | |
| 1113 UpdateDisplay("600x400,600x400"); | 1110 UpdateDisplay("600x400,600x400"); |
| 1114 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1111 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1115 | 1112 |
| 1116 std::unique_ptr<aura::Window> window1( | 1113 std::unique_ptr<aura::Window> window1( |
| 1117 CreateWindow(gfx::Rect(650, 300, 250, 450))); | 1114 CreateWindow(gfx::Rect(650, 300, 250, 450))); |
| 1118 | 1115 |
| 1119 // We need a widget for the close button to work because windows are closed | 1116 // We need a widget for the close button to work because windows are closed |
| 1120 // via the widget. We also use the widget to determine if the window has been | 1117 // via the widget. We also use the widget to determine if the window has been |
| 1121 // closed or not. We explicity create the widget so that the window can be | 1118 // closed or not. We explicity create the widget so that the window can be |
| 1122 // parented to a non-primary root window. | 1119 // parented to a non-primary root window. |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 ClickWindow(window1.get()); | 1424 ClickWindow(window1.get()); |
| 1428 EXPECT_FALSE(IsSelecting()); | 1425 EXPECT_FALSE(IsSelecting()); |
| 1429 | 1426 |
| 1430 // Clicking on window1 should activate child1. | 1427 // Clicking on window1 should activate child1. |
| 1431 EXPECT_TRUE(wm::IsActiveWindow(child1.get())); | 1428 EXPECT_TRUE(wm::IsActiveWindow(child1.get())); |
| 1432 } | 1429 } |
| 1433 | 1430 |
| 1434 // Tests that windows remain on the display they are currently on in overview | 1431 // Tests that windows remain on the display they are currently on in overview |
| 1435 // mode, and that the close buttons are on matching displays. | 1432 // mode, and that the close buttons are on matching displays. |
| 1436 TEST_F(WindowSelectorTest, MultipleDisplays) { | 1433 TEST_F(WindowSelectorTest, MultipleDisplays) { |
| 1437 if (!SupportsMultipleDisplays()) | |
| 1438 return; | |
| 1439 | |
| 1440 UpdateDisplay("600x400,600x400"); | 1434 UpdateDisplay("600x400,600x400"); |
| 1441 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1435 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1442 gfx::Rect bounds1(0, 0, 400, 400); | 1436 gfx::Rect bounds1(0, 0, 400, 400); |
| 1443 gfx::Rect bounds2(650, 0, 400, 400); | 1437 gfx::Rect bounds2(650, 0, 400, 400); |
| 1444 | 1438 |
| 1445 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1439 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1446 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); | 1440 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); |
| 1447 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2)); | 1441 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2)); |
| 1448 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2)); | 1442 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2)); |
| 1449 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds1)); | 1443 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds1)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 wm::ActivateWindow(window4); | 1498 wm::ActivateWindow(window4); |
| 1505 wm::ActivateWindow(window3); | 1499 wm::ActivateWindow(window3); |
| 1506 wm::ActivateWindow(window2); | 1500 wm::ActivateWindow(window2); |
| 1507 wm::ActivateWindow(window1); | 1501 wm::ActivateWindow(window1); |
| 1508 | 1502 |
| 1509 ToggleOverview(); | 1503 ToggleOverview(); |
| 1510 } | 1504 } |
| 1511 | 1505 |
| 1512 // Tests removing a display during overview. | 1506 // Tests removing a display during overview. |
| 1513 TEST_F(WindowSelectorTest, RemoveDisplay) { | 1507 TEST_F(WindowSelectorTest, RemoveDisplay) { |
| 1514 if (!SupportsMultipleDisplays()) | |
| 1515 return; | |
| 1516 | |
| 1517 UpdateDisplay("400x400,400x400"); | 1508 UpdateDisplay("400x400,400x400"); |
| 1518 gfx::Rect bounds1(0, 0, 100, 100); | 1509 gfx::Rect bounds1(0, 0, 100, 100); |
| 1519 gfx::Rect bounds2(450, 0, 100, 100); | 1510 gfx::Rect bounds2(450, 0, 100, 100); |
| 1520 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1511 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1521 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1512 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| 1522 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); | 1513 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); |
| 1523 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); | 1514 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); |
| 1524 | 1515 |
| 1525 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1516 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1526 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 1517 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 const int index = index_path_for_direction[key_index][i]; | 1678 const int index = index_path_for_direction[key_index][i]; |
| 1688 EXPECT_EQ(GetSelectedWindow()->id(), | 1679 EXPECT_EQ(GetSelectedWindow()->id(), |
| 1689 overview_windows[index - 1]->GetWindow()->GetShellWindowId()); | 1680 overview_windows[index - 1]->GetWindow()->GetShellWindowId()); |
| 1690 } | 1681 } |
| 1691 ToggleOverview(); | 1682 ToggleOverview(); |
| 1692 } | 1683 } |
| 1693 } | 1684 } |
| 1694 | 1685 |
| 1695 // Tests basic selection across multiple monitors. | 1686 // Tests basic selection across multiple monitors. |
| 1696 TEST_F(WindowSelectorTest, BasicMultiMonitorArrowKeyNavigation) { | 1687 TEST_F(WindowSelectorTest, BasicMultiMonitorArrowKeyNavigation) { |
| 1697 if (!SupportsMultipleDisplays()) | |
| 1698 return; | |
| 1699 | |
| 1700 UpdateDisplay("400x400,400x400"); | 1688 UpdateDisplay("400x400,400x400"); |
| 1701 gfx::Rect bounds1(0, 0, 100, 100); | 1689 gfx::Rect bounds1(0, 0, 100, 100); |
| 1702 gfx::Rect bounds2(450, 0, 100, 100); | 1690 gfx::Rect bounds2(450, 0, 100, 100); |
| 1703 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2)); | 1691 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2)); |
| 1704 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2)); | 1692 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2)); |
| 1705 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); | 1693 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); |
| 1706 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1694 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1707 | 1695 |
| 1708 ToggleOverview(); | 1696 ToggleOverview(); |
| 1709 | 1697 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1721 EXPECT_EQ(GetSelectedWindow(), | 1709 EXPECT_EQ(GetSelectedWindow(), |
| 1722 WmWindow::GetAuraWindow(overview_root2[0]->GetWindow())); | 1710 WmWindow::GetAuraWindow(overview_root2[0]->GetWindow())); |
| 1723 SendKey(ui::VKEY_RIGHT); | 1711 SendKey(ui::VKEY_RIGHT); |
| 1724 EXPECT_EQ(GetSelectedWindow(), | 1712 EXPECT_EQ(GetSelectedWindow(), |
| 1725 WmWindow::GetAuraWindow(overview_root2[1]->GetWindow())); | 1713 WmWindow::GetAuraWindow(overview_root2[1]->GetWindow())); |
| 1726 } | 1714 } |
| 1727 | 1715 |
| 1728 // Tests first monitor when display order doesn't match left to right screen | 1716 // Tests first monitor when display order doesn't match left to right screen |
| 1729 // positions. | 1717 // positions. |
| 1730 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) { | 1718 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) { |
| 1731 if (!SupportsMultipleDisplays()) | |
| 1732 return; | |
| 1733 | |
| 1734 UpdateDisplay("400x400,400x400"); | 1719 UpdateDisplay("400x400,400x400"); |
| 1735 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 1720 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 1736 display::test::CreateDisplayLayout(display_manager(), | 1721 display::test::CreateDisplayLayout(display_manager(), |
| 1737 display::DisplayPlacement::LEFT, 0)); | 1722 display::DisplayPlacement::LEFT, 0)); |
| 1738 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1723 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1739 gfx::Rect bounds1(-350, 0, 100, 100); | 1724 gfx::Rect bounds1(-350, 0, 100, 100); |
| 1740 gfx::Rect bounds2(0, 0, 100, 100); | 1725 gfx::Rect bounds2(0, 0, 100, 100); |
| 1741 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1726 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| 1742 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1727 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1743 EXPECT_EQ(root_windows[1], window1->GetRootWindow()); | 1728 EXPECT_EQ(root_windows[1], window1->GetRootWindow()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1754 ToggleOverview(); | 1739 ToggleOverview(); |
| 1755 | 1740 |
| 1756 // Coming from right to left, we should select window2 first being on the | 1741 // Coming from right to left, we should select window2 first being on the |
| 1757 // display on the right. | 1742 // display on the right. |
| 1758 SendKey(ui::VKEY_LEFT); | 1743 SendKey(ui::VKEY_LEFT); |
| 1759 EXPECT_EQ(GetSelectedWindow(), window2.get()); | 1744 EXPECT_EQ(GetSelectedWindow(), window2.get()); |
| 1760 } | 1745 } |
| 1761 | 1746 |
| 1762 // Tests three monitors where the grid becomes empty on one of the monitors. | 1747 // Tests three monitors where the grid becomes empty on one of the monitors. |
| 1763 TEST_F(WindowSelectorTest, ThreeMonitor) { | 1748 TEST_F(WindowSelectorTest, ThreeMonitor) { |
| 1764 if (!SupportsMultipleDisplays()) | |
| 1765 return; | |
| 1766 | |
| 1767 UpdateDisplay("400x400,400x400,400x400"); | 1749 UpdateDisplay("400x400,400x400,400x400"); |
| 1768 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1750 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1769 gfx::Rect bounds1(0, 0, 100, 100); | 1751 gfx::Rect bounds1(0, 0, 100, 100); |
| 1770 gfx::Rect bounds2(400, 0, 100, 100); | 1752 gfx::Rect bounds2(400, 0, 100, 100); |
| 1771 gfx::Rect bounds3(800, 0, 100, 100); | 1753 gfx::Rect bounds3(800, 0, 100, 100); |
| 1772 std::unique_ptr<aura::Window> window3(CreateWindow(bounds3)); | 1754 std::unique_ptr<aura::Window> window3(CreateWindow(bounds3)); |
| 1773 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1755 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| 1774 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1756 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1775 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 1757 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| 1776 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | 1758 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); | 2123 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
| 2142 ASSERT_TRUE(resizer.get()); | 2124 ASSERT_TRUE(resizer.get()); |
| 2143 gfx::Point location = resizer->GetInitialLocation(); | 2125 gfx::Point location = resizer->GetInitialLocation(); |
| 2144 location.Offset(20, 20); | 2126 location.Offset(20, 20); |
| 2145 resizer->Drag(location, 0); | 2127 resizer->Drag(location, 0); |
| 2146 ToggleOverview(); | 2128 ToggleOverview(); |
| 2147 resizer->RevertDrag(); | 2129 resizer->RevertDrag(); |
| 2148 } | 2130 } |
| 2149 | 2131 |
| 2150 } // namespace ash | 2132 } // namespace ash |
| OLD | NEW |