| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "base/win/scoped_bstr.h" | 7 #include "base/win/scoped_bstr.h" |
| 8 #include "base/win/scoped_comptr.h" | 8 #include "base/win/scoped_comptr.h" |
| 9 #include "base/win/scoped_variant.h" | 9 #include "base/win/scoped_variant.h" |
| 10 #include "content/browser/accessibility/browser_accessibility_manager.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 scoped_ptr<BrowserAccessibilityManager> manager( | 611 scoped_ptr<BrowserAccessibilityManager> manager( |
| 612 new BrowserAccessibilityManagerWin( | 612 new BrowserAccessibilityManagerWin( |
| 613 accessible_hwnd.get(), | 613 accessible_hwnd.get(), |
| 614 NULL, | 614 NULL, |
| 615 BrowserAccessibilityManagerWin::GetEmptyDocument(), | 615 BrowserAccessibilityManagerWin::GetEmptyDocument(), |
| 616 NULL, | 616 NULL, |
| 617 new CountedBrowserAccessibilityFactory())); | 617 new CountedBrowserAccessibilityFactory())); |
| 618 | 618 |
| 619 // Verify the root is as we expect by default. | 619 // Verify the root is as we expect by default. |
| 620 BrowserAccessibility* root = manager->GetRoot(); | 620 BrowserAccessibility* root = manager->GetRoot(); |
| 621 EXPECT_EQ(0, root->renderer_id()); | 621 EXPECT_EQ(0, root->GetId()); |
| 622 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->role()); | 622 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->GetRole()); |
| 623 EXPECT_EQ(busy_state | readonly_state | enabled_state, root->state()); | 623 EXPECT_EQ(busy_state | readonly_state | enabled_state, root->GetState()); |
| 624 | 624 |
| 625 // Tree with a child textfield. | 625 // Tree with a child textfield. |
| 626 ui::AXNodeData tree1_1; | 626 ui::AXNodeData tree1_1; |
| 627 tree1_1.id = 1; | 627 tree1_1.id = 1; |
| 628 tree1_1.role = ui::AX_ROLE_ROOT_WEB_AREA; | 628 tree1_1.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 629 tree1_1.child_ids.push_back(2); | 629 tree1_1.child_ids.push_back(2); |
| 630 | 630 |
| 631 ui::AXNodeData tree1_2; | 631 ui::AXNodeData tree1_2; |
| 632 tree1_2.id = 2; | 632 tree1_2.id = 2; |
| 633 tree1_2.role = ui::AX_ROLE_TEXT_FIELD; | 633 tree1_2.role = ui::AX_ROLE_TEXT_FIELD; |
| 634 | 634 |
| 635 // Process a load complete. | 635 // Process a load complete. |
| 636 std::vector<AccessibilityHostMsg_EventParams> params; | 636 std::vector<AccessibilityHostMsg_EventParams> params; |
| 637 params.push_back(AccessibilityHostMsg_EventParams()); | 637 params.push_back(AccessibilityHostMsg_EventParams()); |
| 638 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 638 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
| 639 msg->event_type = ui::AX_EVENT_LOAD_COMPLETE; | 639 msg->event_type = ui::AX_EVENT_LOAD_COMPLETE; |
| 640 msg->update.nodes.push_back(tree1_1); | 640 msg->update.nodes.push_back(tree1_1); |
| 641 msg->update.nodes.push_back(tree1_2); | 641 msg->update.nodes.push_back(tree1_2); |
| 642 msg->id = tree1_1.id; | 642 msg->id = tree1_1.id; |
| 643 manager->OnAccessibilityEvents(params); | 643 manager->OnAccessibilityEvents(params); |
| 644 | 644 |
| 645 // Save for later comparison. | 645 // Save for later comparison. |
| 646 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(2); | 646 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(2); |
| 647 | 647 |
| 648 // Verify the root has changed. | 648 // Verify the root has changed. |
| 649 EXPECT_NE(root, manager->GetRoot()); | 649 EXPECT_NE(root, manager->GetRoot()); |
| 650 | 650 |
| 651 // And the proper child remains. | 651 // And the proper child remains. |
| 652 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, acc1_2->role()); | 652 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, acc1_2->GetRole()); |
| 653 EXPECT_EQ(2, acc1_2->renderer_id()); | 653 EXPECT_EQ(2, acc1_2->GetId()); |
| 654 | 654 |
| 655 // Tree with a child button. | 655 // Tree with a child button. |
| 656 ui::AXNodeData tree2_1; | 656 ui::AXNodeData tree2_1; |
| 657 tree2_1.id = 1; | 657 tree2_1.id = 1; |
| 658 tree2_1.role = ui::AX_ROLE_ROOT_WEB_AREA; | 658 tree2_1.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 659 tree2_1.child_ids.push_back(3); | 659 tree2_1.child_ids.push_back(3); |
| 660 | 660 |
| 661 ui::AXNodeData tree2_2; | 661 ui::AXNodeData tree2_2; |
| 662 tree2_2.id = 3; | 662 tree2_2.id = 3; |
| 663 tree2_2.role = ui::AX_ROLE_BUTTON; | 663 tree2_2.role = ui::AX_ROLE_BUTTON; |
| 664 | 664 |
| 665 msg->update.nodes.clear(); | 665 msg->update.nodes.clear(); |
| 666 msg->update.nodes.push_back(tree2_1); | 666 msg->update.nodes.push_back(tree2_1); |
| 667 msg->update.nodes.push_back(tree2_2); | 667 msg->update.nodes.push_back(tree2_2); |
| 668 msg->id = tree2_1.id; | 668 msg->id = tree2_1.id; |
| 669 | 669 |
| 670 // Fire another load complete. | 670 // Fire another load complete. |
| 671 manager->OnAccessibilityEvents(params); | 671 manager->OnAccessibilityEvents(params); |
| 672 | 672 |
| 673 BrowserAccessibility* acc2_2 = manager->GetFromRendererID(3); | 673 BrowserAccessibility* acc2_2 = manager->GetFromRendererID(3); |
| 674 | 674 |
| 675 // Verify the root has changed. | 675 // Verify the root has changed. |
| 676 EXPECT_NE(root, manager->GetRoot()); | 676 EXPECT_NE(root, manager->GetRoot()); |
| 677 | 677 |
| 678 // And the new child exists. | 678 // And the new child exists. |
| 679 EXPECT_EQ(ui::AX_ROLE_BUTTON, acc2_2->role()); | 679 EXPECT_EQ(ui::AX_ROLE_BUTTON, acc2_2->GetRole()); |
| 680 EXPECT_EQ(3, acc2_2->renderer_id()); | 680 EXPECT_EQ(3, acc2_2->GetId()); |
| 681 | 681 |
| 682 // Ensure we properly cleaned up. | 682 // Ensure we properly cleaned up. |
| 683 manager.reset(); | 683 manager.reset(); |
| 684 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 684 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 685 } | 685 } |
| 686 | 686 |
| 687 TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) { | 687 TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) { |
| 688 HWND desktop_hwnd = GetDesktopWindow(); | 688 HWND desktop_hwnd = GetDesktopWindow(); |
| 689 base::win::ScopedComPtr<IAccessible> desktop_hwnd_iaccessible; | 689 base::win::ScopedComPtr<IAccessible> desktop_hwnd_iaccessible; |
| 690 ASSERT_EQ(S_OK, AccessibleObjectFromWindow( | 690 ASSERT_EQ(S_OK, AccessibleObjectFromWindow( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 manager->MaybeCallNotifyWinEvent(0, 0); | 731 manager->MaybeCallNotifyWinEvent(0, 0); |
| 732 new_parent_hwnd = manager->parent_hwnd(); | 732 new_parent_hwnd = manager->parent_hwnd(); |
| 733 ASSERT_FALSE(NULL == new_parent_hwnd); | 733 ASSERT_FALSE(NULL == new_parent_hwnd); |
| 734 | 734 |
| 735 // This time, destroy the manager first, make sure the AccessibleHWND doesn't | 735 // This time, destroy the manager first, make sure the AccessibleHWND doesn't |
| 736 // crash on destruction (to be caught by SyzyASAN or other tools). | 736 // crash on destruction (to be caught by SyzyASAN or other tools). |
| 737 manager.reset(NULL); | 737 manager.reset(NULL); |
| 738 } | 738 } |
| 739 | 739 |
| 740 } // namespace content | 740 } // namespace content |
| OLD | NEW |