| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 EXPECT_EQ(1 << ui::AX_STATE_BUSY | | 763 EXPECT_EQ(1 << ui::AX_STATE_BUSY | |
| 764 1 << ui::AX_STATE_READ_ONLY | | 764 1 << ui::AX_STATE_READ_ONLY | |
| 765 1 << ui::AX_STATE_ENABLED, | 765 1 << ui::AX_STATE_ENABLED, |
| 766 root->GetState()); | 766 root->GetState()); |
| 767 | 767 |
| 768 LONG unique_id_win = root->ToBrowserAccessibilityWin()->unique_id_win(); | 768 LONG unique_id_win = root->ToBrowserAccessibilityWin()->unique_id_win(); |
| 769 ASSERT_EQ(root, manager->GetFromUniqueIdWin(unique_id_win)); | 769 ASSERT_EQ(root, manager->GetFromUniqueIdWin(unique_id_win)); |
| 770 } | 770 } |
| 771 | 771 |
| 772 TEST_F(BrowserAccessibilityTest, TestIA2Attributes) { | 772 TEST_F(BrowserAccessibilityTest, TestIA2Attributes) { |
| 773 ui::AXNodeData pseudo_before; |
| 774 pseudo_before.id = 2; |
| 775 pseudo_before.role = ui::AX_ROLE_DIV; |
| 776 pseudo_before.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "<pseudo:before>"); |
| 777 pseudo_before.AddStringAttribute(ui::AX_ATTR_DISPLAY, "none"); |
| 778 |
| 773 ui::AXNodeData checkbox; | 779 ui::AXNodeData checkbox; |
| 774 checkbox.id = 2; | 780 checkbox.id = 3; |
| 775 checkbox.SetName("Checkbox"); | 781 checkbox.SetName("Checkbox"); |
| 776 checkbox.role = ui::AX_ROLE_CHECK_BOX; | 782 checkbox.role = ui::AX_ROLE_CHECK_BOX; |
| 777 checkbox.state = 1 << ui::AX_STATE_CHECKED; | 783 checkbox.state = 1 << ui::AX_STATE_CHECKED; |
| 778 | 784 |
| 779 ui::AXNodeData root; | 785 ui::AXNodeData root; |
| 780 root.id = 1; | 786 root.id = 1; |
| 781 root.SetName("Document"); | 787 root.SetName("Document"); |
| 782 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 788 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 783 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 789 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); |
| 784 root.child_ids.push_back(2); | 790 root.child_ids.push_back(2); |
| 791 root.child_ids.push_back(3); |
| 785 | 792 |
| 786 CountedBrowserAccessibility::reset(); | 793 CountedBrowserAccessibility::reset(); |
| 787 scoped_ptr<BrowserAccessibilityManager> manager( | 794 scoped_ptr<BrowserAccessibilityManager> manager( |
| 788 BrowserAccessibilityManager::Create( | 795 BrowserAccessibilityManager::Create( |
| 789 MakeAXTreeUpdate(root, checkbox), | 796 MakeAXTreeUpdate(root, pseudo_before, checkbox), nullptr, |
| 790 nullptr, new CountedBrowserAccessibilityFactory())); | 797 new CountedBrowserAccessibilityFactory())); |
| 791 ASSERT_EQ(2, CountedBrowserAccessibility::num_instances()); | 798 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
| 792 | 799 |
| 793 ASSERT_NE(nullptr, manager->GetRoot()); | 800 ASSERT_NE(nullptr, manager->GetRoot()); |
| 794 BrowserAccessibilityWin* root_accessible = | 801 BrowserAccessibilityWin* root_accessible = |
| 795 manager->GetRoot()->ToBrowserAccessibilityWin(); | 802 manager->GetRoot()->ToBrowserAccessibilityWin(); |
| 796 ASSERT_NE(nullptr, root_accessible); | 803 ASSERT_NE(nullptr, root_accessible); |
| 797 ASSERT_EQ(1, root_accessible->PlatformChildCount()); | 804 ASSERT_EQ(2, root_accessible->PlatformChildCount()); |
| 798 BrowserAccessibilityWin* checkbox_accessible = | 805 |
| 799 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 806 BrowserAccessibilityWin* pseudo_accessible = |
| 800 ASSERT_NE(nullptr, checkbox_accessible); | 807 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); |
| 808 ASSERT_NE(nullptr, pseudo_accessible); |
| 801 | 809 |
| 802 base::win::ScopedBstr attributes; | 810 base::win::ScopedBstr attributes; |
| 803 HRESULT hr = checkbox_accessible->get_attributes(attributes.Receive()); | 811 HRESULT hr = pseudo_accessible->get_attributes(attributes.Receive()); |
| 804 EXPECT_EQ(S_OK, hr); | 812 EXPECT_EQ(S_OK, hr); |
| 805 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); | 813 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); |
| 806 std::wstring attributes_str(attributes, attributes.Length()); | 814 std::wstring attributes_str(attributes, attributes.Length()); |
| 815 EXPECT_EQ(L"display:none;tag:<pseudo\\:before>;", attributes_str); |
| 816 |
| 817 BrowserAccessibilityWin* checkbox_accessible = |
| 818 root_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); |
| 819 ASSERT_NE(nullptr, checkbox_accessible); |
| 820 |
| 821 attributes.Reset(); |
| 822 hr = checkbox_accessible->get_attributes(attributes.Receive()); |
| 823 EXPECT_EQ(S_OK, hr); |
| 824 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); |
| 825 attributes_str = std::wstring(attributes, attributes.Length()); |
| 807 EXPECT_EQ(L"checkable:true;", attributes_str); | 826 EXPECT_EQ(L"checkable:true;", attributes_str); |
| 808 | 827 |
| 809 manager.reset(); | 828 manager.reset(); |
| 810 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 829 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 811 } | 830 } |
| 812 | 831 |
| 813 /** | 832 /** |
| 814 * Ensures that ui::AX_ATTR_TEXT_SEL_START/END attributes are correctly used to | 833 * Ensures that ui::AX_ATTR_TEXT_SEL_START/END attributes are correctly used to |
| 815 * determine caret position and text selection in simple form fields. | 834 * determine caret position and text selection in simple form fields. |
| 816 */ | 835 */ |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 0L /* selection_index */, &selection_start, &selection_end);; | 1199 0L /* selection_index */, &selection_start, &selection_end);; |
| 1181 EXPECT_EQ(S_OK, hr); | 1200 EXPECT_EQ(S_OK, hr); |
| 1182 EXPECT_EQ(1L, selection_start); | 1201 EXPECT_EQ(1L, selection_start); |
| 1183 EXPECT_EQ(7L, selection_end); | 1202 EXPECT_EQ(7L, selection_end); |
| 1184 | 1203 |
| 1185 manager.reset(); | 1204 manager.reset(); |
| 1186 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 1205 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 1187 } | 1206 } |
| 1188 | 1207 |
| 1189 } // namespace content | 1208 } // namespace content |
| OLD | NEW |