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 "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/accessibility/browser_accessibility.h" | 7 #include "content/browser/accessibility/browser_accessibility.h" |
8 #include "content/browser/accessibility/browser_accessibility_manager.h" | 8 #include "content/browser/accessibility/browser_accessibility_manager.h" |
9 #include "content/common/accessibility_messages.h" | 9 #include "content/common/accessibility_messages.h" |
10 #include "content/common/accessibility_node_data.h" | 10 #include "content/common/accessibility_node_data.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 root, | 135 root, |
136 NULL, | 136 NULL, |
137 new CountedBrowserAccessibilityFactory()); | 137 new CountedBrowserAccessibilityFactory()); |
138 manager->UpdateNodesForTesting(button, checkbox); | 138 manager->UpdateNodesForTesting(button, checkbox); |
139 ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); | 139 ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); |
140 | 140 |
141 CountedBrowserAccessibility* root_accessible = | 141 CountedBrowserAccessibility* root_accessible = |
142 static_cast<CountedBrowserAccessibility*>(manager->GetRoot()); | 142 static_cast<CountedBrowserAccessibility*>(manager->GetRoot()); |
143 root_accessible->NativeAddReference(); | 143 root_accessible->NativeAddReference(); |
144 CountedBrowserAccessibility* child1_accessible = | 144 CountedBrowserAccessibility* child1_accessible = |
145 static_cast<CountedBrowserAccessibility*>(root_accessible->GetChild(1)); | 145 static_cast<CountedBrowserAccessibility*>( |
| 146 root_accessible->PlatformGetChild(1)); |
146 child1_accessible->NativeAddReference(); | 147 child1_accessible->NativeAddReference(); |
147 | 148 |
148 // Now delete the manager, and only one of the three nodes in the tree | 149 // Now delete the manager, and only one of the three nodes in the tree |
149 // should be released. | 150 // should be released. |
150 delete manager; | 151 delete manager; |
151 ASSERT_EQ(2, CountedBrowserAccessibility::global_obj_count_); | 152 ASSERT_EQ(2, CountedBrowserAccessibility::global_obj_count_); |
152 | 153 |
153 // Release each of our references and make sure that each one results in | 154 // Release each of our references and make sure that each one results in |
154 // the instance being deleted as its reference count hits zero. | 155 // the instance being deleted as its reference count hits zero. |
155 root_accessible->NativeReleaseReference(); | 156 root_accessible->NativeReleaseReference(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 NULL, | 227 NULL, |
227 new CountedBrowserAccessibilityFactory()); | 228 new CountedBrowserAccessibilityFactory()); |
228 manager->UpdateNodesForTesting(tree1_child1, tree1_child2, tree1_child3); | 229 manager->UpdateNodesForTesting(tree1_child1, tree1_child2, tree1_child3); |
229 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 230 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
230 | 231 |
231 // Save references to all of the objects. | 232 // Save references to all of the objects. |
232 CountedBrowserAccessibility* root_accessible = | 233 CountedBrowserAccessibility* root_accessible = |
233 static_cast<CountedBrowserAccessibility*>(manager->GetRoot()); | 234 static_cast<CountedBrowserAccessibility*>(manager->GetRoot()); |
234 root_accessible->NativeAddReference(); | 235 root_accessible->NativeAddReference(); |
235 CountedBrowserAccessibility* child1_accessible = | 236 CountedBrowserAccessibility* child1_accessible = |
236 static_cast<CountedBrowserAccessibility*>(root_accessible->GetChild(0)); | 237 static_cast<CountedBrowserAccessibility*>( |
| 238 root_accessible->PlatformGetChild(0)); |
237 child1_accessible->NativeAddReference(); | 239 child1_accessible->NativeAddReference(); |
238 CountedBrowserAccessibility* child2_accessible = | 240 CountedBrowserAccessibility* child2_accessible = |
239 static_cast<CountedBrowserAccessibility*>(root_accessible->GetChild(1)); | 241 static_cast<CountedBrowserAccessibility*>( |
| 242 root_accessible->PlatformGetChild(1)); |
240 child2_accessible->NativeAddReference(); | 243 child2_accessible->NativeAddReference(); |
241 CountedBrowserAccessibility* child3_accessible = | 244 CountedBrowserAccessibility* child3_accessible = |
242 static_cast<CountedBrowserAccessibility*>(root_accessible->GetChild(2)); | 245 static_cast<CountedBrowserAccessibility*>( |
| 246 root_accessible->PlatformGetChild(2)); |
243 child3_accessible->NativeAddReference(); | 247 child3_accessible->NativeAddReference(); |
244 | 248 |
245 // Check the index in parent. | 249 // Check the index in parent. |
246 EXPECT_EQ(0, child1_accessible->index_in_parent()); | 250 EXPECT_EQ(0, child1_accessible->index_in_parent()); |
247 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 251 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
248 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 252 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
249 | 253 |
250 // Process a notification containing the changed subtree. | 254 // Process a notification containing the changed subtree. |
251 std::vector<AccessibilityHostMsg_EventParams> params; | 255 std::vector<AccessibilityHostMsg_EventParams> params; |
252 params.push_back(AccessibilityHostMsg_EventParams()); | 256 params.push_back(AccessibilityHostMsg_EventParams()); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 tree1_child1, tree1_grandchild1, | 404 tree1_child1, tree1_grandchild1, |
401 tree1_child2, tree1_grandchild2, | 405 tree1_child2, tree1_grandchild2, |
402 tree1_child3, tree1_grandchild3); | 406 tree1_child3, tree1_grandchild3); |
403 ASSERT_EQ(8, CountedBrowserAccessibility::global_obj_count_); | 407 ASSERT_EQ(8, CountedBrowserAccessibility::global_obj_count_); |
404 | 408 |
405 // Save references to some objects. | 409 // Save references to some objects. |
406 CountedBrowserAccessibility* root_accessible = | 410 CountedBrowserAccessibility* root_accessible = |
407 static_cast<CountedBrowserAccessibility*>(manager->GetRoot()); | 411 static_cast<CountedBrowserAccessibility*>(manager->GetRoot()); |
408 root_accessible->NativeAddReference(); | 412 root_accessible->NativeAddReference(); |
409 CountedBrowserAccessibility* container_accessible = | 413 CountedBrowserAccessibility* container_accessible = |
410 static_cast<CountedBrowserAccessibility*>(root_accessible->GetChild(0)); | 414 static_cast<CountedBrowserAccessibility*>( |
| 415 root_accessible->PlatformGetChild(0)); |
411 container_accessible->NativeAddReference(); | 416 container_accessible->NativeAddReference(); |
412 CountedBrowserAccessibility* child2_accessible = | 417 CountedBrowserAccessibility* child2_accessible = |
413 static_cast<CountedBrowserAccessibility*>( | 418 static_cast<CountedBrowserAccessibility*>( |
414 container_accessible->GetChild(1)); | 419 container_accessible->PlatformGetChild(1)); |
415 child2_accessible->NativeAddReference(); | 420 child2_accessible->NativeAddReference(); |
416 CountedBrowserAccessibility* child3_accessible = | 421 CountedBrowserAccessibility* child3_accessible = |
417 static_cast<CountedBrowserAccessibility*>( | 422 static_cast<CountedBrowserAccessibility*>( |
418 container_accessible->GetChild(2)); | 423 container_accessible->PlatformGetChild(2)); |
419 child3_accessible->NativeAddReference(); | 424 child3_accessible->NativeAddReference(); |
420 | 425 |
421 // Check the index in parent. | 426 // Check the index in parent. |
422 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 427 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
423 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 428 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
424 | 429 |
425 // Process a notification containing the changed subtree rooted at | 430 // Process a notification containing the changed subtree rooted at |
426 // the container. | 431 // the container. |
427 std::vector<AccessibilityHostMsg_EventParams> params; | 432 std::vector<AccessibilityHostMsg_EventParams> params; |
428 params.push_back(AccessibilityHostMsg_EventParams()); | 433 params.push_back(AccessibilityHostMsg_EventParams()); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 manager.reset(BrowserAccessibilityManager::Create( | 605 manager.reset(BrowserAccessibilityManager::Create( |
601 root2, | 606 root2, |
602 delegate.get(), | 607 delegate.get(), |
603 factory)); | 608 factory)); |
604 ASSERT_FALSE(delegate->got_fatal_error()); | 609 ASSERT_FALSE(delegate->got_fatal_error()); |
605 manager->UpdateNodesForTesting(child1, child2); | 610 manager->UpdateNodesForTesting(child1, child2); |
606 ASSERT_TRUE(delegate->got_fatal_error()); | 611 ASSERT_TRUE(delegate->got_fatal_error()); |
607 } | 612 } |
608 | 613 |
609 } // namespace content | 614 } // namespace content |
OLD | NEW |