| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
| 6 #include "chrome/browser/automation/ui_controls.h" | 6 #include "chrome/browser/automation/ui_controls.h" |
| 7 #include "chrome/browser/views/chrome_views_delegate.h" | 7 #include "chrome/browser/views/chrome_views_delegate.h" |
| 8 #include "chrome/browser/views/frame/browser_view.h" | 8 #include "chrome/browser/views/frame/browser_view.h" |
| 9 #include "chrome/test/in_process_browser_test.h" | 9 #include "chrome/test/in_process_browser_test.h" |
| 10 #include "chrome/test/ui_test_utils.h" | 10 #include "chrome/test/ui_test_utils.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 ~BrowserKeyboardAccessibility() {} | 28 ~BrowserKeyboardAccessibility() {} |
| 29 | 29 |
| 30 // Overidden from ChromeViewsDelegate. | 30 // Overidden from ChromeViewsDelegate. |
| 31 // Save the last notification sent by views::View::NotifyAccessibilityEvent. | 31 // Save the last notification sent by views::View::NotifyAccessibilityEvent. |
| 32 virtual void NotifyAccessibilityEvent( | 32 virtual void NotifyAccessibilityEvent( |
| 33 views::View* view, AccessibilityTypes::Event event_type) { | 33 views::View* view, AccessibilityTypes::Event event_type) { |
| 34 current_view_ = view; | 34 current_view_ = view; |
| 35 current_event_type_ = event_type; | 35 current_event_type_ = event_type; |
| 36 | 36 |
| 37 // Are we within a message loop waiting for a particular event? | 37 // Are we within a message loop waiting for a particular event? |
| 38 // TODO(phajdan.jr): remove logging after fixing http://crbug.com/50663. |
| 39 LOG(ERROR) << "Got notification; is_waiting_ is " |
| 40 << (is_waiting_ ? "true" : "false"); |
| 38 if (is_waiting_) { | 41 if (is_waiting_) { |
| 39 is_waiting_ = false; | 42 is_waiting_ = false; |
| 40 MessageLoop::current()->Quit(); | 43 MessageLoop::current()->Quit(); |
| 41 } | 44 } |
| 42 } | 45 } |
| 43 | 46 |
| 44 // Helper that performs tabbing until it cycles back to the original focus. | 47 // Helper that performs tabbing until it cycles back to the original focus. |
| 45 void TabCyclerForwardAndBack(gfx::NativeWindow hwnd); | 48 void TabCyclerForwardAndBack(gfx::NativeWindow hwnd); |
| 46 void TabCycler(gfx::NativeWindow hwnd, bool forward_tab); | 49 void TabCycler(gfx::NativeWindow hwnd, bool forward_tab); |
| 47 | 50 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 IN_PROC_BROWSER_TEST_F(BrowserKeyboardAccessibility, TabInKeywordEditor) { | 94 IN_PROC_BROWSER_TEST_F(BrowserKeyboardAccessibility, TabInKeywordEditor) { |
| 92 browser()->OpenKeywordEditor(); | 95 browser()->OpenKeywordEditor(); |
| 93 TabCyclerForwardAndBack(current_view_native_window()); | 96 TabCyclerForwardAndBack(current_view_native_window()); |
| 94 } | 97 } |
| 95 | 98 |
| 96 IN_PROC_BROWSER_TEST_F(BrowserKeyboardAccessibility, TabInOptionsDialog) { | 99 IN_PROC_BROWSER_TEST_F(BrowserKeyboardAccessibility, TabInOptionsDialog) { |
| 97 browser()->OpenOptionsDialog(); | 100 browser()->OpenOptionsDialog(); |
| 98 | 101 |
| 99 // Tab through each of the three tabs. | 102 // Tab through each of the three tabs. |
| 100 for (int i = 0; i < 3; ++i) { | 103 for (int i = 0; i < 3; ++i) { |
| 104 // TODO(phajdan.jr): remove logging after fixing http://crbug.com/50663. |
| 105 LOG(ERROR) << "Iteration no. " << i; |
| 106 |
| 101 TabCyclerForwardAndBack(current_view_native_window()); | 107 TabCyclerForwardAndBack(current_view_native_window()); |
| 108 |
| 109 |
| 110 // TODO(phajdan.jr): remove logging after fixing http://crbug.com/50663. |
| 111 LOG(ERROR) << "Sending TAB key event..."; |
| 102 ui_controls::SendKeyPressNotifyWhenDone(current_view_native_window(), | 112 ui_controls::SendKeyPressNotifyWhenDone(current_view_native_window(), |
| 103 base::VKEY_TAB, | 113 base::VKEY_TAB, |
| 104 true, false, false, false, | 114 true, false, false, false, |
| 105 new MessageLoop::QuitTask()); | 115 new MessageLoop::QuitTask()); |
| 106 set_waiting(true); | 116 set_waiting(true); |
| 107 ui_test_utils::RunMessageLoop(); | 117 ui_test_utils::RunMessageLoop(); |
| 108 } | 118 } |
| 109 } | 119 } |
| 110 | 120 |
| 111 IN_PROC_BROWSER_TEST_F(BrowserKeyboardAccessibility, TabInPasswordManager) { | 121 IN_PROC_BROWSER_TEST_F(BrowserKeyboardAccessibility, TabInPasswordManager) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 gfx::NativeWindow hwnd) { | 155 gfx::NativeWindow hwnd) { |
| 146 TabCycler(hwnd, true); | 156 TabCycler(hwnd, true); |
| 147 TabCycler(hwnd, false); | 157 TabCycler(hwnd, false); |
| 148 } | 158 } |
| 149 | 159 |
| 150 void BrowserKeyboardAccessibility::TabCycler(gfx::NativeWindow hwnd, | 160 void BrowserKeyboardAccessibility::TabCycler(gfx::NativeWindow hwnd, |
| 151 bool forward_tab) { | 161 bool forward_tab) { |
| 152 // Wait for a focus event on the provided native window. | 162 // Wait for a focus event on the provided native window. |
| 153 while (current_event() != AccessibilityTypes::EVENT_FOCUS || | 163 while (current_event() != AccessibilityTypes::EVENT_FOCUS || |
| 154 current_view_native_window() != hwnd) { | 164 current_view_native_window() != hwnd) { |
| 165 // TODO(phajdan.jr): remove logging after fixing http://crbug.com/50663. |
| 166 LOG(ERROR) << "Runnig message loop..."; |
| 155 set_waiting(true); | 167 set_waiting(true); |
| 156 ui_test_utils::RunMessageLoop(); | 168 ui_test_utils::RunMessageLoop(); |
| 157 } | 169 } |
| 170 // TODO(phajdan.jr): remove logging after fixing http://crbug.com/50663. |
| 171 LOG(ERROR) << "After the loop."; |
| 158 | 172 |
| 159 views::View* first_focused_item = current_view(); | 173 views::View* first_focused_item = current_view(); |
| 160 | 174 |
| 161 ASSERT_TRUE(first_focused_item != NULL); | 175 ASSERT_TRUE(first_focused_item != NULL); |
| 162 | 176 |
| 163 views::View* next_focused_item = first_focused_item; | 177 views::View* next_focused_item = first_focused_item; |
| 164 | 178 |
| 165 // Keep tabbing until we reach the originally focused view. | 179 // Keep tabbing until we reach the originally focused view. |
| 166 do { | 180 do { |
| 181 // TODO(phajdan.jr): remove logging after fixing http://crbug.com/50663. |
| 182 LOG(ERROR) << "Sending TAB key event."; |
| 167 ui_controls::SendKeyPressNotifyWhenDone(hwnd, base::VKEY_TAB, | 183 ui_controls::SendKeyPressNotifyWhenDone(hwnd, base::VKEY_TAB, |
| 168 false, !forward_tab, false, false, new MessageLoop::QuitTask()); | 184 false, !forward_tab, false, false, new MessageLoop::QuitTask()); |
| 169 set_waiting(true); | 185 set_waiting(true); |
| 170 ui_test_utils::RunMessageLoop(); | 186 ui_test_utils::RunMessageLoop(); |
| 171 next_focused_item = current_view(); | 187 next_focused_item = current_view(); |
| 172 } while (first_focused_item != next_focused_item); | 188 } while (first_focused_item != next_focused_item); |
| 189 // TODO(phajdan.jr): remove logging after fixing http://crbug.com/50663. |
| 190 LOG(ERROR) << "After second loop."; |
| 173 } | 191 } |
| 174 | 192 |
| 175 } // namespace | 193 } // namespace |
| OLD | NEW |