| 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/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "base/scoped_comptr_win.h" | 6 #include "base/scoped_comptr_win.h" |
| 7 #include "chrome/browser/accessibility/browser_accessibility_manager.h" | 7 #include "chrome/browser/accessibility/browser_accessibility_manager.h" |
| 8 #include "chrome/browser/accessibility/browser_accessibility_win.h" | 8 #include "chrome/browser/accessibility/browser_accessibility_win.h" |
| 9 #include "chrome/common/render_messages_params.h" | 9 #include "content/common/view_messages.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 using webkit_glue::WebAccessibility; | 12 using webkit_glue::WebAccessibility; |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Subclass of BrowserAccessibilityWin that counts the number of instances. | 16 // Subclass of BrowserAccessibilityWin that counts the number of instances. |
| 17 class CountedBrowserAccessibility : public BrowserAccessibilityWin { | 17 class CountedBrowserAccessibility : public BrowserAccessibilityWin { |
| 18 public: | 18 public: |
| 19 CountedBrowserAccessibility() { global_obj_count_++; } | 19 CountedBrowserAccessibility() { global_obj_count_++; } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = |
| 196 ViewHostMsg_AccessibilityNotification_Params:: | 196 ViewHostMsg_AccessibilityNotification_Type:: |
| 197 NOTIFICATION_TYPE_CHILDREN_CHANGED; | 197 NOTIFICATION_TYPE_CHILDREN_CHANGED; |
| 198 param.acc_obj = text; | 198 param.acc_obj = text; |
| 199 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 199 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
| 200 notifications.push_back(param); | 200 notifications.push_back(param); |
| 201 manager->OnAccessibilityNotifications(notifications); | 201 manager->OnAccessibilityNotifications(notifications); |
| 202 | 202 |
| 203 // Query for the text IAccessible and verify that it now returns "new text" | 203 // Query for the text IAccessible and verify that it now returns "new text" |
| 204 // as its value. | 204 // as its value. |
| 205 hr = manager->GetRoot()->toBrowserAccessibilityWin()->get_accChild( | 205 hr = manager->GetRoot()->toBrowserAccessibilityWin()->get_accChild( |
| 206 CreateI4Variant(1), | 206 CreateI4Variant(1), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 root, | 258 root, |
| 259 NULL, | 259 NULL, |
| 260 new CountedBrowserAccessibilityFactory()); | 260 new CountedBrowserAccessibilityFactory()); |
| 261 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 261 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
| 262 | 262 |
| 263 // Notify the BrowserAccessibilityManager that the div node and its children | 263 // Notify the BrowserAccessibilityManager that the div node and its children |
| 264 // were removed and ensure that only one BrowserAccessibility instance exists. | 264 // were removed and ensure that only one BrowserAccessibility instance exists. |
| 265 root.children.clear(); | 265 root.children.clear(); |
| 266 ViewHostMsg_AccessibilityNotification_Params param; | 266 ViewHostMsg_AccessibilityNotification_Params param; |
| 267 param.notification_type = | 267 param.notification_type = |
| 268 ViewHostMsg_AccessibilityNotification_Params:: | 268 ViewHostMsg_AccessibilityNotification_Type:: |
| 269 NOTIFICATION_TYPE_CHILDREN_CHANGED; | 269 NOTIFICATION_TYPE_CHILDREN_CHANGED; |
| 270 param.acc_obj = root; | 270 param.acc_obj = root; |
| 271 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 271 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
| 272 notifications.push_back(param); | 272 notifications.push_back(param); |
| 273 manager->OnAccessibilityNotifications(notifications); | 273 manager->OnAccessibilityNotifications(notifications); |
| 274 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); | 274 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); |
| 275 | 275 |
| 276 // Delete the manager and test that all BrowserAccessibility instances are | 276 // Delete the manager and test that all BrowserAccessibility instances are |
| 277 // deleted. | 277 // deleted. |
| 278 delete manager; | 278 delete manager; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 ASSERT_EQ(start, 0); | 356 ASSERT_EQ(start, 0); |
| 357 ASSERT_EQ(end, 13); | 357 ASSERT_EQ(end, 13); |
| 358 ASSERT_EQ(text, string16(L"One two three")); | 358 ASSERT_EQ(text, string16(L"One two three")); |
| 359 SysFreeString(text); | 359 SysFreeString(text); |
| 360 | 360 |
| 361 // Delete the manager and test that all BrowserAccessibility instances are | 361 // Delete the manager and test that all BrowserAccessibility instances are |
| 362 // deleted. | 362 // deleted. |
| 363 delete manager; | 363 delete manager; |
| 364 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 364 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 365 } | 365 } |
| OLD | NEW |