OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 ui::AccessibilityTypes::Role role_; | 114 ui::AccessibilityTypes::Role role_; |
115 }; | 115 }; |
116 | 116 |
117 class AccessibilityEventRouterViewsTest | 117 class AccessibilityEventRouterViewsTest |
118 : public testing::Test, | 118 : public testing::Test, |
119 public content::NotificationObserver { | 119 public content::NotificationObserver { |
120 public: | 120 public: |
121 virtual void SetUp() { | 121 virtual void SetUp() { |
122 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); | 122 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); |
123 #if defined(USE_AURA) | 123 #if defined(USE_AURA) |
124 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); | 124 root_window_.reset(new aura::RootWindow); |
125 test_stacking_client_.reset( | 125 test_stacking_client_.reset( |
126 new aura::test::TestStackingClient(root_window)); | 126 new aura::test::TestStackingClient(root_window_.get())); |
127 #endif | 127 #endif |
128 } | 128 } |
129 | 129 |
130 virtual void TearDown() { | 130 virtual void TearDown() { |
131 #if defined(USE_AURA) | 131 #if defined(USE_AURA) |
132 test_stacking_client_.reset(); | 132 test_stacking_client_.reset(); |
| 133 root_window_.reset(); |
133 #endif | 134 #endif |
134 delete views::ViewsDelegate::views_delegate; | 135 delete views::ViewsDelegate::views_delegate; |
135 views::ViewsDelegate::views_delegate = NULL; | 136 views::ViewsDelegate::views_delegate = NULL; |
136 | 137 |
137 // The Widget's FocusManager is deleted using DeleteSoon - this | 138 // The Widget's FocusManager is deleted using DeleteSoon - this |
138 // forces it to be deleted now, so we don't have any memory leaks | 139 // forces it to be deleted now, so we don't have any memory leaks |
139 // when this method exits. | 140 // when this method exits. |
140 MessageLoop::current()->RunAllPending(); | 141 MessageLoop::current()->RunAllPending(); |
141 } | 142 } |
142 | 143 |
(...skipping 15 matching lines...) Expand all Loading... |
158 focus_event_count_++; | 159 focus_event_count_++; |
159 last_control_name_ = info->name(); | 160 last_control_name_ = info->name(); |
160 last_control_context_ = info->context(); | 161 last_control_context_ = info->context(); |
161 } | 162 } |
162 | 163 |
163 MessageLoopForUI message_loop_; | 164 MessageLoopForUI message_loop_; |
164 int focus_event_count_; | 165 int focus_event_count_; |
165 std::string last_control_name_; | 166 std::string last_control_name_; |
166 std::string last_control_context_; | 167 std::string last_control_context_; |
167 #if defined(USE_AURA) | 168 #if defined(USE_AURA) |
| 169 scoped_ptr<aura::RootWindow> root_window_; |
168 scoped_ptr<aura::test::TestStackingClient> test_stacking_client_; | 170 scoped_ptr<aura::test::TestStackingClient> test_stacking_client_; |
169 #endif | 171 #endif |
170 }; | 172 }; |
171 | 173 |
172 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { | 174 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { |
173 const char kButton1ASCII[] = "Button1"; | 175 const char kButton1ASCII[] = "Button1"; |
174 const char kButton2ASCII[] = "Button2"; | 176 const char kButton2ASCII[] = "Button2"; |
175 const char kButton3ASCII[] = "Button3"; | 177 const char kButton3ASCII[] = "Button3"; |
176 const char kButton3NewASCII[] = "Button3New"; | 178 const char kButton3NewASCII[] = "Button3New"; |
177 | 179 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 314 |
313 // Test that we got the event with the expected name and context. | 315 // Test that we got the event with the expected name and context. |
314 EXPECT_EQ(1, focus_event_count_); | 316 EXPECT_EQ(1, focus_event_count_); |
315 EXPECT_EQ(kButtonNameASCII, last_control_name_); | 317 EXPECT_EQ(kButtonNameASCII, last_control_name_); |
316 EXPECT_EQ(kAlertTextASCII, last_control_context_); | 318 EXPECT_EQ(kAlertTextASCII, last_control_context_); |
317 | 319 |
318 window->CloseNow(); | 320 window->CloseNow(); |
319 } | 321 } |
320 | 322 |
321 #endif // defined(TOOLKIT_VIEWS) | 323 #endif // defined(TOOLKIT_VIEWS) |
OLD | NEW |