diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 07:05:41 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 07:05:41 +0000 |
commit | ce711ac2f9c0f72b8347a381eea8106f9b57811c (patch) | |
tree | b416b659efe875090302b8e55f2fe7f1cac2cc50 /ash/focus_cycler_unittest.cc | |
parent | f292c05203ef92c03912031b9193ac5dbbeea241 (diff) | |
download | chromium_src-ce711ac2f9c0f72b8347a381eea8106f9b57811c.zip chromium_src-ce711ac2f9c0f72b8347a381eea8106f9b57811c.tar.gz chromium_src-ce711ac2f9c0f72b8347a381eea8106f9b57811c.tar.bz2 |
Handle Ctrl+F1 and Ctrl+F2 correctly even when no browser window is available.
- Remove accelerators from ash/focus_cycler.cc and chrome/browser/ui/views/accelerator_table.cc. Instead, handle it in ash/accelerator/accelerator_controller.cc.
- Do not try to focus a browser window in ash/focus_cycler.cc when it's not available. Unit tests added.
BUG=129307
TEST=ran aura_shell_unittests + manually checked
Review URL: https://chromiumcodereview.appspot.com/10545132
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/focus_cycler_unittest.cc')
-rw-r--r-- | ash/focus_cycler_unittest.cc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc index c21a1f9..d0377a2 100644 --- a/ash/focus_cycler_unittest.cc +++ b/ash/focus_cycler_unittest.cc @@ -136,6 +136,95 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) { EXPECT_TRUE(wm::IsActiveWindow(window0.get())); } +TEST_F(FocusCyclerTest, CycleFocusForwardBackward) { + scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); + + // Add the Status area + scoped_ptr<SystemTray> tray(CreateSystemTray()); + ASSERT_TRUE(tray->GetWidget()); + focus_cycler->AddWidget(tray->GetWidget()); + GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( + focus_cycler.get()); + + // Add the launcher + Launcher* launcher = Shell::GetInstance()->launcher(); + ASSERT_TRUE(launcher); + views::Widget* launcher_widget = launcher->widget(); + ASSERT_TRUE(launcher_widget); + launcher->SetFocusCycler(focus_cycler.get()); + + // Create a single test window. + Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); + scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); + wm::ActivateWindow(window0.get()); + EXPECT_TRUE(wm::IsActiveWindow(window0.get())); + + // Cycle focus to the launcher + focus_cycler->RotateFocus(FocusCycler::BACKWARD); + EXPECT_TRUE(launcher_widget->IsActive()); + + // Cycle focus to the status area + focus_cycler->RotateFocus(FocusCycler::BACKWARD); + EXPECT_TRUE(tray->GetWidget()->IsActive()); + + // Cycle focus to the browser + focus_cycler->RotateFocus(FocusCycler::BACKWARD); + EXPECT_TRUE(wm::IsActiveWindow(window0.get())); + + // Cycle focus to the status area + focus_cycler->RotateFocus(FocusCycler::FORWARD); + EXPECT_TRUE(tray->GetWidget()->IsActive()); + + // Cycle focus to the launcher + focus_cycler->RotateFocus(FocusCycler::FORWARD); + EXPECT_TRUE(launcher_widget->IsActive()); + + // Cycle focus to the browser + focus_cycler->RotateFocus(FocusCycler::FORWARD); + EXPECT_TRUE(wm::IsActiveWindow(window0.get())); +} + +TEST_F(FocusCyclerTest, CycleFocusNoBrowser) { + scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); + + // Add the Status area + scoped_ptr<SystemTray> tray(CreateSystemTray()); + ASSERT_TRUE(tray->GetWidget()); + focus_cycler->AddWidget(tray->GetWidget()); + GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( + focus_cycler.get()); + + // Add the launcher and focus it + Launcher* launcher = Shell::GetInstance()->launcher(); + ASSERT_TRUE(launcher); + views::Widget* launcher_widget = launcher->widget(); + ASSERT_TRUE(launcher_widget); + launcher->SetFocusCycler(focus_cycler.get()); + focus_cycler->FocusWidget(launcher_widget); + + // Cycle focus to the status area + focus_cycler->RotateFocus(FocusCycler::FORWARD); + EXPECT_TRUE(tray->GetWidget()->IsActive()); + + // Cycle focus to the launcher + focus_cycler->RotateFocus(FocusCycler::FORWARD); + EXPECT_TRUE(launcher_widget->IsActive()); + + // Cycle focus to the status area + focus_cycler->RotateFocus(FocusCycler::FORWARD); + EXPECT_TRUE(tray->GetWidget()->IsActive()); + + // Cycle focus to the launcher + focus_cycler->RotateFocus(FocusCycler::BACKWARD); + EXPECT_TRUE(launcher_widget->IsActive()); + + // Cycle focus to the status area + focus_cycler->RotateFocus(FocusCycler::BACKWARD); + EXPECT_TRUE(tray->GetWidget()->IsActive()); +} + class FocusCyclerLauncherTest : public AshTestBase { public: FocusCyclerLauncherTest() : AshTestBase() {} |