| 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" | |
| 11 #include "ash/common/focus_cycler.h" | 10 #include "ash/common/focus_cycler.h" |
| 12 #include "ash/common/scoped_root_window_for_new_windows.h" | 11 #include "ash/common/scoped_root_window_for_new_windows.h" |
| 13 #include "ash/common/session/session_state_delegate.h" | 12 #include "ash/common/session/session_state_delegate.h" |
| 14 #include "ash/common/shelf/shelf_widget.h" | 13 #include "ash/common/shelf/shelf_widget.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" | 14 #include "ash/common/shelf/wm_shelf.h" |
| 16 #include "ash/common/test/test_shelf_delegate.h" | 15 #include "ash/common/test/test_shelf_delegate.h" |
| 17 #include "ash/common/wm/window_cycle_list.h" | 16 #include "ash/common/wm/window_cycle_list.h" |
| 18 #include "ash/common/wm/window_state.h" | 17 #include "ash/common/wm/window_state.h" |
| 19 #include "ash/common/wm/wm_event.h" | 18 #include "ash/common/wm/wm_event.h" |
| 20 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 20 #include "ash/common/wm_window.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_view_presenter_impl.h" | 25 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 26 #include "ash/test/test_shell_delegate.h" | 26 #include "ash/test/test_shell_delegate.h" |
| 27 #include "ash/wm/window_state_aura.h" | 27 #include "ash/wm/window_state_aura.h" |
| 28 #include "ash/wm/window_util.h" | 28 #include "ash/wm/window_util.h" |
| 29 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 30 #include "ui/aura/client/screen_position_client.h" | 30 #include "ui/aura/client/screen_position_client.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void OnMouseEvent(ui::MouseEvent* event) override { mouse_events_++; } | 66 void OnMouseEvent(ui::MouseEvent* event) override { mouse_events_++; } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 int key_events_; | 69 int key_events_; |
| 70 int mouse_events_; | 70 int mouse_events_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(EventCounter); | 72 DISALLOW_COPY_AND_ASSIGN(EventCounter); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 bool IsWindowMinimized(aura::Window* window) { | 75 bool IsWindowMinimized(aura::Window* window) { |
| 76 return WmWindowAura::Get(window)->GetWindowState()->IsMinimized(); | 76 return WmWindow::Get(window)->GetWindowState()->IsMinimized(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace | 79 } // namespace |
| 80 | 80 |
| 81 using aura::test::CreateTestWindowWithId; | 81 using aura::test::CreateTestWindowWithId; |
| 82 using aura::test::TestWindowDelegate; | 82 using aura::test::TestWindowDelegate; |
| 83 using aura::Window; | 83 using aura::Window; |
| 84 | 84 |
| 85 class WindowCycleControllerTest : public test::AshTestBase { | 85 class WindowCycleControllerTest : public test::AshTestBase { |
| 86 public: | 86 public: |
| 87 WindowCycleControllerTest() {} | 87 WindowCycleControllerTest() {} |
| 88 ~WindowCycleControllerTest() override {} | 88 ~WindowCycleControllerTest() override {} |
| 89 | 89 |
| 90 void SetUp() override { | 90 void SetUp() override { |
| 91 test::AshTestBase::SetUp(); | 91 test::AshTestBase::SetUp(); |
| 92 | 92 |
| 93 WindowCycleList::DisableInitialDelayForTesting(); | 93 WindowCycleList::DisableInitialDelayForTesting(); |
| 94 | 94 |
| 95 shelf_view_test_.reset(new test::ShelfViewTestAPI( | 95 shelf_view_test_.reset(new test::ShelfViewTestAPI( |
| 96 GetPrimaryShelf()->GetShelfViewForTesting())); | 96 GetPrimaryShelf()->GetShelfViewForTesting())); |
| 97 shelf_view_test_->SetAnimationDuration(1); | 97 shelf_view_test_->SetAnimationDuration(1); |
| 98 } | 98 } |
| 99 | 99 |
| 100 aura::Window* CreatePanelWindow() { | 100 aura::Window* CreatePanelWindow() { |
| 101 gfx::Rect rect(100, 100); | 101 gfx::Rect rect(100, 100); |
| 102 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 102 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
| 103 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, rect); | 103 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, rect); |
| 104 test::TestShelfDelegate::instance()->AddShelfItem( | 104 test::TestShelfDelegate::instance()->AddShelfItem(WmWindow::Get(window)); |
| 105 WmWindowAura::Get(window)); | |
| 106 shelf_view_test_->RunMessageLoopUntilAnimationsDone(); | 105 shelf_view_test_->RunMessageLoopUntilAnimationsDone(); |
| 107 return window; | 106 return window; |
| 108 } | 107 } |
| 109 | 108 |
| 110 const aura::Window::Windows GetWindows(WindowCycleController* controller) { | 109 const aura::Window::Windows GetWindows(WindowCycleController* controller) { |
| 111 return WmWindowAura::ToAuraWindows( | 110 return WmWindow::ToAuraWindows(controller->window_cycle_list()->windows()); |
| 112 controller->window_cycle_list()->windows()); | |
| 113 } | 111 } |
| 114 | 112 |
| 115 const views::Widget* GetWindowCycleListWidget() const { | 113 const views::Widget* GetWindowCycleListWidget() const { |
| 116 return WmShell::Get() | 114 return WmShell::Get() |
| 117 ->window_cycle_controller() | 115 ->window_cycle_controller() |
| 118 ->window_cycle_list() | 116 ->window_cycle_list() |
| 119 ->widget(); | 117 ->widget(); |
| 120 } | 118 } |
| 121 | 119 |
| 122 private: | 120 private: |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // Create two windows in the primary root. | 407 // Create two windows in the primary root. |
| 410 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 408 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 411 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); | 409 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); |
| 412 Window* top_container0 = | 410 Window* top_container0 = |
| 413 Shell::GetContainer(root_windows[0], kShellWindowId_AlwaysOnTopContainer); | 411 Shell::GetContainer(root_windows[0], kShellWindowId_AlwaysOnTopContainer); |
| 414 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); | 412 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); |
| 415 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 413 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| 416 | 414 |
| 417 // Move the active root window to the secondary root and create two windows. | 415 // Move the active root window to the secondary root and create two windows. |
| 418 ScopedRootWindowForNewWindows root_for_new_windows( | 416 ScopedRootWindowForNewWindows root_for_new_windows( |
| 419 WmWindowAura::Get(root_windows[1])); | 417 WmWindow::Get(root_windows[1])); |
| 420 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); | 418 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); |
| 421 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | 419 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
| 422 | 420 |
| 423 Window* top_container1 = | 421 Window* top_container1 = |
| 424 Shell::GetContainer(root_windows[1], kShellWindowId_AlwaysOnTopContainer); | 422 Shell::GetContainer(root_windows[1], kShellWindowId_AlwaysOnTopContainer); |
| 425 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); | 423 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); |
| 426 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); | 424 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); |
| 427 | 425 |
| 428 wm::ActivateWindow(window2.get()); | 426 wm::ActivateWindow(window2.get()); |
| 429 | 427 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 // Base case sets the expectation for other cases. | 764 // Base case sets the expectation for other cases. |
| 767 if (expected_bounds.IsEmpty()) | 765 if (expected_bounds.IsEmpty()) |
| 768 expected_bounds = display_relative_bounds; | 766 expected_bounds = display_relative_bounds; |
| 769 else | 767 else |
| 770 EXPECT_EQ(expected_bounds, display_relative_bounds); | 768 EXPECT_EQ(expected_bounds, display_relative_bounds); |
| 771 controller->CompleteCycling(); | 769 controller->CompleteCycling(); |
| 772 } | 770 } |
| 773 } | 771 } |
| 774 | 772 |
| 775 } // namespace ash | 773 } // namespace ash |
| OLD | NEW |