| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ui/views/widget/native_widget.h" | 22 #include "ui/views/widget/native_widget.h" |
| 23 #include "ui/views/widget/root_view.h" | 23 #include "ui/views/widget/root_view.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
| 26 | 26 |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 #include "ui/base/win/scoped_ole_initializer.h" | 28 #include "ui/base/win/scoped_ole_initializer.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #if defined(USE_AURA) | 31 #if defined(USE_AURA) |
| 32 #include "ui/aura/root_window.h" |
| 32 #include "ui/aura/test/aura_test_helper.h" | 33 #include "ui/aura/test/aura_test_helper.h" |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 #if defined(TOOLKIT_VIEWS) | 36 #if defined(TOOLKIT_VIEWS) |
| 36 | 37 |
| 37 class AccessibilityViewsDelegate : public views::TestViewsDelegate { | 38 class AccessibilityViewsDelegate : public views::TestViewsDelegate { |
| 38 public: | 39 public: |
| 39 AccessibilityViewsDelegate() {} | 40 AccessibilityViewsDelegate() {} |
| 40 virtual ~AccessibilityViewsDelegate() {} | 41 virtual ~AccessibilityViewsDelegate() {} |
| 41 | 42 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // forces it to be deleted now, so we don't have any memory leaks | 115 // forces it to be deleted now, so we don't have any memory leaks |
| 115 // when this method exits. | 116 // when this method exits. |
| 116 MessageLoop::current()->RunUntilIdle(); | 117 MessageLoop::current()->RunUntilIdle(); |
| 117 | 118 |
| 118 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
| 119 ole_initializer_.reset(); | 120 ole_initializer_.reset(); |
| 120 #endif | 121 #endif |
| 121 } | 122 } |
| 122 | 123 |
| 123 views::Widget* CreateWindowWithContents(views::View* contents) { | 124 views::Widget* CreateWindowWithContents(views::View* contents) { |
| 124 return views::Widget::CreateWindowWithBounds( | 125 gfx::NativeView context = NULL; |
| 126 #if defined(USE_AURA) |
| 127 context = aura_test_helper_->root_window(); |
| 128 #endif |
| 129 |
| 130 return views::Widget::CreateWindowWithContextAndBounds( |
| 125 new AccessibilityWindowDelegate(contents), | 131 new AccessibilityWindowDelegate(contents), |
| 132 context, |
| 126 gfx::Rect(0, 0, 500, 500)); | 133 gfx::Rect(0, 0, 500, 500)); |
| 127 } | 134 } |
| 128 | 135 |
| 129 protected: | 136 protected: |
| 130 // Implement NotificationObserver::Observe and store information about a | 137 // Implement NotificationObserver::Observe and store information about a |
| 131 // ACCESSIBILITY_CONTROL_FOCUSED event. | 138 // ACCESSIBILITY_CONTROL_FOCUSED event. |
| 132 virtual void Observe(int type, | 139 virtual void Observe(int type, |
| 133 const content::NotificationSource& source, | 140 const content::NotificationSource& source, |
| 134 const content::NotificationDetails& details) { | 141 const content::NotificationDetails& details) { |
| 135 ASSERT_EQ(type, chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED); | 142 ASSERT_EQ(type, chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 304 |
| 298 // Test that we got the event with the expected name and context. | 305 // Test that we got the event with the expected name and context. |
| 299 EXPECT_EQ(1, focus_event_count_); | 306 EXPECT_EQ(1, focus_event_count_); |
| 300 EXPECT_EQ(kButtonNameASCII, last_control_name_); | 307 EXPECT_EQ(kButtonNameASCII, last_control_name_); |
| 301 EXPECT_EQ(kAlertTextASCII, last_control_context_); | 308 EXPECT_EQ(kAlertTextASCII, last_control_context_); |
| 302 | 309 |
| 303 window->CloseNow(); | 310 window->CloseNow(); |
| 304 } | 311 } |
| 305 | 312 |
| 306 #endif // defined(TOOLKIT_VIEWS) | 313 #endif // defined(TOOLKIT_VIEWS) |
| OLD | NEW |