| OLD | NEW |
| 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/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" |
| 11 #include "ash/common/focus_cycler.h" | 11 #include "ash/common/focus_cycler.h" |
| 12 #include "ash/common/session/session_state_delegate.h" | 12 #include "ash/common/session/session_state_delegate.h" |
| 13 #include "ash/common/shell_window_ids.h" | 13 #include "ash/common/shell_window_ids.h" |
| 14 #include "ash/common/wm/window_cycle_list.h" |
| 14 #include "ash/common/wm/window_state.h" | 15 #include "ash/common/wm/window_state.h" |
| 15 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
| 16 #include "ash/shelf/shelf.h" | 17 #include "ash/shelf/shelf.h" |
| 17 #include "ash/shelf/shelf_widget.h" | 18 #include "ash/shelf/shelf_widget.h" |
| 18 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 19 #include "ash/test/ash_test_base.h" | 20 #include "ash/test/ash_test_base.h" |
| 20 #include "ash/test/shelf_test_api.h" | 21 #include "ash/test/shelf_test_api.h" |
| 21 #include "ash/test/shelf_view_test_api.h" | 22 #include "ash/test/shelf_view_test_api.h" |
| 22 #include "ash/test/test_shelf_delegate.h" | 23 #include "ash/test/test_shelf_delegate.h" |
| 23 #include "ash/test/test_shell_delegate.h" | 24 #include "ash/test/test_shell_delegate.h" |
| 24 #include "ash/wm/window_cycle_list.h" | |
| 25 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
| 26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
| 27 #include "ui/aura/client/aura_constants.h" | 27 #include "ui/aura/client/aura_constants.h" |
| 28 #include "ui/aura/client/screen_position_client.h" | 28 #include "ui/aura/client/screen_position_client.h" |
| 29 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
| 30 #include "ui/aura/test/test_windows.h" | 30 #include "ui/aura/test/test_windows.h" |
| 31 #include "ui/aura/window.h" | 31 #include "ui/aura/window.h" |
| 32 #include "ui/aura/window_event_dispatcher.h" | 32 #include "ui/aura/window_event_dispatcher.h" |
| 33 #include "ui/events/event_handler.h" | 33 #include "ui/events/event_handler.h" |
| 34 #include "ui/events/test/event_generator.h" | 34 #include "ui/events/test/event_generator.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 controller->window_cycle_list()->windows()); | 96 controller->window_cycle_list()->windows()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 100 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(WindowCycleControllerTest); | 102 DISALLOW_COPY_AND_ASSIGN(WindowCycleControllerTest); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { | 105 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { |
| 106 WindowCycleController* controller = | 106 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 107 Shell::GetInstance()->window_cycle_controller(); | |
| 108 | 107 |
| 109 // Cycling doesn't crash if there are no windows. | 108 // Cycling doesn't crash if there are no windows. |
| 110 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 109 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 111 | 110 |
| 112 // Create a single test window. | 111 // Create a single test window. |
| 113 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 112 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 114 wm::ActivateWindow(window0.get()); | 113 wm::ActivateWindow(window0.get()); |
| 115 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 114 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 116 | 115 |
| 117 // Cycling works for a single window, even though nothing changes. | 116 // Cycling works for a single window, even though nothing changes. |
| 118 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 117 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 119 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 118 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 120 } | 119 } |
| 121 | 120 |
| 122 // Verifies if there is only one window and it isn't active that cycling | 121 // Verifies if there is only one window and it isn't active that cycling |
| 123 // activates it. | 122 // activates it. |
| 124 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { | 123 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { |
| 125 WindowCycleController* controller = | 124 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 126 Shell::GetInstance()->window_cycle_controller(); | |
| 127 | 125 |
| 128 // Create a single test window. | 126 // Create a single test window. |
| 129 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 127 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 130 wm::ActivateWindow(window0.get()); | 128 wm::ActivateWindow(window0.get()); |
| 131 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 129 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 132 | 130 |
| 133 // Rotate focus, this should move focus to another window that isn't part of | 131 // Rotate focus, this should move focus to another window that isn't part of |
| 134 // the default container. | 132 // the default container. |
| 135 WmShell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 133 WmShell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 136 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 134 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
| 137 | 135 |
| 138 // Cycling should activate the window. | 136 // Cycling should activate the window. |
| 139 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 137 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 140 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 138 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 141 } | 139 } |
| 142 | 140 |
| 143 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { | 141 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { |
| 144 WindowCycleController* controller = | 142 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 145 Shell::GetInstance()->window_cycle_controller(); | |
| 146 | 143 |
| 147 // Set up several windows to use to test cycling. Create them in reverse | 144 // Set up several windows to use to test cycling. Create them in reverse |
| 148 // order so they are stacked 0 over 1 over 2. | 145 // order so they are stacked 0 over 1 over 2. |
| 149 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); | 146 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); |
| 150 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 147 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 151 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 148 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 152 wm::ActivateWindow(window0.get()); | 149 wm::ActivateWindow(window0.get()); |
| 153 | 150 |
| 154 // Simulate pressing and releasing Alt-tab. | 151 // Simulate pressing and releasing Alt-tab. |
| 155 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 152 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 TEST_F(WindowCycleControllerTest, MaximizedWindow) { | 240 TEST_F(WindowCycleControllerTest, MaximizedWindow) { |
| 244 // Create a couple of test windows. | 241 // Create a couple of test windows. |
| 245 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 242 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 246 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 243 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 247 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 244 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| 248 window1_state->Maximize(); | 245 window1_state->Maximize(); |
| 249 window1_state->Activate(); | 246 window1_state->Activate(); |
| 250 EXPECT_TRUE(window1_state->IsActive()); | 247 EXPECT_TRUE(window1_state->IsActive()); |
| 251 | 248 |
| 252 // Rotate focus, this should move focus to window0. | 249 // Rotate focus, this should move focus to window0. |
| 253 WindowCycleController* controller = | 250 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 254 Shell::GetInstance()->window_cycle_controller(); | |
| 255 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 251 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 256 EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive()); | 252 EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive()); |
| 257 | 253 |
| 258 // One more time. | 254 // One more time. |
| 259 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 255 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 260 EXPECT_TRUE(window1_state->IsActive()); | 256 EXPECT_TRUE(window1_state->IsActive()); |
| 261 } | 257 } |
| 262 | 258 |
| 263 // Cycles to a minimized window. | 259 // Cycles to a minimized window. |
| 264 TEST_F(WindowCycleControllerTest, Minimized) { | 260 TEST_F(WindowCycleControllerTest, Minimized) { |
| 265 // Create a couple of test windows. | 261 // Create a couple of test windows. |
| 266 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 262 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 267 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 263 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 268 wm::WindowState* window0_state = wm::GetWindowState(window0.get()); | 264 wm::WindowState* window0_state = wm::GetWindowState(window0.get()); |
| 269 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 265 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| 270 | 266 |
| 271 window1_state->Minimize(); | 267 window1_state->Minimize(); |
| 272 window0_state->Activate(); | 268 window0_state->Activate(); |
| 273 EXPECT_TRUE(window0_state->IsActive()); | 269 EXPECT_TRUE(window0_state->IsActive()); |
| 274 | 270 |
| 275 // Rotate focus, this should move focus to window1 and unminimize it. | 271 // Rotate focus, this should move focus to window1 and unminimize it. |
| 276 WindowCycleController* controller = | 272 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 277 Shell::GetInstance()->window_cycle_controller(); | |
| 278 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 273 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 279 EXPECT_FALSE(window1_state->IsMinimized()); | 274 EXPECT_FALSE(window1_state->IsMinimized()); |
| 280 EXPECT_TRUE(window1_state->IsActive()); | 275 EXPECT_TRUE(window1_state->IsActive()); |
| 281 | 276 |
| 282 // One more time back to w0. | 277 // One more time back to w0. |
| 283 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 278 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 284 EXPECT_TRUE(window0_state->IsActive()); | 279 EXPECT_TRUE(window0_state->IsActive()); |
| 285 } | 280 } |
| 286 | 281 |
| 287 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { | 282 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { |
| 288 WindowCycleController* controller = | 283 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 289 Shell::GetInstance()->window_cycle_controller(); | |
| 290 | 284 |
| 291 // Set up several windows to use to test cycling. | 285 // Set up several windows to use to test cycling. |
| 292 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 286 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 293 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 287 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 294 | 288 |
| 295 Window* top_container = Shell::GetContainer( | 289 Window* top_container = Shell::GetContainer( |
| 296 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); | 290 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); |
| 297 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 291 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
| 298 wm::ActivateWindow(window0.get()); | 292 wm::ActivateWindow(window0.get()); |
| 299 | 293 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 320 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 314 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 321 | 315 |
| 322 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 316 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 323 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 317 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 324 | 318 |
| 325 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 319 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 326 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 320 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 327 } | 321 } |
| 328 | 322 |
| 329 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { | 323 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { |
| 330 WindowCycleController* controller = | 324 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 331 Shell::GetInstance()->window_cycle_controller(); | |
| 332 | 325 |
| 333 // Set up several windows to use to test cycling. | 326 // Set up several windows to use to test cycling. |
| 334 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 327 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 335 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 328 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 336 | 329 |
| 337 Window* top_container = Shell::GetContainer( | 330 Window* top_container = Shell::GetContainer( |
| 338 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); | 331 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); |
| 339 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 332 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
| 340 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); | 333 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); |
| 341 wm::ActivateWindow(window0.get()); | 334 wm::ActivateWindow(window0.get()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 368 |
| 376 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) { | 369 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) { |
| 377 if (!SupportsMultipleDisplays()) | 370 if (!SupportsMultipleDisplays()) |
| 378 return; | 371 return; |
| 379 | 372 |
| 380 // Set up a second root window | 373 // Set up a second root window |
| 381 UpdateDisplay("1000x600,600x400"); | 374 UpdateDisplay("1000x600,600x400"); |
| 382 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 375 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 383 ASSERT_EQ(2U, root_windows.size()); | 376 ASSERT_EQ(2U, root_windows.size()); |
| 384 | 377 |
| 385 WindowCycleController* controller = | 378 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 386 Shell::GetInstance()->window_cycle_controller(); | |
| 387 | 379 |
| 388 Shell::GetInstance()->set_target_root_window(root_windows[0]); | 380 Shell::GetInstance()->set_target_root_window(root_windows[0]); |
| 389 | 381 |
| 390 // Create two windows in the primary root. | 382 // Create two windows in the primary root. |
| 391 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 383 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 392 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); | 384 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); |
| 393 Window* top_container0 = | 385 Window* top_container0 = |
| 394 Shell::GetContainer(root_windows[0], kShellWindowId_AlwaysOnTopContainer); | 386 Shell::GetContainer(root_windows[0], kShellWindowId_AlwaysOnTopContainer); |
| 395 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); | 387 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); |
| 396 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 388 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 434 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 443 | 435 |
| 444 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 436 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 445 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 437 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 446 | 438 |
| 447 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 439 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 448 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 440 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 449 } | 441 } |
| 450 | 442 |
| 451 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { | 443 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { |
| 452 WindowCycleController* controller = | 444 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 453 Shell::GetInstance()->window_cycle_controller(); | |
| 454 | 445 |
| 455 // Set up several windows to use to test cycling. | 446 // Set up several windows to use to test cycling. |
| 456 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 447 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 457 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 448 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 458 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); | 449 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); |
| 459 | 450 |
| 460 wm::ActivateWindow(window0.get()); | 451 wm::ActivateWindow(window0.get()); |
| 461 | 452 |
| 462 // Simulate pressing and releasing Alt-tab. | 453 // Simulate pressing and releasing Alt-tab. |
| 463 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 454 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 484 | 475 |
| 485 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 476 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 486 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 477 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 487 | 478 |
| 488 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 479 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 489 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 480 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 490 } | 481 } |
| 491 | 482 |
| 492 // Tests that beginning window selection hides the app list. | 483 // Tests that beginning window selection hides the app list. |
| 493 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { | 484 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { |
| 494 WindowCycleController* controller = | 485 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 495 Shell::GetInstance()->window_cycle_controller(); | |
| 496 | 486 |
| 497 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 487 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 498 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 488 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 499 Shell::GetInstance()->ShowAppList(NULL); | 489 Shell::GetInstance()->ShowAppList(NULL); |
| 500 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 490 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 501 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 491 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 502 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 492 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 503 } | 493 } |
| 504 | 494 |
| 505 // Tests that cycling through windows shows and minimizes windows as they | 495 // Tests that cycling through windows shows and minimizes windows as they |
| 506 // are passed. | 496 // are passed. |
| 507 TEST_F(WindowCycleControllerTest, CyclePreservesMinimization) { | 497 TEST_F(WindowCycleControllerTest, CyclePreservesMinimization) { |
| 508 WindowCycleController* controller = | 498 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 509 Shell::GetInstance()->window_cycle_controller(); | |
| 510 | 499 |
| 511 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 500 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 512 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 501 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 513 wm::ActivateWindow(window1.get()); | 502 wm::ActivateWindow(window1.get()); |
| 514 wm::GetWindowState(window1.get())->Minimize(); | 503 wm::GetWindowState(window1.get())->Minimize(); |
| 515 wm::ActivateWindow(window0.get()); | 504 wm::ActivateWindow(window0.get()); |
| 516 EXPECT_TRUE(IsWindowMinimized(window1.get())); | 505 EXPECT_TRUE(IsWindowMinimized(window1.get())); |
| 517 | 506 |
| 518 // On window 2. | 507 // On window 2. |
| 519 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 508 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 520 EXPECT_FALSE(IsWindowMinimized(window1.get())); | 509 EXPECT_FALSE(IsWindowMinimized(window1.get())); |
| 521 | 510 |
| 522 // Back on window 1. | 511 // Back on window 1. |
| 523 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 512 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 524 EXPECT_TRUE(IsWindowMinimized(window1.get())); | 513 EXPECT_TRUE(IsWindowMinimized(window1.get())); |
| 525 | 514 |
| 526 controller->StopCycling(); | 515 controller->StopCycling(); |
| 527 | 516 |
| 528 EXPECT_TRUE(IsWindowMinimized(window1.get())); | 517 EXPECT_TRUE(IsWindowMinimized(window1.get())); |
| 529 } | 518 } |
| 530 | 519 |
| 531 // Tests cycles between panel and normal windows. | 520 // Tests cycles between panel and normal windows. |
| 532 TEST_F(WindowCycleControllerTest, CyclePanels) { | 521 TEST_F(WindowCycleControllerTest, CyclePanels) { |
| 533 WindowCycleController* controller = | 522 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 534 Shell::GetInstance()->window_cycle_controller(); | |
| 535 | 523 |
| 536 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 524 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 537 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); | 525 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); |
| 538 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); | 526 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); |
| 539 wm::ActivateWindow(window0.get()); | 527 wm::ActivateWindow(window0.get()); |
| 540 wm::ActivateWindow(panel1.get()); | 528 wm::ActivateWindow(panel1.get()); |
| 541 wm::ActivateWindow(panel0.get()); | 529 wm::ActivateWindow(panel0.get()); |
| 542 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); | 530 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); |
| 543 | 531 |
| 544 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 532 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 545 controller->StopCycling(); | 533 controller->StopCycling(); |
| 546 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); | 534 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); |
| 547 | 535 |
| 548 // Cycling again should select the most recently used panel. | 536 // Cycling again should select the most recently used panel. |
| 549 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 537 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 550 controller->StopCycling(); | 538 controller->StopCycling(); |
| 551 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); | 539 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); |
| 552 | 540 |
| 553 // Cycling twice again should select the first window. | 541 // Cycling twice again should select the first window. |
| 554 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 542 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 555 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 543 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 556 controller->StopCycling(); | 544 controller->StopCycling(); |
| 557 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 545 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 558 } | 546 } |
| 559 | 547 |
| 560 // Tests cycles between panel and normal windows. | 548 // Tests cycles between panel and normal windows. |
| 561 TEST_F(WindowCycleControllerTest, CyclePanelsDestroyed) { | 549 TEST_F(WindowCycleControllerTest, CyclePanelsDestroyed) { |
| 562 WindowCycleController* controller = | 550 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 563 Shell::GetInstance()->window_cycle_controller(); | |
| 564 | 551 |
| 565 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 552 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 566 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 553 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 567 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 554 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| 568 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); | 555 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); |
| 569 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); | 556 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); |
| 570 wm::ActivateWindow(window2.get()); | 557 wm::ActivateWindow(window2.get()); |
| 571 wm::ActivateWindow(panel1.get()); | 558 wm::ActivateWindow(panel1.get()); |
| 572 wm::ActivateWindow(panel0.get()); | 559 wm::ActivateWindow(panel0.get()); |
| 573 wm::ActivateWindow(window1.get()); | 560 wm::ActivateWindow(window1.get()); |
| 574 wm::ActivateWindow(window0.get()); | 561 wm::ActivateWindow(window0.get()); |
| 575 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 562 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 576 | 563 |
| 577 // Cycling once highlights window2. | 564 // Cycling once highlights window2. |
| 578 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 565 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 579 // All panels are destroyed. | 566 // All panels are destroyed. |
| 580 panel0.reset(); | 567 panel0.reset(); |
| 581 panel1.reset(); | 568 panel1.reset(); |
| 582 // Cycling again should now select window2. | 569 // Cycling again should now select window2. |
| 583 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 570 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 584 controller->StopCycling(); | 571 controller->StopCycling(); |
| 585 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 572 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 586 } | 573 } |
| 587 | 574 |
| 588 // Tests cycles between panel and normal windows. | 575 // Tests cycles between panel and normal windows. |
| 589 TEST_F(WindowCycleControllerTest, CycleMruPanelDestroyed) { | 576 TEST_F(WindowCycleControllerTest, CycleMruPanelDestroyed) { |
| 590 WindowCycleController* controller = | 577 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 591 Shell::GetInstance()->window_cycle_controller(); | |
| 592 | 578 |
| 593 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 579 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 594 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 580 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 595 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); | 581 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); |
| 596 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); | 582 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); |
| 597 wm::ActivateWindow(panel1.get()); | 583 wm::ActivateWindow(panel1.get()); |
| 598 wm::ActivateWindow(panel0.get()); | 584 wm::ActivateWindow(panel0.get()); |
| 599 wm::ActivateWindow(window1.get()); | 585 wm::ActivateWindow(window1.get()); |
| 600 wm::ActivateWindow(window0.get()); | 586 wm::ActivateWindow(window0.get()); |
| 601 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 587 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 626 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 612 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 627 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 613 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 628 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 614 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 629 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 615 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 630 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); | 616 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); |
| 631 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); | 617 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); |
| 632 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 618 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 633 } | 619 } |
| 634 | 620 |
| 635 } // namespace ash | 621 } // namespace ash |
| OLD | NEW |