| 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/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_state.h" | 14 #include "ash/common/wm/window_state.h" |
| 15 #include "ash/common/wm/wm_event.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_cycle_list.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 EXPECT_EQ(1u, key_count.GetCountAndReset()); | 626 EXPECT_EQ(1u, key_count.GetCountAndReset()); |
| 626 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 627 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 627 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 628 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 628 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 629 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 629 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 630 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 630 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); | 631 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); |
| 631 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); | 632 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); |
| 632 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 633 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 633 } | 634 } |
| 634 | 635 |
| 636 // Tests that we can cycle past fullscreen windows: https://crbug.com/622396. |
| 637 // Fullscreen windows are special in that they are allowed to handle alt+tab |
| 638 // keypresses, which means the window cycle event filter should not handle |
| 639 // the tab press else it prevents cycling past that window. |
| 640 TEST_F(WindowCycleControllerTest, TabPastFullscreenWindow) { |
| 641 std::unique_ptr<Window> w0(CreateTestWindowInShellWithId(0)); |
| 642 std::unique_ptr<Window> w1(CreateTestWindowInShellWithId(1)); |
| 643 wm::WMEvent maximize_event(wm::WM_EVENT_FULLSCREEN); |
| 644 |
| 645 // To make this test work with or without the new alt+tab selector we make |
| 646 // both the initial window and the second window fullscreen. |
| 647 wm::GetWindowState(w0.get())->OnWMEvent(&maximize_event); |
| 648 wm::GetWindowState(w1.get())->Activate(); |
| 649 wm::GetWindowState(w1.get())->OnWMEvent(&maximize_event); |
| 650 EXPECT_TRUE(wm::GetWindowState(w0.get())->IsFullscreen()); |
| 651 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsFullscreen()); |
| 652 wm::GetWindowState(w0.get())->Activate(); |
| 653 EXPECT_TRUE(wm::GetWindowState(w0.get())->IsActive()); |
| 654 |
| 655 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 656 generator.PressKey(ui::VKEY_MENU, ui::EF_NONE); |
| 657 |
| 658 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 659 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 660 |
| 661 // Because w0 and w1 are full-screen, the event should be passed to the |
| 662 // browser window to handle it (which if the browser doesn't handle it will |
| 663 // pass on the alt+tab to continue cycling). To make this test work with or |
| 664 // without the new alt+tab selector we check for the event on either |
| 665 // fullscreen window. |
| 666 KeyEventCounter key_count; |
| 667 w0->AddPreTargetHandler(&key_count); |
| 668 w1->AddPreTargetHandler(&key_count); |
| 669 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 670 EXPECT_EQ(1u, key_count.GetCountAndReset()); |
| 671 } |
| 672 |
| 635 } // namespace ash | 673 } // namespace ash |
| OLD | NEW |