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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/win/scoped_comptr.h" | 6 #include "base/win/scoped_comptr.h" |
7 #include "content/browser/accessibility/browser_accessibility_manager.h" | 7 #include "content/browser/accessibility/browser_accessibility_manager.h" |
8 #include "content/browser/accessibility/browser_accessibility_win.h" | 8 #include "content/browser/accessibility/browser_accessibility_win.h" |
9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 hr = text_accessible->get_accName(CreateI4Variant(CHILDID_SELF), &name); | 185 hr = text_accessible->get_accName(CreateI4Variant(CHILDID_SELF), &name); |
186 ASSERT_EQ(S_OK, hr); | 186 ASSERT_EQ(S_OK, hr); |
187 EXPECT_STREQ(L"old text", name.m_str); | 187 EXPECT_STREQ(L"old text", name.m_str); |
188 | 188 |
189 text_dispatch.Release(); | 189 text_dispatch.Release(); |
190 text_accessible.Release(); | 190 text_accessible.Release(); |
191 | 191 |
192 // Notify the BrowserAccessibilityManager that the text child has changed. | 192 // Notify the BrowserAccessibilityManager that the text child has changed. |
193 text.name = L"new text"; | 193 text.name = L"new text"; |
194 ViewHostMsg_AccessibilityNotification_Params param; | 194 ViewHostMsg_AccessibilityNotification_Params param; |
195 param.notification_type = | 195 param.notification_type = ViewHostMsg_AccEvent::CHILDREN_CHANGED; |
196 ViewHostMsg_AccessibilityNotification_Type:: | |
197 NOTIFICATION_TYPE_CHILDREN_CHANGED; | |
198 param.acc_obj = text; | 196 param.acc_obj = text; |
199 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 197 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
200 notifications.push_back(param); | 198 notifications.push_back(param); |
201 manager->OnAccessibilityNotifications(notifications); | 199 manager->OnAccessibilityNotifications(notifications); |
202 | 200 |
203 // Query for the text IAccessible and verify that it now returns "new text" | 201 // Query for the text IAccessible and verify that it now returns "new text" |
204 // as its value. | 202 // as its value. |
205 hr = manager->GetRoot()->toBrowserAccessibilityWin()->get_accChild( | 203 hr = manager->GetRoot()->toBrowserAccessibilityWin()->get_accChild( |
206 CreateI4Variant(1), | 204 CreateI4Variant(1), |
207 text_dispatch.Receive()); | 205 text_dispatch.Receive()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 GetDesktopWindow(), | 255 GetDesktopWindow(), |
258 root, | 256 root, |
259 NULL, | 257 NULL, |
260 new CountedBrowserAccessibilityFactory()); | 258 new CountedBrowserAccessibilityFactory()); |
261 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 259 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
262 | 260 |
263 // Notify the BrowserAccessibilityManager that the div node and its children | 261 // Notify the BrowserAccessibilityManager that the div node and its children |
264 // were removed and ensure that only one BrowserAccessibility instance exists. | 262 // were removed and ensure that only one BrowserAccessibility instance exists. |
265 root.children.clear(); | 263 root.children.clear(); |
266 ViewHostMsg_AccessibilityNotification_Params param; | 264 ViewHostMsg_AccessibilityNotification_Params param; |
267 param.notification_type = | 265 param.notification_type = ViewHostMsg_AccEvent::CHILDREN_CHANGED; |
268 ViewHostMsg_AccessibilityNotification_Type:: | |
269 NOTIFICATION_TYPE_CHILDREN_CHANGED; | |
270 param.acc_obj = root; | 266 param.acc_obj = root; |
271 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 267 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
272 notifications.push_back(param); | 268 notifications.push_back(param); |
273 manager->OnAccessibilityNotifications(notifications); | 269 manager->OnAccessibilityNotifications(notifications); |
274 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); | 270 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); |
275 | 271 |
276 // Delete the manager and test that all BrowserAccessibility instances are | 272 // Delete the manager and test that all BrowserAccessibility instances are |
277 // deleted. | 273 // deleted. |
278 delete manager; | 274 delete manager; |
279 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 275 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 357 |
362 ASSERT_EQ(S_OK, text1_obj->get_text(0, IA2_TEXT_OFFSET_LENGTH, &text)); | 358 ASSERT_EQ(S_OK, text1_obj->get_text(0, IA2_TEXT_OFFSET_LENGTH, &text)); |
363 ASSERT_EQ(text, string16(L"One two three.\nFour five six.")); | 359 ASSERT_EQ(text, string16(L"One two three.\nFour five six.")); |
364 SysFreeString(text); | 360 SysFreeString(text); |
365 | 361 |
366 // Delete the manager and test that all BrowserAccessibility instances are | 362 // Delete the manager and test that all BrowserAccessibility instances are |
367 // deleted. | 363 // deleted. |
368 delete manager; | 364 delete manager; |
369 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 365 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
370 } | 366 } |
OLD | NEW |