| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 private: | 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(WindowCycleControllerTest); | 33 DISALLOW_COPY_AND_ASSIGN(WindowCycleControllerTest); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { | 36 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { |
| 37 WindowCycleController* controller = | 37 WindowCycleController* controller = |
| 38 Shell::GetInstance()->window_cycle_controller(); | 38 Shell::GetInstance()->window_cycle_controller(); |
| 39 | 39 |
| 40 // Cycling doesn't crash if there are no windows. | 40 // Cycling doesn't crash if there are no windows. |
| 41 std::vector<Window*> windows = Shell::GetInstance()->delegate()-> | 41 std::vector<Window*> windows = Shell::GetInstance()->delegate()-> |
| 42 GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD, | 42 GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD); |
| 43 ShellDelegate::ORDER_MRU); | |
| 44 EXPECT_TRUE(windows.empty()); | 43 EXPECT_TRUE(windows.empty()); |
| 45 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 44 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
| 46 | 45 |
| 47 // Create a single test window. | 46 // Create a single test window. |
| 48 Window* default_container = | 47 Window* default_container = |
| 49 ash::Shell::GetInstance()->GetContainer( | 48 ash::Shell::GetInstance()->GetContainer( |
| 50 internal::kShellWindowId_DefaultContainer); | 49 internal::kShellWindowId_DefaultContainer); |
| 51 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | 50 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); |
| 52 wm::ActivateWindow(window0.get()); | 51 wm::ActivateWindow(window0.get()); |
| 53 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 52 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 66 Window* default_container = | 65 Window* default_container = |
| 67 Shell::GetInstance()->GetContainer( | 66 Shell::GetInstance()->GetContainer( |
| 68 internal::kShellWindowId_DefaultContainer); | 67 internal::kShellWindowId_DefaultContainer); |
| 69 scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container)); | 68 scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container)); |
| 70 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); | 69 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); |
| 71 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | 70 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); |
| 72 wm::ActivateWindow(window0.get()); | 71 wm::ActivateWindow(window0.get()); |
| 73 | 72 |
| 74 // Window lists should return the topmost window in front. | 73 // Window lists should return the topmost window in front. |
| 75 std::vector<Window*> windows = Shell::GetInstance()->delegate()-> | 74 std::vector<Window*> windows = Shell::GetInstance()->delegate()-> |
| 76 GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD, | 75 GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD); |
| 77 ShellDelegate::ORDER_MRU); | |
| 78 ASSERT_EQ(3u, windows.size()); | 76 ASSERT_EQ(3u, windows.size()); |
| 79 ASSERT_EQ(window0.get(), windows[0]); | 77 ASSERT_EQ(window0.get(), windows[0]); |
| 80 ASSERT_EQ(window1.get(), windows[1]); | 78 ASSERT_EQ(window1.get(), windows[1]); |
| 81 ASSERT_EQ(window2.get(), windows[2]); | 79 ASSERT_EQ(window2.get(), windows[2]); |
| 82 | 80 |
| 83 // Simulate pressing and releasing Alt-tab. | 81 // Simulate pressing and releasing Alt-tab. |
| 84 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 82 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 85 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 83 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
| 86 controller->AltKeyReleased(); | 84 controller->AltKeyReleased(); |
| 87 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 85 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); | 169 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); |
| 172 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 170 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
| 173 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 171 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
| 174 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 172 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 175 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 173 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 176 } | 174 } |
| 177 | 175 |
| 178 } // namespace | 176 } // namespace |
| 179 | 177 |
| 180 } // namespace ash | 178 } // namespace ash |
| OLD | NEW |