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

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 2667293002: [ash-md] Adds support for gesture to move selection in overview mode (Closed)
Patch Set: [ash-md] Adds support for gesture to move selection in overview mode (tuning) Created 3 years, 10 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 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 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 TEST_F(WindowSelectorTest, BasicTabKeyNavigation) { 1617 TEST_F(WindowSelectorTest, BasicTabKeyNavigation) {
1618 gfx::Rect bounds(0, 0, 100, 100); 1618 gfx::Rect bounds(0, 0, 100, 100);
1619 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1619 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1620 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1620 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1621 ToggleOverview(); 1621 ToggleOverview();
1622 1622
1623 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_windows = 1623 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_windows =
1624 GetWindowItemsForRoot(0); 1624 GetWindowItemsForRoot(0);
1625 SendKey(ui::VKEY_TAB); 1625 SendKey(ui::VKEY_TAB);
1626 EXPECT_EQ(GetSelectedWindow(), 1626 EXPECT_EQ(GetSelectedWindow(),
1627 WmWindow::GetAuraWindow(overview_windows[1]->GetWindow()));
1628 SendKey(ui::VKEY_TAB);
1629 EXPECT_EQ(GetSelectedWindow(),
1627 WmWindow::GetAuraWindow(overview_windows[0]->GetWindow())); 1630 WmWindow::GetAuraWindow(overview_windows[0]->GetWindow()));
1628 SendKey(ui::VKEY_TAB); 1631 SendKey(ui::VKEY_TAB);
1629 EXPECT_EQ(GetSelectedWindow(), 1632 EXPECT_EQ(GetSelectedWindow(),
1630 WmWindow::GetAuraWindow(overview_windows[1]->GetWindow())); 1633 WmWindow::GetAuraWindow(overview_windows[1]->GetWindow()));
1631 SendKey(ui::VKEY_TAB);
1632 EXPECT_EQ(GetSelectedWindow(),
1633 WmWindow::GetAuraWindow(overview_windows[0]->GetWindow()));
1634 } 1634 }
1635 1635
1636 // Tests that pressing Ctrl+W while a window is selected in overview closes it. 1636 // Tests that pressing Ctrl+W while a window is selected in overview closes it.
1637 TEST_F(WindowSelectorTest, CloseWindowWithKey) { 1637 TEST_F(WindowSelectorTest, CloseWindowWithKey) {
1638 gfx::Rect bounds(0, 0, 100, 100); 1638 gfx::Rect bounds(0, 0, 100, 100);
1639 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1640 std::unique_ptr<views::Widget> widget = 1639 std::unique_ptr<views::Widget> widget =
1641 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 1640 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1642 aura::Window* window1 = widget->GetNativeWindow(); 1641 aura::Window* window1 = widget->GetNativeWindow();
1642 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1643 ToggleOverview(); 1643 ToggleOverview();
1644 1644
1645 SendKey(ui::VKEY_RIGHT); 1645 SendKey(ui::VKEY_RIGHT);
1646 EXPECT_EQ(window1, GetSelectedWindow()); 1646 EXPECT_EQ(window1, GetSelectedWindow());
1647 SendCtrlKey(ui::VKEY_W); 1647 SendCtrlKey(ui::VKEY_W);
1648 EXPECT_TRUE(widget->IsClosed()); 1648 EXPECT_TRUE(widget->IsClosed());
1649 } 1649 }
1650 1650
1651 // Tests traversing some windows in overview mode with the arrow keys in every 1651 // Tests traversing some windows in overview mode with the arrow keys in every
1652 // possible direction. 1652 // possible direction.
1653 TEST_F(WindowSelectorTest, BasicArrowKeyNavigation) { 1653 TEST_F(WindowSelectorTest, BasicArrowKeyNavigation) {
1654 const size_t test_windows = 9; 1654 const size_t test_windows = 9;
1655 UpdateDisplay("800x600"); 1655 UpdateDisplay("800x600");
1656 std::vector<std::unique_ptr<aura::Window>> windows; 1656 std::vector<std::unique_ptr<aura::Window>> windows;
1657 for (size_t i = test_windows; i > 0; i--) { 1657 for (size_t i = test_windows; i > 0; i--) {
1658 windows.push_back( 1658 windows.push_back(
1659 base::WrapUnique(CreateWindowWithId(gfx::Rect(0, 0, 100, 100), i))); 1659 base::WrapUnique(CreateWindowWithId(gfx::Rect(0, 0, 100, 100), i)));
1660 } 1660 }
1661 1661
1662 ui::KeyboardCode arrow_keys[] = {ui::VKEY_RIGHT, ui::VKEY_DOWN, ui::VKEY_LEFT, 1662 ui::KeyboardCode arrow_keys[] = {ui::VKEY_RIGHT, ui::VKEY_DOWN, ui::VKEY_LEFT,
1663 ui::VKEY_UP}; 1663 ui::VKEY_UP};
1664 // The rows contain variable number of items making vertical navigation not 1664 // The rows contain variable number of items making vertical navigation not
1665 // feasible. [Down] is equivalent to [Right] and [Up] is equivalent to [Left]. 1665 // feasible. [Down] is equivalent to [Right] and [Up] is equivalent to [Left].
1666 int index_path_for_direction[][test_windows + 1] = { 1666 int index_path_for_direction[][test_windows + 1] = {
1667 {1, 2, 3, 4, 5, 6, 7, 8, 9, 1}, // Right 1667 {2, 3, 4, 5, 6, 7, 8, 9, 1, 2}, // Right
1668 {1, 2, 3, 4, 5, 6, 7, 8, 9, 1}, // Down (same as Right) 1668 {2, 3, 4, 5, 6, 7, 8, 9, 1, 2}, // Down (same as Right)
1669 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9}, // Left 1669 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9}, // Left
1670 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9} // Up (same as Left) 1670 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9} // Up (same as Left)
1671 }; 1671 };
1672 1672
1673 for (size_t key_index = 0; key_index < arraysize(arrow_keys); key_index++) { 1673 for (size_t key_index = 0; key_index < arraysize(arrow_keys); key_index++) {
1674 ToggleOverview(); 1674 ToggleOverview();
1675 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_windows = 1675 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_windows =
1676 GetWindowItemsForRoot(0); 1676 GetWindowItemsForRoot(0);
1677 for (size_t i = 0; i < test_windows + 1; i++) { 1677 for (size_t i = 0; i < test_windows + 1; i++) {
1678 SendKey(arrow_keys[key_index]); 1678 SendKey(arrow_keys[key_index]);
(...skipping 18 matching lines...) Expand all
1697 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); 1697 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1));
1698 1698
1699 ToggleOverview(); 1699 ToggleOverview();
1700 1700
1701 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_root1 = 1701 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_root1 =
1702 GetWindowItemsForRoot(0); 1702 GetWindowItemsForRoot(0);
1703 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_root2 = 1703 const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_root2 =
1704 GetWindowItemsForRoot(1); 1704 GetWindowItemsForRoot(1);
1705 SendKey(ui::VKEY_RIGHT); 1705 SendKey(ui::VKEY_RIGHT);
1706 EXPECT_EQ(GetSelectedWindow(), 1706 EXPECT_EQ(GetSelectedWindow(),
1707 WmWindow::GetAuraWindow(overview_root1[0]->GetWindow()));
1708 SendKey(ui::VKEY_RIGHT);
1709 EXPECT_EQ(GetSelectedWindow(),
1710 WmWindow::GetAuraWindow(overview_root1[1]->GetWindow())); 1707 WmWindow::GetAuraWindow(overview_root1[1]->GetWindow()));
1711 SendKey(ui::VKEY_RIGHT); 1708 SendKey(ui::VKEY_RIGHT);
1712 EXPECT_EQ(GetSelectedWindow(), 1709 EXPECT_EQ(GetSelectedWindow(),
1713 WmWindow::GetAuraWindow(overview_root2[0]->GetWindow())); 1710 WmWindow::GetAuraWindow(overview_root2[0]->GetWindow()));
1714 SendKey(ui::VKEY_RIGHT); 1711 SendKey(ui::VKEY_RIGHT);
1715 EXPECT_EQ(GetSelectedWindow(), 1712 EXPECT_EQ(GetSelectedWindow(),
1716 WmWindow::GetAuraWindow(overview_root2[1]->GetWindow())); 1713 WmWindow::GetAuraWindow(overview_root2[1]->GetWindow()));
1714 SendKey(ui::VKEY_RIGHT);
1715 EXPECT_EQ(GetSelectedWindow(),
1716 WmWindow::GetAuraWindow(overview_root1[0]->GetWindow()));
1717 } 1717 }
1718 1718
1719 // Tests first monitor when display order doesn't match left to right screen 1719 // Tests first monitor when display order doesn't match left to right screen
1720 // positions. 1720 // positions.
1721 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) { 1721 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) {
1722 UpdateDisplay("400x400,400x400"); 1722 UpdateDisplay("400x400,400x400");
1723 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 1723 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
1724 display::test::CreateDisplayLayout(display_manager(), 1724 display::test::CreateDisplayLayout(display_manager(),
1725 display::DisplayPlacement::LEFT, 0)); 1725 display::DisplayPlacement::LEFT, 0));
1726 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1726 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); 2126 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
2127 ASSERT_TRUE(resizer.get()); 2127 ASSERT_TRUE(resizer.get());
2128 gfx::Point location = resizer->GetInitialLocation(); 2128 gfx::Point location = resizer->GetInitialLocation();
2129 location.Offset(20, 20); 2129 location.Offset(20, 20);
2130 resizer->Drag(location, 0); 2130 resizer->Drag(location, 0);
2131 ToggleOverview(); 2131 ToggleOverview();
2132 resizer->RevertDrag(); 2132 resizer->RevertDrag();
2133 } 2133 }
2134 2134
2135 } // namespace ash 2135 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698