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

Unified Diff: ash/wm/overview/window_selector_unittest.cc

Issue 260883005: Separated alt-tab window cycle from overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed issues in window_cycle_controller Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/overview/window_selector_unittest.cc
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index 3389283b1e27bb2ed45b3b9946e9280391c0aae8..5d9c4adeaadf76d289649cee42c90fde77e5add8 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -156,25 +156,6 @@ class WindowSelectorTest : public test::AshTestBase {
ash::Shell::GetInstance()->window_selector_controller()->ToggleOverview();
}
- void Cycle(WindowSelector::Direction direction) {
- ash::Shell::GetInstance()->window_selector_controller()->
- HandleCycleWindow(direction);
- }
-
- void StopCycling() {
- ash::Shell::GetInstance()->window_selector_controller()->window_selector_->
- SelectWindow();
- }
-
- void FireOverviewStartTimer() {
- // Calls the method to start overview mode which is normally called by the
- // timer. The timer will still fire and call this method triggering the
- // DCHECK that overview mode was not already started, except that we call
- // StopCycling before the timer has a chance to fire.
- ash::Shell::GetInstance()->window_selector_controller()->window_selector_->
- StartOverview();
- }
-
gfx::Transform GetTransformRelativeTo(gfx::PointF origin,
const gfx::Transform& transform) {
gfx::Transform t;
@@ -342,16 +323,6 @@ TEST_F(WindowSelectorTest, FullscreenWindow) {
ToggleOverview();
ClickWindow(window2.get());
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen());
-
- // Verify that selecting the panel will make it visible.
- // TODO(flackr): Click on panel rather than cycle to it when
- // clicking on panels is fixed, see http://crbug.com/339834.
- Cycle(WindowSelector::FORWARD);
- Cycle(WindowSelector::FORWARD);
- StopCycling();
- EXPECT_TRUE(wm::GetWindowState(panel1.get())->IsActive());
- EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen());
- EXPECT_TRUE(panel1->IsVisible());
}
// Tests that the shelf dimming state is removed while in overview and restored
@@ -379,18 +350,6 @@ TEST_F(WindowSelectorTest, SelectingHidesAppList) {
ToggleOverview();
EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility());
ToggleOverview();
-
- // The app list uses an animation to fade out. If it is toggled on immediately
- // after being removed the old widget is re-used and it does not gain focus.
- // When running under normal circumstances this shouldn't be possible, but
- // it is in a test without letting the message loop run.
- RunAllPendingInMessageLoop();
-
- Shell::GetInstance()->ToggleAppList(NULL);
- EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility());
- Cycle(WindowSelector::FORWARD);
- EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility());
- StopCycling();
}
// Tests that a minimized window's visibility and layer visibility is correctly
@@ -434,192 +393,6 @@ TEST_F(WindowSelectorTest, BoundsChangeDuringOverview) {
ToggleOverview();
}
-// Tests entering overview mode with three windows and cycling through them.
-TEST_F(WindowSelectorTest, BasicCycle) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- scoped_ptr<aura::Window> window3(CreateWindow(bounds));
- wm::ActivateWindow(window3.get());
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
- EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
- EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
- EXPECT_FALSE(wm::IsActiveWindow(window3.get()));
-
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(IsSelecting());
- EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
-
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(wm::IsActiveWindow(window3.get()));
-
- StopCycling();
- EXPECT_FALSE(IsSelecting());
- EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
- EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
- EXPECT_TRUE(wm::IsActiveWindow(window3.get()));
-}
-
-// Tests that cycling through windows preserves the window stacking order.
-TEST_F(WindowSelectorTest, CyclePreservesStackingOrder) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- scoped_ptr<aura::Window> window3(CreateWindow(bounds));
- wm::ActivateWindow(window3.get());
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
- // Window order from top to bottom is 1, 2, 3.
- EXPECT_TRUE(IsWindowAbove(window1.get(), window2.get()));
- EXPECT_TRUE(IsWindowAbove(window2.get(), window3.get()));
-
- // On window 2.
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(IsWindowAbove(window2.get(), window1.get()));
- EXPECT_TRUE(IsWindowAbove(window1.get(), window3.get()));
-
- // On window 3.
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(IsWindowAbove(window3.get(), window1.get()));
- EXPECT_TRUE(IsWindowAbove(window1.get(), window2.get()));
-
- // Back on window 1.
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(IsWindowAbove(window1.get(), window2.get()));
- EXPECT_TRUE(IsWindowAbove(window2.get(), window3.get()));
- StopCycling();
-}
-
-// Tests that cycling through windows shows and minimizes windows as they
-// are passed.
-TEST_F(WindowSelectorTest, CyclePreservesMinimization) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- wm::ActivateWindow(window2.get());
- wm::GetWindowState(window2.get())->Minimize();
- wm::ActivateWindow(window1.get());
- EXPECT_TRUE(wm::IsWindowMinimized(window2.get()));
-
- // On window 2.
- Cycle(WindowSelector::FORWARD);
- EXPECT_FALSE(wm::IsWindowMinimized(window2.get()));
-
- // Back on window 1.
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(wm::IsWindowMinimized(window2.get()));
-
- StopCycling();
- EXPECT_TRUE(wm::IsWindowMinimized(window2.get()));
-}
-
-// Tests beginning cycling while in overview mode.
-TEST_F(WindowSelectorTest, OverviewTransitionToCycle) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
-
- ToggleOverview();
- Cycle(WindowSelector::FORWARD);
- StopCycling();
-
- EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
- EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
- EXPECT_EQ(window2.get(), GetFocusedWindow());
-}
-
-// Tests cycles between panel and normal windows.
-TEST_F(WindowSelectorTest, CyclePanels) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
- scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds));
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
- wm::ActivateWindow(panel2.get());
- wm::ActivateWindow(panel1.get());
- EXPECT_TRUE(wm::IsActiveWindow(panel1.get()));
-
- // Cycling once should select window1 since the panels are grouped into a
- // single selectable item.
- Cycle(WindowSelector::FORWARD);
- StopCycling();
- EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
-
- // Cycling again should select the most recently used panel.
- Cycle(WindowSelector::FORWARD);
- StopCycling();
- EXPECT_TRUE(wm::IsActiveWindow(panel1.get()));
-}
-
-// Tests the visibility of panel windows during cycling.
-TEST_F(WindowSelectorTest, CyclePanelVisibility) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
- wm::ActivateWindow(panel1.get());
- wm::ActivateWindow(window1.get());
-
- Cycle(WindowSelector::FORWARD);
- FireOverviewStartTimer();
- EXPECT_EQ(1.0f, panel1->layer()->GetTargetOpacity());
- StopCycling();
-}
-
-// Tests cycles between panel and normal windows.
-TEST_F(WindowSelectorTest, CyclePanelsDestroyed) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- scoped_ptr<aura::Window> window3(CreateWindow(bounds));
- scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
- scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds));
- wm::ActivateWindow(window3.get());
- wm::ActivateWindow(panel2.get());
- wm::ActivateWindow(panel1.get());
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
- EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
-
- // Cycling once highlights window2.
- Cycle(WindowSelector::FORWARD);
- // All panels are destroyed.
- panel1.reset();
- panel2.reset();
- // Cycling again should now select window3.
- Cycle(WindowSelector::FORWARD);
- StopCycling();
- EXPECT_TRUE(wm::IsActiveWindow(window3.get()));
-}
-
-// Tests cycles between panel and normal windows.
-TEST_F(WindowSelectorTest, CycleMruPanelDestroyed) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
- scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds));
- wm::ActivateWindow(panel2.get());
- wm::ActivateWindow(panel1.get());
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
- EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
-
- // Cycling once highlights window2.
- Cycle(WindowSelector::FORWARD);
- // Panel 1 is the next item as the MRU panel, removing it should make panel 2
- // the next window to be selected.
- panel1.reset();
- // Cycling again should now select window3.
- Cycle(WindowSelector::FORWARD);
- StopCycling();
- EXPECT_TRUE(wm::IsActiveWindow(panel2.get()));
-}
-
// Tests that a newly created window aborts overview.
TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) {
gfx::Rect bounds(0, 0, 400, 400);
@@ -651,24 +424,6 @@ TEST_F(WindowSelectorTest, ActivationCancelsOveriew) {
EXPECT_EQ(window1.get(), GetFocusedWindow());
}
-// Verifies that overview mode only begins after a delay when cycling.
-TEST_F(WindowSelectorTest, CycleOverviewDelay) {
- gfx::Rect bounds(0, 0, 400, 400);
- scoped_ptr<aura::Window> window1(CreateWindow(bounds));
- scoped_ptr<aura::Window> window2(CreateWindow(bounds));
- EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get()));
-
- // When cycling first starts, the windows will still be overlapping.
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(IsSelecting());
- EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get()));
-
- // Once the overview timer fires, the windows should no longer overlap.
- FireOverviewStartTimer();
- EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get()));
- StopCycling();
-}
-
// Tests that exiting overview mode without selecting a window restores focus
// to the previously focused window.
TEST_F(WindowSelectorTest, CancelRestoresFocus) {
@@ -845,168 +600,6 @@ TEST_F(WindowSelectorTest, MultipleDisplays) {
EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel3.get()));
}
-// Verifies that the single display overview used during alt tab cycling uses
-// the display of the selected window by default.
-TEST_F(WindowSelectorTest, CycleOverviewUsesCurrentDisplay) {
- if (!SupportsMultipleDisplays())
- return;
-
- UpdateDisplay("400x400,400x400");
- aura::Window::Windows root_windows = Shell::GetAllRootWindows();
-
- scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(0, 0, 100, 100)));
- scoped_ptr<aura::Window> window2(CreateWindow(gfx::Rect(450, 0, 100, 100)));
- EXPECT_EQ(root_windows[0], window1->GetRootWindow());
- EXPECT_EQ(root_windows[1], window2->GetRootWindow());
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
- EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow());
-
- Cycle(WindowSelector::FORWARD);
- FireOverviewStartTimer();
-
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(window1.get()))));
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(window2.get()))));
- StopCycling();
-}
-
-// Verifies that the windows being shown on another display are copied.
-TEST_F(WindowSelectorTest, CycleMultipleDisplaysCopiesWindows) {
- if (!SupportsMultipleDisplays())
- return;
-
- UpdateDisplay("400x400,400x400");
- aura::Window::Windows root_windows = Shell::GetAllRootWindows();
-
- gfx::Rect root1_rect(0, 0, 100, 100);
- gfx::Rect root2_rect(450, 0, 100, 100);
- scoped_ptr<aura::Window> unmoved1(CreateWindow(root2_rect));
- scoped_ptr<aura::Window> unmoved2(CreateWindow(root2_rect));
- scoped_ptr<aura::Window> moved1_trans_parent(CreateWindow(root1_rect));
- scoped_ptr<aura::Window> moved1(CreateWindow(root1_rect));
- unmoved1->SetName("unmoved1");
- unmoved2->SetName("unmoved2");
- moved1->SetName("moved1");
- moved1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
- ::wm::AddTransientChild(moved1_trans_parent.get(), moved1.get());
- moved1_trans_parent->SetName("moved1_trans_parent");
-
- EXPECT_EQ(root_windows[0], moved1->GetRootWindow());
- EXPECT_EQ(root_windows[0], moved1_trans_parent->GetRootWindow());
- EXPECT_EQ(root_windows[1], unmoved1->GetRootWindow());
- EXPECT_EQ(root_windows[1], unmoved2->GetRootWindow());
- wm::ActivateWindow(unmoved2.get());
- wm::ActivateWindow(unmoved1.get());
-
- Cycle(WindowSelector::FORWARD);
- FireOverviewStartTimer();
-
- // All windows are moved to second root window.
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(unmoved1.get()))));
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(unmoved2.get()))));
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(moved1.get()))));
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(moved1_trans_parent.get()))));
-
- // unmoved1 and unmoved2 were already on the correct display and should not
- // have been copied.
- EXPECT_TRUE(!GetCopyWindow(unmoved1.get()));
- EXPECT_TRUE(!GetCopyWindow(unmoved2.get()));
-
- // moved1 and its transient parent moved1_trans_parent should have also been
- // copied for displaying on root_windows[1].
- aura::Window* copy1 = GetCopyWindow(moved1.get());
- aura::Window* copy1_trans_parent = GetCopyWindow(moved1_trans_parent.get());
- ASSERT_FALSE(!copy1);
- ASSERT_FALSE(!copy1_trans_parent);
-
- // Verify that the bounds and transform of the copy match the original window
- // but that it is on the other root window.
- EXPECT_EQ(root_windows[1], copy1->GetRootWindow());
- EXPECT_EQ(moved1->GetBoundsInScreen().ToString(),
- copy1->GetBoundsInScreen().ToString());
- EXPECT_EQ(moved1->layer()->GetTargetTransform().ToString(),
- copy1->layer()->GetTargetTransform().ToString());
- StopCycling();
-
- // After cycling the copy windows should have been destroyed.
- RunAllPendingInMessageLoop();
- EXPECT_TRUE(!GetCopyWindow(moved1.get()));
- EXPECT_TRUE(!GetCopyWindow(moved1_trans_parent.get()));
-}
-
-// Tests that beginning to cycle from overview mode moves windows to the
-// active display.
-TEST_F(WindowSelectorTest, MultipleDisplaysOverviewTransitionToCycle) {
- if (!SupportsMultipleDisplays())
- return;
-
- UpdateDisplay("400x400,400x400");
- aura::Window::Windows root_windows = Shell::GetAllRootWindows();
-
- scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(0, 0, 100, 100)));
- scoped_ptr<aura::Window> window2(CreateWindow(gfx::Rect(450, 0, 100, 100)));
- EXPECT_EQ(root_windows[0], window1->GetRootWindow());
- EXPECT_EQ(root_windows[1], window2->GetRootWindow());
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window1.get());
-
- ToggleOverview();
- EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(window1.get()))));
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(window2.get()))));
-
- Cycle(WindowSelector::FORWARD);
- EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(window1.get()))));
- EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains(
- ToEnclosingRect(GetTransformedTargetBounds(window2.get()))));
- StopCycling();
-}
-
-// Tests that a bounds change during overview is corrected for.
-TEST_F(WindowSelectorTest, BoundsChangeDuringCycleOnOtherDisplay) {
- if (!SupportsMultipleDisplays())
- return;
-
- UpdateDisplay("400x400,400x400");
- aura::Window::Windows root_windows = Shell::GetAllRootWindows();
-
- scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(0, 0, 100, 100)));
- scoped_ptr<aura::Window> window2(CreateWindow(gfx::Rect(450, 0, 100, 100)));
- scoped_ptr<aura::Window> window3(CreateWindow(gfx::Rect(450, 0, 100, 100)));
- EXPECT_EQ(root_windows[0], window1->GetRootWindow());
- EXPECT_EQ(root_windows[1], window2->GetRootWindow());
- EXPECT_EQ(root_windows[1], window3->GetRootWindow());
- wm::ActivateWindow(window1.get());
- wm::ActivateWindow(window2.get());
- wm::ActivateWindow(window3.get());
-
- Cycle(WindowSelector::FORWARD);
- FireOverviewStartTimer();
-
- gfx::Rect overview_bounds(
- ToEnclosingRect(GetTransformedTargetBounds(window1.get())));
- EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(overview_bounds));
-
- // Change the position and size of window1 (being displayed on the second
- // root window) and it should remain within the same bounds.
- window1->SetBounds(gfx::Rect(100, 0, 200, 200));
- gfx::Rect new_overview_bounds =
- ToEnclosingRect(GetTransformedTargetBounds(window1.get()));
- EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x());
- EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y());
- EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width());
- EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height());
- StopCycling();
-}
-
// Tests shutting down during overview.
TEST_F(WindowSelectorTest, Shutdown) {
gfx::Rect bounds(0, 0, 400, 400);

Powered by Google App Engine
This is Rietveld 408576698