| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/focus_cycler.h" | 5 #include "ash/focus_cycler.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "base/bind.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" |
| 8 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 12 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
| 10 #include "chrome/test/base/ui_controls.h" | 13 #include "chrome/test/base/ui_controls.h" |
| 11 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 14 #include "ui/base/accessibility/accessibility_types.h" | 17 #include "ui/base/accessibility/accessibility_types.h" |
| 15 #include "ui/base/accessibility/accessible_view_state.h" | 18 #include "ui/base/accessibility/accessible_view_state.h" |
| 16 #include "ui/views/focus/focus_manager.h" | 19 #include "ui/views/focus/focus_manager.h" |
| 17 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 37 ASSERT_TRUE(view != NULL); | 40 ASSERT_TRUE(view != NULL); |
| 38 ui::AccessibleViewState state; | 41 ui::AccessibleViewState state; |
| 39 view->GetAccessibleState(&state); | 42 view->GetAccessibleState(&state); |
| 40 ASSERT_NE(state.role, ui::AccessibilityTypes::ROLE_CLIENT); | 43 ASSERT_NE(state.role, ui::AccessibilityTypes::ROLE_CLIENT); |
| 41 ASSERT_FALSE(state.name.empty()); | 44 ASSERT_FALSE(state.name.empty()); |
| 42 } | 45 } |
| 43 | 46 |
| 44 void PressEscape() { | 47 void PressEscape() { |
| 45 aura::Window* window = ash::wm::GetActiveWindow(); | 48 aura::Window* window = ash::wm::GetActiveWindow(); |
| 46 CHECK(window); | 49 CHECK(window); |
| 47 ui_controls::SendKeyPress(window, ui::VKEY_ESCAPE, | 50 wait_for_key_press_.reset(new base::RunLoop()); |
| 48 false, false, false, false); | 51 ui_controls::SendKeyPressNotifyWhenDone( |
| 49 content::RunAllPendingInMessageLoop(); | 52 window, ui::VKEY_ESCAPE, |
| 53 false, false, false, false, |
| 54 base::Bind(&AshFocusCycleTest::QuitWaiting, base::Unretained(this))); |
| 55 wait_for_key_press_->Run(); |
| 56 } |
| 57 |
| 58 private: |
| 59 scoped_ptr<base::RunLoop> wait_for_key_press_; |
| 60 |
| 61 void QuitWaiting() { |
| 62 wait_for_key_press_->Quit(); |
| 50 } | 63 } |
| 51 }; | 64 }; |
| 52 | 65 |
| 53 IN_PROC_BROWSER_TEST_F(AshFocusCycleTest, CycleFocus) { | 66 IN_PROC_BROWSER_TEST_F(AshFocusCycleTest, CycleFocus) { |
| 54 // Initially, the browser frame should have focus. | 67 // Initially, the browser frame should have focus. |
| 55 ASSERT_STREQ("BrowserFrameAura", ash::wm::GetActiveWindow()->name().c_str()); | 68 ASSERT_STREQ("BrowserFrameAura", ash::wm::GetActiveWindow()->name().c_str()); |
| 56 CheckFocusedViewIsAccessible(); | 69 CheckFocusedViewIsAccessible(); |
| 57 | 70 |
| 58 // Rotate focus, as if the user pressed Ctrl+Forward (Ctrl+F2). | 71 // Rotate focus, as if the user pressed Ctrl+Forward (Ctrl+F2). |
| 59 // The first item focused should be in the system tray. | 72 // The first item focused should be in the system tray. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 88 shell->RotateFocus(ash::Shell::FORWARD); | 101 shell->RotateFocus(ash::Shell::FORWARD); |
| 89 shell->RotateFocus(ash::Shell::FORWARD); | 102 shell->RotateFocus(ash::Shell::FORWARD); |
| 90 ASSERT_STREQ("LauncherView", ash::wm::GetActiveWindow()->name().c_str()); | 103 ASSERT_STREQ("LauncherView", ash::wm::GetActiveWindow()->name().c_str()); |
| 91 | 104 |
| 92 PressEscape(); | 105 PressEscape(); |
| 93 ASSERT_STREQ("BrowserFrameAura", ash::wm::GetActiveWindow()->name().c_str()); | 106 ASSERT_STREQ("BrowserFrameAura", ash::wm::GetActiveWindow()->name().c_str()); |
| 94 CheckFocusedViewIsAccessible(); | 107 CheckFocusedViewIsAccessible(); |
| 95 } | 108 } |
| 96 | 109 |
| 97 } // namespace chromeos | 110 } // namespace chromeos |
| OLD | NEW |