Skip to content

Commit

Permalink
Bento: AltTabMode: Show 0-window alt-tab for mode switching
Browse files Browse the repository at this point in the history
If there is no window in the current desk, current-desk-mode
alt-tab can be brought up when there is one or more window on other
desks.

Bug: 1197676
Test: Manual and `ash_unittests --gtest_filter=ModeSelectionWindowCycleControllerTest.NoWindow*`
Change-Id: Idefb1f5eebaed174c5c14f7164c52879266a37f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2880914
Commit-Queue: Cattalyya Nuengsigkapian <cattalyya@chromium.org>
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#881691}
  • Loading branch information
Cattalyya Nuengsigkapian authored and Chromium LUCI CQ committed May 11, 2021
1 parent 4ed9c1b commit bf6854b
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 71 deletions.
44 changes: 38 additions & 6 deletions ash/wm/window_cycle/window_cycle_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2107,17 +2107,16 @@ TEST_F(ModeSelectionWindowCycleControllerTest, OneWindowTotalInActiveDesk) {
CompleteCycling(cycle_controller);
}

// Similar to OneWindowInActiveDesk, tests that alt-tab does not show up if
// there is no window to be shown, but would show "No recent items" if
// switching from the all-desks mode with multiple windows. Additionally,
// tests that while the focus is on the tab slider button, pressing the Down
// arrow key does nothing.
// For no window in the current-desk mode, if there are other windows in other
// desk, tests that alt-tab view always shows up, so the user can switch mode
// and select other windows. Additionally, tests that while the focus is on the
// tab slider button, pressing the Down arrow key does nothing.
TEST_F(ModeSelectionWindowCycleControllerTest, NoWindowInActiveDesk) {
WindowCycleController* cycle_controller =
Shell::Get()->window_cycle_controller();
ui::test::EventGenerator* generator = GetEventGenerator();

// Create two desks with all two windows in desk1.
// Create two desks with a window in desk1.
auto win0 = CreateAppWindow(gfx::Rect(0, 0, 250, 100));
auto win1 = CreateAppWindow(gfx::Rect(50, 50, 200, 200));
auto* desks_controller = DesksController::Get();
Expand Down Expand Up @@ -2158,6 +2157,39 @@ TEST_F(ModeSelectionWindowCycleControllerTest, NoWindowInActiveDesk) {
EXPECT_TRUE(cycle_controller->IsAltTabPerActiveDesk());

CompleteCycling(cycle_controller);

// Entering alt-tab in the current-desk mode with zero window should work and
// show no-recent-item label.
cycle_controller->StartCycling();
cycle_windows = GetWindows(cycle_controller);
EXPECT_EQ(0u, GetWindowCycleItemViews().size());
EXPECT_EQ(cycle_windows.size(), GetWindowCycleItemViews().size());
EXPECT_EQ(nullptr, GetTargetWindow());
EXPECT_TRUE(GetWindowCycleNoRecentItemsLabel()->GetVisible());
}

// For no window in the current-desk mode, if there is no other window in
// other desks, tests that alt-tab does not show up.
TEST_F(ModeSelectionWindowCycleControllerTest, NoWindowTotalInActiveDesk) {
WindowCycleController* cycle_controller =
Shell::Get()->window_cycle_controller();

// Create two desks with all two windows in desk1.
auto* desks_controller = DesksController::Get();
desks_controller->NewDesk(DesksCreationRemovalSource::kButton);
ASSERT_EQ(2u, desks_controller->desks().size());
const Desk* desk_2 = desks_controller->desks()[1].get();

// Activate desk2.
ActivateDesk(desk_2);
EXPECT_EQ(desk_2, desks_controller->active_desk());

// Starting alt-tab should show all windows from all desks.
cycle_controller->HandleCycleWindow(
WindowCycleController::WindowCyclingDirection::kForward);
EXPECT_TRUE(cycle_controller->IsCycling());
EXPECT_FALSE(CycleViewExists());
CompleteCycling(cycle_controller);
}

// Tests that switching between modes correctly reset the alt-tab-highlighted
Expand Down
Loading

0 comments on commit bf6854b

Please sign in to comment.