| 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 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include "content/browser/accessibility/browser_accessibility_win.h" | 10 #include "content/browser/accessibility/browser_accessibility_win.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // Check the index in parent. | 260 // Check the index in parent. |
| 261 EXPECT_EQ(0, child1_accessible->index_in_parent()); | 261 EXPECT_EQ(0, child1_accessible->index_in_parent()); |
| 262 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 262 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
| 263 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 263 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
| 264 | 264 |
| 265 // Process a notification containing the changed subtree. | 265 // Process a notification containing the changed subtree. |
| 266 std::vector<AccessibilityHostMsg_EventParams> params; | 266 std::vector<AccessibilityHostMsg_EventParams> params; |
| 267 params.push_back(AccessibilityHostMsg_EventParams()); | 267 params.push_back(AccessibilityHostMsg_EventParams()); |
| 268 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 268 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
| 269 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; | 269 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
| 270 msg->nodes.push_back(tree2_root); | 270 msg->update.nodes.push_back(tree2_root); |
| 271 msg->nodes.push_back(tree2_child0); | 271 msg->update.nodes.push_back(tree2_child0); |
| 272 msg->id = tree2_root.id; | 272 msg->id = tree2_root.id; |
| 273 manager->OnAccessibilityEvents(params); | 273 manager->OnAccessibilityEvents(params); |
| 274 | 274 |
| 275 // There should be 5 objects now: the 4 from the new tree, plus the | 275 // There should be 5 objects now: the 4 from the new tree, plus the |
| 276 // reference to child3 we kept. | 276 // reference to child3 we kept. |
| 277 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_); | 277 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_); |
| 278 | 278 |
| 279 // Check that our references to the root, child1, and child2 are still valid, | 279 // Check that our references to the root, child1, and child2 are still valid, |
| 280 // but that the reference to child3 is now invalid. | 280 // but that the reference to child3 is now invalid. |
| 281 EXPECT_TRUE(root_accessible->instance_active()); | 281 EXPECT_TRUE(root_accessible->instance_active()); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 // Check the index in parent. | 437 // Check the index in parent. |
| 438 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 438 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
| 439 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 439 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
| 440 | 440 |
| 441 // Process a notification containing the changed subtree rooted at | 441 // Process a notification containing the changed subtree rooted at |
| 442 // the container. | 442 // the container. |
| 443 std::vector<AccessibilityHostMsg_EventParams> params; | 443 std::vector<AccessibilityHostMsg_EventParams> params; |
| 444 params.push_back(AccessibilityHostMsg_EventParams()); | 444 params.push_back(AccessibilityHostMsg_EventParams()); |
| 445 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 445 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
| 446 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; | 446 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
| 447 msg->nodes.push_back(tree2_container); | 447 msg->update.nodes.push_back(tree2_container); |
| 448 msg->nodes.push_back(tree2_child0); | 448 msg->update.nodes.push_back(tree2_child0); |
| 449 msg->nodes.push_back(tree2_grandchild0); | 449 msg->update.nodes.push_back(tree2_grandchild0); |
| 450 msg->id = tree2_container.id; | 450 msg->id = tree2_container.id; |
| 451 manager->OnAccessibilityEvents(params); | 451 manager->OnAccessibilityEvents(params); |
| 452 | 452 |
| 453 // There should be 9 objects now: the 8 from the new tree, plus the | 453 // There should be 9 objects now: the 8 from the new tree, plus the |
| 454 // reference to child3 we kept. | 454 // reference to child3 we kept. |
| 455 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_); | 455 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_); |
| 456 | 456 |
| 457 // Check that our references to the root and container and child2 are | 457 // Check that our references to the root and container and child2 are |
| 458 // still valid, but that the reference to child3 is now invalid. | 458 // still valid, but that the reference to child3 is now invalid. |
| 459 EXPECT_TRUE(root_accessible->instance_active()); | 459 EXPECT_TRUE(root_accessible->instance_active()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 NULL, | 544 NULL, |
| 545 new CountedBrowserAccessibilityFactory()); | 545 new CountedBrowserAccessibilityFactory()); |
| 546 manager->UpdateNodesForTesting(tree1_2, tree1_3, tree1_4); | 546 manager->UpdateNodesForTesting(tree1_2, tree1_3, tree1_4); |
| 547 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 547 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
| 548 | 548 |
| 549 // Process a notification containing the changed subtree. | 549 // Process a notification containing the changed subtree. |
| 550 std::vector<AccessibilityHostMsg_EventParams> params; | 550 std::vector<AccessibilityHostMsg_EventParams> params; |
| 551 params.push_back(AccessibilityHostMsg_EventParams()); | 551 params.push_back(AccessibilityHostMsg_EventParams()); |
| 552 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 552 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
| 553 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; | 553 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
| 554 msg->nodes.push_back(tree2_1); | 554 msg->update.nodes.push_back(tree2_1); |
| 555 msg->nodes.push_back(tree2_4); | 555 msg->update.nodes.push_back(tree2_4); |
| 556 msg->nodes.push_back(tree2_5); | 556 msg->update.nodes.push_back(tree2_5); |
| 557 msg->nodes.push_back(tree2_6); | 557 msg->update.nodes.push_back(tree2_6); |
| 558 msg->id = tree2_1.id; | 558 msg->id = tree2_1.id; |
| 559 manager->OnAccessibilityEvents(params); | 559 manager->OnAccessibilityEvents(params); |
| 560 | 560 |
| 561 // There should be 4 objects now. | 561 // There should be 4 objects now. |
| 562 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 562 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
| 563 | 563 |
| 564 // Delete the manager and make sure all memory is cleaned up. | 564 // Delete the manager and make sure all memory is cleaned up. |
| 565 delete manager; | 565 delete manager; |
| 566 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 566 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 567 } | 567 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 root_accessible->GetLocalBoundsForRange(1, 2).ToString()); | 880 root_accessible->GetLocalBoundsForRange(1, 2).ToString()); |
| 881 | 881 |
| 882 EXPECT_EQ(gfx::Rect(120, 100, 80, 20).ToString(), | 882 EXPECT_EQ(gfx::Rect(120, 100, 80, 20).ToString(), |
| 883 root_accessible->GetLocalBoundsForRange(1, 3).ToString()); | 883 root_accessible->GetLocalBoundsForRange(1, 3).ToString()); |
| 884 | 884 |
| 885 EXPECT_EQ(gfx::Rect(100, 100, 100, 20).ToString(), | 885 EXPECT_EQ(gfx::Rect(100, 100, 100, 20).ToString(), |
| 886 root_accessible->GetLocalBoundsForRange(0, 4).ToString()); | 886 root_accessible->GetLocalBoundsForRange(0, 4).ToString()); |
| 887 } | 887 } |
| 888 | 888 |
| 889 } // namespace content | 889 } // namespace content |
| OLD | NEW |