summaryrefslogtreecommitdiffstats
path: root/ash/wm/window_cycle_controller_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ash/wm/window_cycle_controller_unittest.cc')
-rw-r--r--ash/wm/window_cycle_controller_unittest.cc102
1 files changed, 83 insertions, 19 deletions
diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc
index 3aaac40..006d766 100644
--- a/ash/wm/window_cycle_controller_unittest.cc
+++ b/ash/wm/window_cycle_controller_unittest.cc
@@ -10,6 +10,7 @@
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/test_shell_delegate.h"
+#include "ash/wm/window_cycle_list.h"
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/test/test_windows.h"
@@ -24,23 +25,13 @@ using aura::test::CreateTestWindowWithId;
using aura::test::TestWindowDelegate;
using aura::Window;
-class WindowCycleControllerTest : public test::AshTestBase {
- public:
- WindowCycleControllerTest() {}
- virtual ~WindowCycleControllerTest() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WindowCycleControllerTest);
-};
+typedef test::AshTestBase WindowCycleControllerTest;
TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) {
WindowCycleController* controller =
Shell::GetInstance()->window_cycle_controller();
// Cycling doesn't crash if there are no windows.
- std::vector<Window*> windows = Shell::GetInstance()->delegate()->
- GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD);
- EXPECT_TRUE(windows.empty());
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
// Create a single test window.
@@ -56,6 +47,30 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) {
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
}
+// Verifies if there is only one window and it isn't active that cycling
+// activates it.
+TEST_F(WindowCycleControllerTest, SingleWindowNotActive) {
+ WindowCycleController* controller =
+ Shell::GetInstance()->window_cycle_controller();
+
+ // Create a single test window.
+ Window* default_container =
+ ash::Shell::GetInstance()->GetContainer(
+ internal::kShellWindowId_DefaultContainer);
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ wm::ActivateWindow(window0.get());
+ EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+
+ // Rotate focus, this should move focus to another window that isn't part of
+ // the default container.
+ Shell::GetInstance()->RotateFocus(Shell::FORWARD);
+ EXPECT_FALSE(wm::IsActiveWindow(window0.get()));
+
+ // Cycling should activate the window.
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+}
+
TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
WindowCycleController* controller =
Shell::GetInstance()->window_cycle_controller();
@@ -70,17 +85,17 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
wm::ActivateWindow(window0.get());
- // Window lists should return the topmost window in front.
- std::vector<Window*> windows = Shell::GetInstance()->delegate()->
- GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD);
- ASSERT_EQ(3u, windows.size());
- ASSERT_EQ(window0.get(), windows[0]);
- ASSERT_EQ(window1.get(), windows[1]);
- ASSERT_EQ(window2.get(), windows[2]);
-
// Simulate pressing and releasing Alt-tab.
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
+
+ // Window lists should return the topmost window in front.
+ ASSERT_TRUE(controller->windows());
+ ASSERT_EQ(3u, controller->windows()->windows().size());
+ ASSERT_EQ(window0.get(), controller->windows()->windows()[0]);
+ ASSERT_EQ(window1.get(), controller->windows()->windows()[1]);
+ ASSERT_EQ(window2.get(), controller->windows()->windows()[2]);
+
controller->AltKeyReleased();
EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
@@ -167,6 +182,55 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
}
+// Cycles between a maximized and normal window.
+TEST_F(WindowCycleControllerTest, MaximizedWindow) {
+ // Create a couple of test windows.
+ Window* default_container =
+ ash::Shell::GetInstance()->GetContainer(
+ internal::kShellWindowId_DefaultContainer);
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
+
+ wm::MaximizeWindow(window1.get());
+ wm::ActivateWindow(window1.get());
+ EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
+
+ // Rotate focus, this should move focus to window0.
+ WindowCycleController* controller =
+ Shell::GetInstance()->window_cycle_controller();
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+
+ // One more time.
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
+}
+
+// Cycles to a minimized window.
+TEST_F(WindowCycleControllerTest, Minimized) {
+ // Create a couple of test windows.
+ Window* default_container =
+ ash::Shell::GetInstance()->GetContainer(
+ internal::kShellWindowId_DefaultContainer);
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
+
+ wm::MinimizeWindow(window1.get());
+ wm::ActivateWindow(window0.get());
+ EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+
+ // Rotate focus, this should move focus to window1 and unminimize it.
+ WindowCycleController* controller =
+ Shell::GetInstance()->window_cycle_controller();
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
+ EXPECT_FALSE(wm::IsWindowMinimized(window1.get()));
+ EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
+
+ // One more time back to w0.
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+}
+
} // namespace
} // namespace ash