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

Side by Side Diff: ash/wm/window_cycle_controller_unittest.cc

Issue 2389323002: Start Alt+Tab on MRU instead of MRU+1 if all windows are minimized. (Closed)
Patch Set: Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/wm/window_cycle_controller.h" 5 #include "ash/common/wm/window_cycle_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/aura/wm_window_aura.h" 10 #include "ash/aura/wm_window_aura.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 EXPECT_FALSE(window0_state->IsActive()); 288 EXPECT_FALSE(window0_state->IsActive());
289 EXPECT_FALSE(window1_state->IsMinimized()); 289 EXPECT_FALSE(window1_state->IsMinimized());
290 EXPECT_TRUE(window1_state->IsActive()); 290 EXPECT_TRUE(window1_state->IsActive());
291 291
292 // One more time back to w0. 292 // One more time back to w0.
293 controller->HandleCycleWindow(WindowCycleController::FORWARD); 293 controller->HandleCycleWindow(WindowCycleController::FORWARD);
294 controller->StopCycling(); 294 controller->StopCycling();
295 EXPECT_TRUE(window0_state->IsActive()); 295 EXPECT_TRUE(window0_state->IsActive());
296 } 296 }
297 297
298 // If all windows are minimized, start on the first one rather than the second
varkha 2016/10/06 03:31:08 Nit: "Tests that when all windows are minimized, c
Evan Stade 2016/10/06 15:40:33 Done.
299 // one.
300 TEST_F(WindowCycleControllerTest, AllAreMinimized) {
301 // Create a couple of test windows.
302 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0));
303 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1));
304 wm::WindowState* window0_state = wm::GetWindowState(window0.get());
305 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
306
307 window0_state->Minimize();
308 window1_state->Minimize();
309
310 WindowCycleController* controller = WmShell::Get()->window_cycle_controller();
311 controller->HandleCycleWindow(WindowCycleController::FORWARD);
312 controller->StopCycling();
313 EXPECT_TRUE(window0_state->IsActive());
314 EXPECT_FALSE(window0_state->IsMinimized());
315 EXPECT_TRUE(window1_state->IsMinimized());
316
317 // But it's business as usual when cycling backwards.
318 window0_state->Minimize();
319 window1_state->Minimize();
varkha 2016/10/06 03:31:08 Redundant?
Evan Stade 2016/10/06 15:40:33 seems harmless but improves legibility
320 controller->HandleCycleWindow(WindowCycleController::BACKWARD);
321 controller->StopCycling();
322 EXPECT_TRUE(window0_state->IsMinimized());
323 EXPECT_TRUE(window1_state->IsActive());
324 EXPECT_FALSE(window1_state->IsMinimized());
325 }
326
298 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { 327 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) {
299 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); 328 WindowCycleController* controller = WmShell::Get()->window_cycle_controller();
300 329
301 // Set up several windows to use to test cycling. 330 // Set up several windows to use to test cycling.
302 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); 331 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0));
303 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); 332 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1));
304 333
305 Window* top_container = Shell::GetContainer( 334 Window* top_container = Shell::GetContainer(
306 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); 335 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer);
307 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); 336 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container));
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // without the new alt+tab selector we check for the event on either 692 // without the new alt+tab selector we check for the event on either
664 // fullscreen window. 693 // fullscreen window.
665 EventCounter event_count; 694 EventCounter event_count;
666 w0->AddPreTargetHandler(&event_count); 695 w0->AddPreTargetHandler(&event_count);
667 w1->AddPreTargetHandler(&event_count); 696 w1->AddPreTargetHandler(&event_count);
668 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 697 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
669 EXPECT_EQ(1, event_count.GetKeyEventCountAndReset()); 698 EXPECT_EQ(1, event_count.GetKeyEventCountAndReset());
670 } 699 }
671 700
672 } // namespace ash 701 } // namespace ash
OLDNEW
« ash/common/wm/window_cycle_list.cc ('K') | « ash/common/wm/window_cycle_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698