Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Unified Diff: ui/aura_shell/shell_accelerator_controller_unittest.cc

Issue 8817018: Implement cycle window forward/backward by keyboard shortcuts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add check for lock screen view visibility Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d0d4d73a6db99289137094274012763b614de8c0..dac177adc760fe8cefe5a4c940379e3240a643bd 100644
--- a/ui/aura_shell/shell_accelerator_controller_unittest.cc
+++ b/ui/aura_shell/shell_accelerator_controller_unittest.cc
@@ -2,8 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#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"
#include "ui/aura_shell/test/aura_shell_test_base.h"
namespace aura_shell {
@@ -165,5 +169,115 @@ 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);
+ window0->Activate();
+ EXPECT_TRUE(window0->IsActive());
+
+ ui::Accelerator cycle_forward(ui::VKEY_TAB, false, false, true);
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_TRUE(window1->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_TRUE(window2->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_TRUE(window0->IsActive());
+
+ ui::Accelerator cycle_backward(ui::VKEY_TAB, true, false, true);
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+ EXPECT_TRUE(window2->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+ EXPECT_TRUE(window1->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+ EXPECT_TRUE(window0->IsActive());
+
+ 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.
+ modal_window->Activate();
+ EXPECT_TRUE(modal_window->IsActive());
+ EXPECT_FALSE(GetController()->Process(cycle_forward));
+ EXPECT_TRUE(modal_window->IsActive());
+ EXPECT_FALSE(window0->IsActive());
+ EXPECT_FALSE(window1->IsActive());
+ EXPECT_FALSE(window2->IsActive());
+ EXPECT_FALSE(GetController()->Process(cycle_backward));
+ EXPECT_TRUE(modal_window->IsActive());
+ EXPECT_FALSE(window0->IsActive());
+ EXPECT_FALSE(window1->IsActive());
+ EXPECT_FALSE(window2->IsActive());
+
+ // The modal window is not activated by cycling window.
+ window0->Activate();
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_FALSE(modal_window->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_FALSE(modal_window->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_FALSE(modal_window->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+ EXPECT_FALSE(modal_window->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+ EXPECT_FALSE(modal_window->IsActive());
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+ EXPECT_FALSE(modal_window->IsActive());
+
+ // 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));
+ lock_screen_window->Hide();
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+
+ 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_modal_window->Hide();
+ EXPECT_TRUE(GetController()->Process(cycle_forward));
+ EXPECT_TRUE(GetController()->Process(cycle_backward));
+}
+
} // namespace test
} // namespace aura_shell

Powered by Google App Engine
This is Rietveld 408576698