| 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/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" |
| 11 #include "ash/common/focus_cycler.h" | 11 #include "ash/common/focus_cycler.h" |
| 12 #include "ash/common/scoped_root_window_for_new_windows.h" | 12 #include "ash/common/scoped_root_window_for_new_windows.h" |
| 13 #include "ash/common/session/session_state_delegate.h" | 13 #include "ash/common/session/session_state_delegate.h" |
| 14 #include "ash/common/shelf/shelf_widget.h" | 14 #include "ash/common/shelf/shelf_widget.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" | 15 #include "ash/common/shelf/wm_shelf.h" |
| 16 #include "ash/common/test/test_shelf_delegate.h" | 16 #include "ash/common/test/test_shelf_delegate.h" |
| 17 #include "ash/common/wm/window_cycle_list.h" | 17 #include "ash/common/wm/window_cycle_list.h" |
| 18 #include "ash/common/wm/window_state.h" | 18 #include "ash/common/wm/window_state.h" |
| 19 #include "ash/common/wm/wm_event.h" | 19 #include "ash/common/wm/wm_event.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/public/cpp/shell_window_ids.h" | 21 #include "ash/public/cpp/shell_window_ids.h" |
| 22 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 23 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
| 24 #include "ash/test/shelf_view_test_api.h" | 24 #include "ash/test/shelf_view_test_api.h" |
| 25 #include "ash/test/test_app_list_presenter_impl.h" |
| 25 #include "ash/test/test_shell_delegate.h" | 26 #include "ash/test/test_shell_delegate.h" |
| 26 #include "ash/wm/window_state_aura.h" | 27 #include "ash/wm/window_state_aura.h" |
| 27 #include "ash/wm/window_util.h" | 28 #include "ash/wm/window_util.h" |
| 28 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 29 #include "ui/aura/client/screen_position_client.h" | 30 #include "ui/aura/client/screen_position_client.h" |
| 30 #include "ui/aura/env.h" | 31 #include "ui/aura/env.h" |
| 31 #include "ui/aura/test/test_windows.h" | 32 #include "ui/aura/test/test_windows.h" |
| 32 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
| 33 #include "ui/aura/window_event_dispatcher.h" | 34 #include "ui/aura/window_event_dispatcher.h" |
| 35 #include "ui/display/manager/display_manager.h" |
| 34 #include "ui/events/event_handler.h" | 36 #include "ui/events/event_handler.h" |
| 35 #include "ui/events/test/event_generator.h" | 37 #include "ui/events/test/event_generator.h" |
| 36 #include "ui/gfx/geometry/rect.h" | 38 #include "ui/gfx/geometry/rect.h" |
| 37 | 39 |
| 38 namespace ash { | 40 namespace ash { |
| 39 | 41 |
| 40 namespace { | 42 namespace { |
| 41 | 43 |
| 42 class EventCounter : public ui::EventHandler { | 44 class EventCounter : public ui::EventHandler { |
| 43 public: | 45 public: |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 463 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
| 462 | 464 |
| 463 // Showing the Alt+Tab UI does however deactivate the erstwhile active window. | 465 // Showing the Alt+Tab UI does however deactivate the erstwhile active window. |
| 464 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 466 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 465 | 467 |
| 466 controller->StopCycling(); | 468 controller->StopCycling(); |
| 467 } | 469 } |
| 468 | 470 |
| 469 // Tests that beginning window selection hides the app list. | 471 // Tests that beginning window selection hides the app list. |
| 470 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { | 472 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { |
| 473 // The tested behavior relies on the app list presenter implementation. |
| 474 test::TestAppListPresenterImpl app_list_presenter_impl; |
| 475 |
| 471 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 476 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 472 | 477 |
| 473 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 478 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 474 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 479 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 475 WmShell::Get()->ShowAppList(); | 480 app_list_presenter_impl.Show(display_manager()->first_display_id()); |
| 476 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); | 481 EXPECT_TRUE(app_list_presenter_impl.IsVisible()); |
| 477 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 482 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 478 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); | 483 EXPECT_FALSE(app_list_presenter_impl.IsVisible()); |
| 479 | 484 |
| 480 // Make sure that dismissing the app list this way doesn't pass activation | 485 // Make sure that dismissing the app list this way doesn't pass activation |
| 481 // to a different window. | 486 // to a different window. |
| 482 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 487 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
| 483 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 488 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 484 | 489 |
| 485 controller->StopCycling(); | 490 controller->StopCycling(); |
| 486 } | 491 } |
| 487 | 492 |
| 488 // Tests that cycling through windows doesn't change their minimized state. | 493 // Tests that cycling through windows doesn't change their minimized state. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 // without the new alt+tab selector we check for the event on either | 697 // without the new alt+tab selector we check for the event on either |
| 693 // fullscreen window. | 698 // fullscreen window. |
| 694 EventCounter event_count; | 699 EventCounter event_count; |
| 695 w0->AddPreTargetHandler(&event_count); | 700 w0->AddPreTargetHandler(&event_count); |
| 696 w1->AddPreTargetHandler(&event_count); | 701 w1->AddPreTargetHandler(&event_count); |
| 697 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 702 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 698 EXPECT_EQ(1, event_count.GetKeyEventCountAndReset()); | 703 EXPECT_EQ(1, event_count.GetKeyEventCountAndReset()); |
| 699 } | 704 } |
| 700 | 705 |
| 701 } // namespace ash | 706 } // namespace ash |
| OLD | NEW |