Index: ui/aura_shell/shell_accelerator_controller_unittest.cc |
diff --git a/ui/aura_shell/shell_accelerator_controller_unittest.cc b/ui/aura_shell/shell_accelerator_controller_unittest.cc |
index e962d6809a2dec40ae2babf3fa2ff9f3d2beba83..d82d33fdbbf2688df448c9f0d5efed4319b22024 100644 |
--- a/ui/aura_shell/shell_accelerator_controller_unittest.cc |
+++ b/ui/aura_shell/shell_accelerator_controller_unittest.cc |
@@ -6,6 +6,7 @@ |
#include "ui/aura/root_window.h" |
#include "ui/aura/test/test_window_delegate.h" |
#include "ui/aura/test/test_windows.h" |
+#include "ui/aura/window.h" |
#include "ui/aura_shell/shell.h" |
#include "ui/aura_shell/shell_accelerator_controller.h" |
#include "ui/aura_shell/shell_window_ids.h" |
@@ -207,5 +208,114 @@ TEST_F(ShellAcceleratorControllerTest, GlobalAccelerators) { |
#endif |
} |
+TEST_F(ShellAcceleratorControllerTest, HandleCycleWindow) { |
+ aura::Window* default_container = |
+ aura_shell::Shell::GetInstance()->GetContainer( |
+ internal::kShellWindowId_DefaultContainer); |
+ aura::Window* window0 = aura::test::CreateTestWindowWithDelegate( |
+ new aura::test::TestWindowDelegate, |
+ -1, |
+ gfx::Rect(), |
+ default_container); |
+ aura::Window* window1 = aura::test::CreateTestWindowWithDelegate( |
+ new aura::test::TestWindowDelegate, |
+ -1, |
+ gfx::Rect(), |
+ default_container); |
+ aura::Window* window2 = aura::test::CreateTestWindowWithDelegate( |
+ new aura::test::TestWindowDelegate, |
+ -1, |
+ gfx::Rect(), |
+ default_container); |
+ ActivateWindow(window0); |
+ EXPECT_TRUE(IsActiveWindow(window0)); |
+ |
+ ui::Accelerator cycle_forward(ui::VKEY_TAB, false, false, true); |
+ EXPECT_TRUE(GetController()->Process(cycle_forward)); |
+ EXPECT_TRUE(IsActiveWindow(window1)); |
+ EXPECT_TRUE(GetController()->Process(cycle_forward)); |
+ EXPECT_TRUE(IsActiveWindow(window2)); |
+ EXPECT_TRUE(GetController()->Process(cycle_forward)); |
+ EXPECT_TRUE(IsActiveWindow(window0)); |
+ |
+ ui::Accelerator cycle_backward(ui::VKEY_TAB, true, false, true); |
+ EXPECT_TRUE(GetController()->Process(cycle_backward)); |
+ EXPECT_TRUE(IsActiveWindow(window2)); |
+ EXPECT_TRUE(GetController()->Process(cycle_backward)); |
+ EXPECT_TRUE(IsActiveWindow(window1)); |
+ EXPECT_TRUE(GetController()->Process(cycle_backward)); |
+ EXPECT_TRUE(IsActiveWindow(window0)); |
+ |
+ aura::Window* modal_container = |
+ aura_shell::Shell::GetInstance()->GetContainer( |
+ internal::kShellWindowId_AlwaysOnTopContainer); |
+ aura::Window* modal_window = aura::test::CreateTestWindowWithDelegate( |
+ new aura::test::TestWindowDelegate, |
+ -1, |
+ gfx::Rect(), |
+ modal_container); |
+ |
+ // When the modal window is active, cycling window does not take effect. |
+ ActivateWindow(modal_window); |
+ EXPECT_TRUE(IsActiveWindow(modal_window)); |
+ EXPECT_FALSE(GetController()->Process(cycle_forward)); |
+ EXPECT_TRUE(IsActiveWindow(modal_window)); |
+ EXPECT_FALSE(IsActiveWindow(window0)); |
+ EXPECT_FALSE(IsActiveWindow(window1)); |
+ EXPECT_FALSE(IsActiveWindow(window2)); |
+ EXPECT_FALSE(GetController()->Process(cycle_backward)); |
+ EXPECT_TRUE(IsActiveWindow(modal_window)); |
+ EXPECT_FALSE(IsActiveWindow(window0)); |
+ EXPECT_FALSE(IsActiveWindow(window1)); |
+ EXPECT_FALSE(IsActiveWindow(window2)); |
+ |
+ // The modal window is not activated by cycling window. |
+ ActivateWindow(window0); |
+ EXPECT_TRUE(GetController()->Process(cycle_forward)); |
+ EXPECT_FALSE(IsActiveWindow(modal_window)); |
+ EXPECT_TRUE(GetController()->Process(cycle_forward)); |
+ EXPECT_FALSE(IsActiveWindow(modal_window)); |
+ EXPECT_TRUE(GetController()->Process(cycle_forward)); |
+ EXPECT_FALSE(IsActiveWindow(modal_window)); |
+ EXPECT_TRUE(GetController()->Process(cycle_backward)); |
+ EXPECT_FALSE(IsActiveWindow(modal_window)); |
+ EXPECT_TRUE(GetController()->Process(cycle_backward)); |
+ EXPECT_FALSE(IsActiveWindow(modal_window)); |
+ EXPECT_TRUE(GetController()->Process(cycle_backward)); |
+ EXPECT_FALSE(IsActiveWindow(modal_window)); |
+ |
+ // When a screen lock window is visible, cycling window does not take effect. |
+ aura::Window* lock_screen_container = |
+ aura_shell::Shell::GetInstance()->GetContainer( |
+ internal::kShellWindowId_LockScreenContainer); |
+ aura::Window* lock_screen_window = aura::test::CreateTestWindowWithDelegate( |
+ new aura::test::TestWindowDelegate, |
+ -1, |
+ gfx::Rect(), |
+ lock_screen_container); |
+ |
+ lock_screen_window->Show(); |
+ EXPECT_FALSE(GetController()->Process(cycle_forward)); |
+ EXPECT_FALSE(GetController()->Process(cycle_backward)); |
+ |
+ // When a screen lock window is visible, cycling window does not take effect. |
+ // But otherwise, cycling window does take effect. |
+ aura::Window* lock_modal_container = |
+ aura_shell::Shell::GetInstance()->GetContainer( |
+ internal::kShellWindowId_LockModalContainer); |
+ aura::Window* lock_modal_window = aura::test::CreateTestWindowWithDelegate( |
+ new aura::test::TestWindowDelegate, |
+ -1, |
+ gfx::Rect(), |
+ lock_modal_container); |
+ |
+ lock_modal_window->Show(); |
+ EXPECT_FALSE(GetController()->Process(cycle_forward)); |
+ EXPECT_FALSE(GetController()->Process(cycle_backward)); |
+ lock_screen_window->Hide(); |
+ EXPECT_TRUE(GetController()->Process(cycle_forward)); |
+ EXPECT_TRUE(GetController()->Process(cycle_backward)); |
+} |
+ |
} // namespace test |
} // namespace aura_shell |