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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/views/widget/native_widget.h" | 25 #include "ui/views/widget/native_widget.h" |
26 #include "ui/views/widget/root_view.h" | 26 #include "ui/views/widget/root_view.h" |
27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
28 #include "ui/views/widget/widget_delegate.h" | 28 #include "ui/views/widget/widget_delegate.h" |
29 | 29 |
30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
31 #include "ui/base/win/scoped_ole_initializer.h" | 31 #include "ui/base/win/scoped_ole_initializer.h" |
32 #endif | 32 #endif |
33 | 33 |
34 #if defined(USE_AURA) | 34 #if defined(USE_AURA) |
35 #include "ui/aura/test/aura_test_helper.h" | |
36 #include "ui/aura/window_event_dispatcher.h" | 35 #include "ui/aura/window_event_dispatcher.h" |
37 #include "ui/compositor/test/context_factories_for_test.h" | 36 #include "ui/compositor/test/context_factories_for_test.h" |
| 37 #include "ui/wm/test/wm_test_helper.h" |
38 #endif | 38 #endif |
39 | 39 |
40 using base::ASCIIToUTF16; | 40 using base::ASCIIToUTF16; |
41 | 41 |
42 class AccessibilityViewsDelegate : public views::TestViewsDelegate { | 42 class AccessibilityViewsDelegate : public views::TestViewsDelegate { |
43 public: | 43 public: |
44 AccessibilityViewsDelegate() {} | 44 AccessibilityViewsDelegate() {} |
45 virtual ~AccessibilityViewsDelegate() {} | 45 virtual ~AccessibilityViewsDelegate() {} |
46 | 46 |
47 // Overridden from views::TestViewsDelegate: | 47 // Overridden from views::TestViewsDelegate: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 virtual void SetUp() { | 104 virtual void SetUp() { |
105 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
106 ole_initializer_.reset(new ui::ScopedOleInitializer()); | 106 ole_initializer_.reset(new ui::ScopedOleInitializer()); |
107 #endif | 107 #endif |
108 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); | 108 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); |
109 #if defined(USE_AURA) | 109 #if defined(USE_AURA) |
110 // The ContextFactory must exist before any Compositors are created. | 110 // The ContextFactory must exist before any Compositors are created. |
111 bool enable_pixel_output = false; | 111 bool enable_pixel_output = false; |
112 ui::InitializeContextFactoryForTests(enable_pixel_output); | 112 ui::InitializeContextFactoryForTests(enable_pixel_output); |
113 | 113 |
114 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 114 wm_test_helper_.reset(new wm::WMTestHelper); |
115 aura_test_helper_->SetUp(); | 115 wm_test_helper_->SetUp(); |
116 #endif // USE_AURA | 116 #endif // USE_AURA |
117 EnableAccessibilityAndListenToFocusNotifications(); | 117 EnableAccessibilityAndListenToFocusNotifications(); |
118 } | 118 } |
119 | 119 |
120 virtual void TearDown() { | 120 virtual void TearDown() { |
121 ClearCallback(); | 121 ClearCallback(); |
122 #if defined(USE_AURA) | 122 #if defined(USE_AURA) |
123 aura_test_helper_->TearDown(); | 123 wm_test_helper_->TearDown(); |
124 ui::TerminateContextFactoryForTests(); | 124 ui::TerminateContextFactoryForTests(); |
125 #endif | 125 #endif |
126 delete views::ViewsDelegate::views_delegate; | 126 delete views::ViewsDelegate::views_delegate; |
127 views::ViewsDelegate::views_delegate = NULL; | 127 views::ViewsDelegate::views_delegate = NULL; |
128 | 128 |
129 // The Widget's FocusManager is deleted using DeleteSoon - this | 129 // The Widget's FocusManager is deleted using DeleteSoon - this |
130 // forces it to be deleted now, so we don't have any memory leaks | 130 // forces it to be deleted now, so we don't have any memory leaks |
131 // when this method exits. | 131 // when this method exits. |
132 base::MessageLoop::current()->RunUntilIdle(); | 132 base::MessageLoop::current()->RunUntilIdle(); |
133 | 133 |
134 #if defined(OS_WIN) | 134 #if defined(OS_WIN) |
135 ole_initializer_.reset(); | 135 ole_initializer_.reset(); |
136 #endif | 136 #endif |
137 } | 137 } |
138 | 138 |
139 views::Widget* CreateWindowWithContents(views::View* contents) { | 139 views::Widget* CreateWindowWithContents(views::View* contents) { |
140 gfx::NativeView context = NULL; | 140 gfx::NativeView context = NULL; |
141 #if defined(USE_AURA) | 141 #if defined(USE_AURA) |
142 context = aura_test_helper_->root_window(); | 142 context = wm_test_helper_->root_window(); |
143 #endif | 143 #endif |
144 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 144 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
145 new AccessibilityWindowDelegate(contents), | 145 new AccessibilityWindowDelegate(contents), |
146 context, | 146 context, |
147 gfx::Rect(0, 0, 500, 500)); | 147 gfx::Rect(0, 0, 500, 500)); |
148 | 148 |
149 // Create a profile and associate it with this window. | 149 // Create a profile and associate it with this window. |
150 widget->SetNativeWindowProperty(Profile::kProfileKey, &profile_); | 150 widget->SetNativeWindowProperty(Profile::kProfileKey, &profile_); |
151 | 151 |
152 return widget; | 152 return widget; |
(...skipping 28 matching lines...) Expand all Loading... |
181 base::MessageLoopForUI message_loop_; | 181 base::MessageLoopForUI message_loop_; |
182 int control_event_count_; | 182 int control_event_count_; |
183 std::string last_control_type_; | 183 std::string last_control_type_; |
184 std::string last_control_name_; | 184 std::string last_control_name_; |
185 std::string last_control_context_; | 185 std::string last_control_context_; |
186 TestingProfile profile_; | 186 TestingProfile profile_; |
187 #if defined(OS_WIN) | 187 #if defined(OS_WIN) |
188 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; | 188 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; |
189 #endif | 189 #endif |
190 #if defined(USE_AURA) | 190 #if defined(USE_AURA) |
191 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 191 scoped_ptr<wm::WMTestHelper> wm_test_helper_; |
192 #endif | 192 #endif |
193 }; | 193 }; |
194 | 194 |
195 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { | 195 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { |
196 const char kButton1ASCII[] = "Button1"; | 196 const char kButton1ASCII[] = "Button1"; |
197 const char kButton2ASCII[] = "Button2"; | 197 const char kButton2ASCII[] = "Button2"; |
198 const char kButton3ASCII[] = "Button3"; | 198 const char kButton3ASCII[] = "Button3"; |
199 const char kButton3NewASCII[] = "Button3New"; | 199 const char kButton3NewASCII[] = "Button3New"; |
200 | 200 |
201 // Create a contents view with 3 buttons. | 201 // Create a contents view with 3 buttons. |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 499 |
500 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( | 500 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( |
501 menu_container, | 501 menu_container, |
502 menu->GetMenuItemByID(kTestCases[i].command_id), | 502 menu->GetMenuItemByID(kTestCases[i].command_id), |
503 &index, | 503 &index, |
504 &count); | 504 &count); |
505 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; | 505 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; |
506 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; | 506 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; |
507 } | 507 } |
508 } | 508 } |
OLD | NEW |