| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/win/scoped_bstr.h" | 10 #include "base/win/scoped_bstr.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // Delete the manager and test that all 3 instances are deleted. | 154 // Delete the manager and test that all 3 instances are deleted. |
| 155 manager.reset(); | 155 manager.reset(); |
| 156 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 156 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 157 | 157 |
| 158 // Construct a manager again, and this time use the IAccessible interface | 158 // Construct a manager again, and this time use the IAccessible interface |
| 159 // to get new references to two of the three nodes in the tree. | 159 // to get new references to two of the three nodes in the tree. |
| 160 manager.reset(BrowserAccessibilityManager::Create( | 160 manager.reset(BrowserAccessibilityManager::Create( |
| 161 MakeAXTreeUpdate(root, button, checkbox), | 161 MakeAXTreeUpdate(root, button, checkbox), |
| 162 NULL, new CountedBrowserAccessibilityFactory())); | 162 NULL, new CountedBrowserAccessibilityFactory())); |
| 163 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); | 163 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
| 164 IAccessible* root_accessible = | 164 IAccessible* root_accessible = ToBrowserAccessibilityWin(manager->GetRoot()); |
| 165 manager->GetRoot()->ToBrowserAccessibilityWin(); | |
| 166 IDispatch* root_iaccessible = NULL; | 165 IDispatch* root_iaccessible = NULL; |
| 167 IDispatch* child1_iaccessible = NULL; | 166 IDispatch* child1_iaccessible = NULL; |
| 168 base::win::ScopedVariant childid_self(CHILDID_SELF); | 167 base::win::ScopedVariant childid_self(CHILDID_SELF); |
| 169 HRESULT hr = root_accessible->get_accChild(childid_self, &root_iaccessible); | 168 HRESULT hr = root_accessible->get_accChild(childid_self, &root_iaccessible); |
| 170 ASSERT_EQ(S_OK, hr); | 169 ASSERT_EQ(S_OK, hr); |
| 171 base::win::ScopedVariant one(1); | 170 base::win::ScopedVariant one(1); |
| 172 hr = root_accessible->get_accChild(one, &child1_iaccessible); | 171 hr = root_accessible->get_accChild(one, &child1_iaccessible); |
| 173 ASSERT_EQ(S_OK, hr); | 172 ASSERT_EQ(S_OK, hr); |
| 174 | 173 |
| 175 // Now delete the manager, and only one of the three nodes in the tree | 174 // Now delete the manager, and only one of the three nodes in the tree |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 CountedBrowserAccessibility::reset(); | 207 CountedBrowserAccessibility::reset(); |
| 209 scoped_ptr<BrowserAccessibilityManager> manager( | 208 scoped_ptr<BrowserAccessibilityManager> manager( |
| 210 BrowserAccessibilityManager::Create( | 209 BrowserAccessibilityManager::Create( |
| 211 MakeAXTreeUpdate(root, text), | 210 MakeAXTreeUpdate(root, text), |
| 212 NULL, new CountedBrowserAccessibilityFactory())); | 211 NULL, new CountedBrowserAccessibilityFactory())); |
| 213 | 212 |
| 214 // Query for the text IAccessible and verify that it returns "old text" as its | 213 // Query for the text IAccessible and verify that it returns "old text" as its |
| 215 // value. | 214 // value. |
| 216 base::win::ScopedVariant one(1); | 215 base::win::ScopedVariant one(1); |
| 217 base::win::ScopedComPtr<IDispatch> text_dispatch; | 216 base::win::ScopedComPtr<IDispatch> text_dispatch; |
| 218 HRESULT hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( | 217 HRESULT hr = ToBrowserAccessibilityWin(manager->GetRoot())->get_accChild( |
| 219 one, text_dispatch.Receive()); | 218 one, text_dispatch.Receive()); |
| 220 ASSERT_EQ(S_OK, hr); | 219 ASSERT_EQ(S_OK, hr); |
| 221 | 220 |
| 222 base::win::ScopedComPtr<IAccessible> text_accessible; | 221 base::win::ScopedComPtr<IAccessible> text_accessible; |
| 223 hr = text_dispatch.QueryInterface(text_accessible.Receive()); | 222 hr = text_dispatch.QueryInterface(text_accessible.Receive()); |
| 224 ASSERT_EQ(S_OK, hr); | 223 ASSERT_EQ(S_OK, hr); |
| 225 | 224 |
| 226 base::win::ScopedVariant childid_self(CHILDID_SELF); | 225 base::win::ScopedVariant childid_self(CHILDID_SELF); |
| 227 base::win::ScopedBstr name; | 226 base::win::ScopedBstr name; |
| 228 hr = text_accessible->get_accName(childid_self, name.Receive()); | 227 hr = text_accessible->get_accName(childid_self, name.Receive()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 242 AXEventNotificationDetails param; | 241 AXEventNotificationDetails param; |
| 243 param.event_type = ui::AX_EVENT_CHILDREN_CHANGED; | 242 param.event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
| 244 param.update.nodes.push_back(text2); | 243 param.update.nodes.push_back(text2); |
| 245 param.id = text2.id; | 244 param.id = text2.id; |
| 246 std::vector<AXEventNotificationDetails> events; | 245 std::vector<AXEventNotificationDetails> events; |
| 247 events.push_back(param); | 246 events.push_back(param); |
| 248 manager->OnAccessibilityEvents(events); | 247 manager->OnAccessibilityEvents(events); |
| 249 | 248 |
| 250 // Query for the text IAccessible and verify that it now returns "new text" | 249 // Query for the text IAccessible and verify that it now returns "new text" |
| 251 // as its value. | 250 // as its value. |
| 252 hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( | 251 hr = ToBrowserAccessibilityWin(manager->GetRoot())->get_accChild( |
| 253 one, text_dispatch.Receive()); | 252 one, text_dispatch.Receive()); |
| 254 ASSERT_EQ(S_OK, hr); | 253 ASSERT_EQ(S_OK, hr); |
| 255 | 254 |
| 256 hr = text_dispatch.QueryInterface(text_accessible.Receive()); | 255 hr = text_dispatch.QueryInterface(text_accessible.Receive()); |
| 257 ASSERT_EQ(S_OK, hr); | 256 ASSERT_EQ(S_OK, hr); |
| 258 | 257 |
| 259 hr = text_accessible->get_accName(childid_self, name.Receive()); | 258 hr = text_accessible->get_accName(childid_self, name.Receive()); |
| 260 ASSERT_EQ(S_OK, hr); | 259 ASSERT_EQ(S_OK, hr); |
| 261 EXPECT_EQ(L"new text", base::string16(name)); | 260 EXPECT_EQ(L"new text", base::string16(name)); |
| 262 | 261 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 388 |
| 390 CountedBrowserAccessibility::reset(); | 389 CountedBrowserAccessibility::reset(); |
| 391 scoped_ptr<BrowserAccessibilityManager> manager( | 390 scoped_ptr<BrowserAccessibilityManager> manager( |
| 392 BrowserAccessibilityManager::Create( | 391 BrowserAccessibilityManager::Create( |
| 393 MakeAXTreeUpdate(root, text_field, static_text1, inline_box1, | 392 MakeAXTreeUpdate(root, text_field, static_text1, inline_box1, |
| 394 line_break, static_text2, inline_box2), | 393 line_break, static_text2, inline_box2), |
| 395 nullptr, new CountedBrowserAccessibilityFactory())); | 394 nullptr, new CountedBrowserAccessibilityFactory())); |
| 396 ASSERT_EQ(7, CountedBrowserAccessibility::num_instances()); | 395 ASSERT_EQ(7, CountedBrowserAccessibility::num_instances()); |
| 397 | 396 |
| 398 BrowserAccessibilityWin* root_obj = | 397 BrowserAccessibilityWin* root_obj = |
| 399 manager->GetRoot()->ToBrowserAccessibilityWin(); | 398 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 400 ASSERT_NE(nullptr, root_obj); | 399 ASSERT_NE(nullptr, root_obj); |
| 401 ASSERT_EQ(1U, root_obj->PlatformChildCount()); | 400 ASSERT_EQ(1U, root_obj->PlatformChildCount()); |
| 402 | 401 |
| 403 BrowserAccessibilityWin* text_field_obj = | 402 BrowserAccessibilityWin* text_field_obj = |
| 404 root_obj->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 403 ToBrowserAccessibilityWin(root_obj->PlatformGetChild(0)); |
| 405 ASSERT_NE(nullptr, text_field_obj); | 404 ASSERT_NE(nullptr, text_field_obj); |
| 406 | 405 |
| 407 long text_len; | 406 long text_len; |
| 408 EXPECT_EQ(S_OK, text_field_obj->get_nCharacters(&text_len)); | 407 EXPECT_EQ(S_OK, text_field_obj->get_nCharacters(&text_len)); |
| 409 | 408 |
| 410 base::win::ScopedBstr text; | 409 base::win::ScopedBstr text; |
| 411 EXPECT_EQ(S_OK, text_field_obj->get_text(0, text_len, text.Receive())); | 410 EXPECT_EQ(S_OK, text_field_obj->get_text(0, text_len, text.Receive())); |
| 412 EXPECT_EQ(text_value, base::UTF16ToUTF8(base::string16(text))); | 411 EXPECT_EQ(text_value, base::UTF16ToUTF8(base::string16(text))); |
| 413 text.Reset(); | 412 text.Reset(); |
| 414 | 413 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 root.child_ids.push_back(text2.id); | 508 root.child_ids.push_back(text2.id); |
| 510 | 509 |
| 511 CountedBrowserAccessibility::reset(); | 510 CountedBrowserAccessibility::reset(); |
| 512 scoped_ptr<BrowserAccessibilityManager> manager( | 511 scoped_ptr<BrowserAccessibilityManager> manager( |
| 513 BrowserAccessibilityManager::Create( | 512 BrowserAccessibilityManager::Create( |
| 514 MakeAXTreeUpdate(root, text1, text2), nullptr, | 513 MakeAXTreeUpdate(root, text1, text2), nullptr, |
| 515 new CountedBrowserAccessibilityFactory())); | 514 new CountedBrowserAccessibilityFactory())); |
| 516 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); | 515 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
| 517 | 516 |
| 518 BrowserAccessibilityWin* root_obj = | 517 BrowserAccessibilityWin* root_obj = |
| 519 manager->GetRoot()->ToBrowserAccessibilityWin(); | 518 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 520 | 519 |
| 521 long text_len; | 520 long text_len; |
| 522 EXPECT_EQ(S_OK, root_obj->get_nCharacters(&text_len)); | 521 EXPECT_EQ(S_OK, root_obj->get_nCharacters(&text_len)); |
| 523 EXPECT_EQ(text_name_len, text_len); | 522 EXPECT_EQ(text_name_len, text_len); |
| 524 | 523 |
| 525 base::win::ScopedBstr text; | 524 base::win::ScopedBstr text; |
| 526 EXPECT_EQ(S_OK, root_obj->get_text(0, text_name_len, text.Receive())); | 525 EXPECT_EQ(S_OK, root_obj->get_text(0, text_name_len, text.Receive())); |
| 527 EXPECT_EQ(text1_name + text2_name, base::UTF16ToUTF8(base::string16(text))); | 526 EXPECT_EQ(text1_name + text2_name, base::UTF16ToUTF8(base::string16(text))); |
| 528 | 527 |
| 529 long hyperlink_count; | 528 long hyperlink_count; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 | 629 |
| 631 CountedBrowserAccessibility::reset(); | 630 CountedBrowserAccessibility::reset(); |
| 632 scoped_ptr<BrowserAccessibilityManager> manager( | 631 scoped_ptr<BrowserAccessibilityManager> manager( |
| 633 BrowserAccessibilityManager::Create( | 632 BrowserAccessibilityManager::Create( |
| 634 MakeAXTreeUpdate(root, text1, combo_box, text2, check_box, button, | 633 MakeAXTreeUpdate(root, text1, combo_box, text2, check_box, button, |
| 635 button_text, link, link_text), | 634 button_text, link, link_text), |
| 636 nullptr, new CountedBrowserAccessibilityFactory())); | 635 nullptr, new CountedBrowserAccessibilityFactory())); |
| 637 ASSERT_EQ(9, CountedBrowserAccessibility::num_instances()); | 636 ASSERT_EQ(9, CountedBrowserAccessibility::num_instances()); |
| 638 | 637 |
| 639 BrowserAccessibilityWin* root_obj = | 638 BrowserAccessibilityWin* root_obj = |
| 640 manager->GetRoot()->ToBrowserAccessibilityWin(); | 639 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 641 | 640 |
| 642 long text_len; | 641 long text_len; |
| 643 EXPECT_EQ(S_OK, root_obj->get_nCharacters(&text_len)); | 642 EXPECT_EQ(S_OK, root_obj->get_nCharacters(&text_len)); |
| 644 EXPECT_EQ(root_hypertext_len, text_len); | 643 EXPECT_EQ(root_hypertext_len, text_len); |
| 645 | 644 |
| 646 base::win::ScopedBstr text; | 645 base::win::ScopedBstr text; |
| 647 EXPECT_EQ(S_OK, root_obj->get_text(0, root_hypertext_len, text.Receive())); | 646 EXPECT_EQ(S_OK, root_obj->get_text(0, root_hypertext_len, text.Receive())); |
| 648 EXPECT_STREQ(root_hypertext.c_str(), text); | 647 EXPECT_STREQ(root_hypertext.c_str(), text); |
| 649 text.Reset(); | 648 text.Reset(); |
| 650 | 649 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 | 813 |
| 815 // Verify the root is as we expect by default. | 814 // Verify the root is as we expect by default. |
| 816 BrowserAccessibility* root = manager->GetRoot(); | 815 BrowserAccessibility* root = manager->GetRoot(); |
| 817 EXPECT_EQ(0, root->GetId()); | 816 EXPECT_EQ(0, root->GetId()); |
| 818 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->GetRole()); | 817 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->GetRole()); |
| 819 EXPECT_EQ(1 << ui::AX_STATE_BUSY | | 818 EXPECT_EQ(1 << ui::AX_STATE_BUSY | |
| 820 1 << ui::AX_STATE_READ_ONLY | | 819 1 << ui::AX_STATE_READ_ONLY | |
| 821 1 << ui::AX_STATE_ENABLED, | 820 1 << ui::AX_STATE_ENABLED, |
| 822 root->GetState()); | 821 root->GetState()); |
| 823 | 822 |
| 824 LONG unique_id_win = root->ToBrowserAccessibilityWin()->unique_id_win(); | 823 int32_t unique_id = ToBrowserAccessibilityWin(root)->unique_id(); |
| 825 ASSERT_EQ(root, manager->GetFromUniqueIdWin(unique_id_win)); | 824 ASSERT_EQ(root, BrowserAccessibility::GetFromUniqueID(unique_id)); |
| 826 } | 825 } |
| 827 | 826 |
| 828 TEST_F(BrowserAccessibilityTest, TestIA2Attributes) { | 827 TEST_F(BrowserAccessibilityTest, TestIA2Attributes) { |
| 829 ui::AXNodeData pseudo_before; | 828 ui::AXNodeData pseudo_before; |
| 830 pseudo_before.id = 2; | 829 pseudo_before.id = 2; |
| 831 pseudo_before.role = ui::AX_ROLE_DIV; | 830 pseudo_before.role = ui::AX_ROLE_DIV; |
| 832 pseudo_before.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "<pseudo:before>"); | 831 pseudo_before.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "<pseudo:before>"); |
| 833 pseudo_before.AddStringAttribute(ui::AX_ATTR_DISPLAY, "none"); | 832 pseudo_before.AddStringAttribute(ui::AX_ATTR_DISPLAY, "none"); |
| 834 | 833 |
| 835 ui::AXNodeData checkbox; | 834 ui::AXNodeData checkbox; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 848 | 847 |
| 849 CountedBrowserAccessibility::reset(); | 848 CountedBrowserAccessibility::reset(); |
| 850 scoped_ptr<BrowserAccessibilityManager> manager( | 849 scoped_ptr<BrowserAccessibilityManager> manager( |
| 851 BrowserAccessibilityManager::Create( | 850 BrowserAccessibilityManager::Create( |
| 852 MakeAXTreeUpdate(root, pseudo_before, checkbox), nullptr, | 851 MakeAXTreeUpdate(root, pseudo_before, checkbox), nullptr, |
| 853 new CountedBrowserAccessibilityFactory())); | 852 new CountedBrowserAccessibilityFactory())); |
| 854 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); | 853 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
| 855 | 854 |
| 856 ASSERT_NE(nullptr, manager->GetRoot()); | 855 ASSERT_NE(nullptr, manager->GetRoot()); |
| 857 BrowserAccessibilityWin* root_accessible = | 856 BrowserAccessibilityWin* root_accessible = |
| 858 manager->GetRoot()->ToBrowserAccessibilityWin(); | 857 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 859 ASSERT_NE(nullptr, root_accessible); | 858 ASSERT_NE(nullptr, root_accessible); |
| 860 ASSERT_EQ(2U, root_accessible->PlatformChildCount()); | 859 ASSERT_EQ(2U, root_accessible->PlatformChildCount()); |
| 861 | 860 |
| 862 BrowserAccessibilityWin* pseudo_accessible = | 861 BrowserAccessibilityWin* pseudo_accessible = |
| 863 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 862 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
| 864 ASSERT_NE(nullptr, pseudo_accessible); | 863 ASSERT_NE(nullptr, pseudo_accessible); |
| 865 | 864 |
| 866 base::win::ScopedBstr attributes; | 865 base::win::ScopedBstr attributes; |
| 867 HRESULT hr = pseudo_accessible->get_attributes(attributes.Receive()); | 866 HRESULT hr = pseudo_accessible->get_attributes(attributes.Receive()); |
| 868 EXPECT_EQ(S_OK, hr); | 867 EXPECT_EQ(S_OK, hr); |
| 869 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); | 868 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); |
| 870 std::wstring attributes_str(attributes, attributes.Length()); | 869 std::wstring attributes_str(attributes, attributes.Length()); |
| 871 EXPECT_EQ(L"display:none;tag:<pseudo\\:before>;", attributes_str); | 870 EXPECT_EQ(L"display:none;tag:<pseudo\\:before>;", attributes_str); |
| 872 | 871 |
| 873 BrowserAccessibilityWin* checkbox_accessible = | 872 BrowserAccessibilityWin* checkbox_accessible = |
| 874 root_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); | 873 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(1)); |
| 875 ASSERT_NE(nullptr, checkbox_accessible); | 874 ASSERT_NE(nullptr, checkbox_accessible); |
| 876 | 875 |
| 877 attributes.Reset(); | 876 attributes.Reset(); |
| 878 hr = checkbox_accessible->get_attributes(attributes.Receive()); | 877 hr = checkbox_accessible->get_attributes(attributes.Receive()); |
| 879 EXPECT_EQ(S_OK, hr); | 878 EXPECT_EQ(S_OK, hr); |
| 880 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); | 879 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); |
| 881 attributes_str = std::wstring(attributes, attributes.Length()); | 880 attributes_str = std::wstring(attributes, attributes.Length()); |
| 882 EXPECT_EQ(L"checkable:true;", attributes_str); | 881 EXPECT_EQ(L"checkable:true;", attributes_str); |
| 883 | 882 |
| 884 manager.reset(); | 883 manager.reset(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 scoped_ptr<BrowserAccessibilityManager> manager( | 954 scoped_ptr<BrowserAccessibilityManager> manager( |
| 956 BrowserAccessibilityManager::Create( | 955 BrowserAccessibilityManager::Create( |
| 957 MakeAXTreeUpdate(root, combo_box, combo_box_text, search_box, | 956 MakeAXTreeUpdate(root, combo_box, combo_box_text, search_box, |
| 958 search_box_text, new_line, text_field, link, | 957 search_box_text, new_line, text_field, link, |
| 959 link_text, slider, slider_text), | 958 link_text, slider, slider_text), |
| 960 nullptr, new CountedBrowserAccessibilityFactory())); | 959 nullptr, new CountedBrowserAccessibilityFactory())); |
| 961 ASSERT_EQ(11, CountedBrowserAccessibility::num_instances()); | 960 ASSERT_EQ(11, CountedBrowserAccessibility::num_instances()); |
| 962 | 961 |
| 963 ASSERT_NE(nullptr, manager->GetRoot()); | 962 ASSERT_NE(nullptr, manager->GetRoot()); |
| 964 BrowserAccessibilityWin* root_accessible = | 963 BrowserAccessibilityWin* root_accessible = |
| 965 manager->GetRoot()->ToBrowserAccessibilityWin(); | 964 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 966 ASSERT_NE(nullptr, root_accessible); | 965 ASSERT_NE(nullptr, root_accessible); |
| 967 ASSERT_EQ(5U, root_accessible->PlatformChildCount()); | 966 ASSERT_EQ(5U, root_accessible->PlatformChildCount()); |
| 968 | 967 |
| 969 BrowserAccessibilityWin* combo_box_accessible = | 968 BrowserAccessibilityWin* combo_box_accessible = |
| 970 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 969 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
| 971 ASSERT_NE(nullptr, combo_box_accessible); | 970 ASSERT_NE(nullptr, combo_box_accessible); |
| 972 manager->SetFocusLocallyForTesting(combo_box_accessible); | 971 manager->SetFocusLocallyForTesting(combo_box_accessible); |
| 973 ASSERT_EQ(combo_box_accessible, | 972 ASSERT_EQ(combo_box_accessible, |
| 974 manager->GetFocus()->ToBrowserAccessibilityWin()); | 973 ToBrowserAccessibilityWin(manager->GetFocus())); |
| 975 BrowserAccessibilityWin* search_box_accessible = | 974 BrowserAccessibilityWin* search_box_accessible = |
| 976 root_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); | 975 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(1)); |
| 977 ASSERT_NE(nullptr, search_box_accessible); | 976 ASSERT_NE(nullptr, search_box_accessible); |
| 978 BrowserAccessibilityWin* text_field_accessible = | 977 BrowserAccessibilityWin* text_field_accessible = |
| 979 root_accessible->PlatformGetChild(2)->ToBrowserAccessibilityWin(); | 978 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(2)); |
| 980 ASSERT_NE(nullptr, text_field_accessible); | 979 ASSERT_NE(nullptr, text_field_accessible); |
| 981 BrowserAccessibilityWin* link_accessible = | 980 BrowserAccessibilityWin* link_accessible = |
| 982 root_accessible->PlatformGetChild(3)->ToBrowserAccessibilityWin(); | 981 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(3)); |
| 983 ASSERT_NE(nullptr, link_accessible); | 982 ASSERT_NE(nullptr, link_accessible); |
| 984 BrowserAccessibilityWin* slider_accessible = | 983 BrowserAccessibilityWin* slider_accessible = |
| 985 root_accessible->PlatformGetChild(4)->ToBrowserAccessibilityWin(); | 984 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(4)); |
| 986 ASSERT_NE(nullptr, slider_accessible); | 985 ASSERT_NE(nullptr, slider_accessible); |
| 987 | 986 |
| 988 base::win::ScopedVariant childid_self(CHILDID_SELF); | 987 base::win::ScopedVariant childid_self(CHILDID_SELF); |
| 989 base::win::ScopedVariant childid_slider(5); | 988 base::win::ScopedVariant childid_slider(5); |
| 990 base::win::ScopedBstr value; | 989 base::win::ScopedBstr value; |
| 991 | 990 |
| 992 HRESULT hr = | 991 HRESULT hr = |
| 993 combo_box_accessible->get_accValue(childid_self, value.Receive()); | 992 combo_box_accessible->get_accValue(childid_self, value.Receive()); |
| 994 EXPECT_EQ(S_OK, hr); | 993 EXPECT_EQ(S_OK, hr); |
| 995 EXPECT_STREQ(L"Combo box text", value); | 994 EXPECT_STREQ(L"Combo box text", value); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 scoped_ptr<BrowserAccessibilityManager> manager( | 1116 scoped_ptr<BrowserAccessibilityManager> manager( |
| 1118 BrowserAccessibilityManager::Create( | 1117 BrowserAccessibilityManager::Create( |
| 1119 MakeAXTreeUpdate(root, textarea, textarea_div, textarea_text, | 1118 MakeAXTreeUpdate(root, textarea, textarea_div, textarea_text, |
| 1120 textarea_line1, textarea_line2, text_field, | 1119 textarea_line1, textarea_line2, text_field, |
| 1121 text_field_div, text_field_text, text_field_line), | 1120 text_field_div, text_field_text, text_field_line), |
| 1122 nullptr, new CountedBrowserAccessibilityFactory())); | 1121 nullptr, new CountedBrowserAccessibilityFactory())); |
| 1123 ASSERT_EQ(10, CountedBrowserAccessibility::num_instances()); | 1122 ASSERT_EQ(10, CountedBrowserAccessibility::num_instances()); |
| 1124 | 1123 |
| 1125 ASSERT_NE(nullptr, manager->GetRoot()); | 1124 ASSERT_NE(nullptr, manager->GetRoot()); |
| 1126 BrowserAccessibilityWin* root_accessible = | 1125 BrowserAccessibilityWin* root_accessible = |
| 1127 manager->GetRoot()->ToBrowserAccessibilityWin(); | 1126 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 1128 ASSERT_NE(nullptr, root_accessible); | 1127 ASSERT_NE(nullptr, root_accessible); |
| 1129 ASSERT_EQ(2U, root_accessible->PlatformChildCount()); | 1128 ASSERT_EQ(2U, root_accessible->PlatformChildCount()); |
| 1130 | 1129 |
| 1131 BrowserAccessibilityWin* textarea_accessible = | 1130 BrowserAccessibilityWin* textarea_accessible = |
| 1132 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1131 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
| 1133 ASSERT_NE(nullptr, textarea_accessible); | 1132 ASSERT_NE(nullptr, textarea_accessible); |
| 1134 BrowserAccessibilityWin* text_field_accessible = | 1133 BrowserAccessibilityWin* text_field_accessible = |
| 1135 root_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); | 1134 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(1)); |
| 1136 ASSERT_NE(nullptr, text_field_accessible); | 1135 ASSERT_NE(nullptr, text_field_accessible); |
| 1137 | 1136 |
| 1138 base::win::ScopedComPtr<IAccessibleText> textarea_object; | 1137 base::win::ScopedComPtr<IAccessibleText> textarea_object; |
| 1139 EXPECT_HRESULT_SUCCEEDED(textarea_accessible->QueryInterface( | 1138 EXPECT_HRESULT_SUCCEEDED(textarea_accessible->QueryInterface( |
| 1140 IID_IAccessibleText, | 1139 IID_IAccessibleText, |
| 1141 reinterpret_cast<void**>(textarea_object.Receive()))); | 1140 reinterpret_cast<void**>(textarea_object.Receive()))); |
| 1142 base::win::ScopedComPtr<IAccessibleText> text_field_object; | 1141 base::win::ScopedComPtr<IAccessibleText> text_field_object; |
| 1143 EXPECT_HRESULT_SUCCEEDED(text_field_accessible->QueryInterface( | 1142 EXPECT_HRESULT_SUCCEEDED(text_field_accessible->QueryInterface( |
| 1144 IID_IAccessibleText, | 1143 IID_IAccessibleText, |
| 1145 reinterpret_cast<void**>(text_field_object.Receive()))); | 1144 reinterpret_cast<void**>(text_field_object.Receive()))); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 | 1215 |
| 1217 CountedBrowserAccessibility::reset(); | 1216 CountedBrowserAccessibility::reset(); |
| 1218 scoped_ptr<BrowserAccessibilityManager> manager( | 1217 scoped_ptr<BrowserAccessibilityManager> manager( |
| 1219 BrowserAccessibilityManager::Create( | 1218 BrowserAccessibilityManager::Create( |
| 1220 MakeAXTreeUpdate(root, combo_box, text_field), | 1219 MakeAXTreeUpdate(root, combo_box, text_field), |
| 1221 nullptr, new CountedBrowserAccessibilityFactory())); | 1220 nullptr, new CountedBrowserAccessibilityFactory())); |
| 1222 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); | 1221 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
| 1223 | 1222 |
| 1224 ASSERT_NE(nullptr, manager->GetRoot()); | 1223 ASSERT_NE(nullptr, manager->GetRoot()); |
| 1225 BrowserAccessibilityWin* root_accessible = | 1224 BrowserAccessibilityWin* root_accessible = |
| 1226 manager->GetRoot()->ToBrowserAccessibilityWin(); | 1225 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 1227 ASSERT_NE(nullptr, root_accessible); | 1226 ASSERT_NE(nullptr, root_accessible); |
| 1228 ASSERT_EQ(2U, root_accessible->PlatformChildCount()); | 1227 ASSERT_EQ(2U, root_accessible->PlatformChildCount()); |
| 1229 | 1228 |
| 1230 BrowserAccessibilityWin* combo_box_accessible = | 1229 BrowserAccessibilityWin* combo_box_accessible = |
| 1231 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1230 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
| 1232 ASSERT_NE(nullptr, combo_box_accessible); | 1231 ASSERT_NE(nullptr, combo_box_accessible); |
| 1233 manager->SetFocusLocallyForTesting(combo_box_accessible); | 1232 manager->SetFocusLocallyForTesting(combo_box_accessible); |
| 1234 ASSERT_EQ(combo_box_accessible, | 1233 ASSERT_EQ(combo_box_accessible, |
| 1235 manager->GetFocus()->ToBrowserAccessibilityWin()); | 1234 ToBrowserAccessibilityWin(manager->GetFocus())); |
| 1236 BrowserAccessibilityWin* text_field_accessible = | 1235 BrowserAccessibilityWin* text_field_accessible = |
| 1237 root_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); | 1236 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(1)); |
| 1238 ASSERT_NE(nullptr, text_field_accessible); | 1237 ASSERT_NE(nullptr, text_field_accessible); |
| 1239 | 1238 |
| 1240 // -2 is never a valid offset. | 1239 // -2 is never a valid offset. |
| 1241 LONG caret_offset = -2; | 1240 LONG caret_offset = -2; |
| 1242 LONG n_selections = -2; | 1241 LONG n_selections = -2; |
| 1243 LONG selection_start = -2; | 1242 LONG selection_start = -2; |
| 1244 LONG selection_end = -2; | 1243 LONG selection_end = -2; |
| 1245 | 1244 |
| 1246 // Test get_caretOffset. | 1245 // Test get_caretOffset. |
| 1247 HRESULT hr = combo_box_accessible->get_caretOffset(&caret_offset); | 1246 HRESULT hr = combo_box_accessible->get_caretOffset(&caret_offset); |
| 1248 EXPECT_EQ(S_OK, hr); | 1247 EXPECT_EQ(S_OK, hr); |
| 1249 EXPECT_EQ(1L, caret_offset); | 1248 EXPECT_EQ(1L, caret_offset); |
| 1250 // The caret should be at the end of the selection. | 1249 // The caret should be at the end of the selection. |
| 1251 hr = text_field_accessible->get_caretOffset(&caret_offset); | 1250 hr = text_field_accessible->get_caretOffset(&caret_offset); |
| 1252 EXPECT_EQ(S_OK, hr); | 1251 EXPECT_EQ(S_OK, hr); |
| 1253 EXPECT_EQ(2L, caret_offset); | 1252 EXPECT_EQ(2L, caret_offset); |
| 1254 | 1253 |
| 1255 // Move the focus to the text field. | 1254 // Move the focus to the text field. |
| 1256 manager->SetFocusLocallyForTesting(text_field_accessible); | 1255 manager->SetFocusLocallyForTesting(text_field_accessible); |
| 1257 ASSERT_EQ(text_field_accessible, | 1256 ASSERT_EQ(text_field_accessible, |
| 1258 manager->GetFocus()->ToBrowserAccessibilityWin()); | 1257 ToBrowserAccessibilityWin(manager->GetFocus())); |
| 1259 | 1258 |
| 1260 // The caret should not have moved. | 1259 // The caret should not have moved. |
| 1261 hr = text_field_accessible->get_caretOffset(&caret_offset); | 1260 hr = text_field_accessible->get_caretOffset(&caret_offset); |
| 1262 EXPECT_EQ(S_OK, hr); | 1261 EXPECT_EQ(S_OK, hr); |
| 1263 EXPECT_EQ(2L, caret_offset); | 1262 EXPECT_EQ(2L, caret_offset); |
| 1264 | 1263 |
| 1265 // Test get_nSelections. | 1264 // Test get_nSelections. |
| 1266 hr = combo_box_accessible->get_nSelections(&n_selections); | 1265 hr = combo_box_accessible->get_nSelections(&n_selections); |
| 1267 EXPECT_EQ(S_OK, hr); | 1266 EXPECT_EQ(S_OK, hr); |
| 1268 EXPECT_EQ(0L, n_selections); | 1267 EXPECT_EQ(0L, n_selections); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 | 1335 |
| 1337 CountedBrowserAccessibility::reset(); | 1336 CountedBrowserAccessibility::reset(); |
| 1338 scoped_ptr<BrowserAccessibilityManager> manager( | 1337 scoped_ptr<BrowserAccessibilityManager> manager( |
| 1339 BrowserAccessibilityManager::Create( | 1338 BrowserAccessibilityManager::Create( |
| 1340 update, | 1339 update, |
| 1341 nullptr, new CountedBrowserAccessibilityFactory())); | 1340 nullptr, new CountedBrowserAccessibilityFactory())); |
| 1342 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); | 1341 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); |
| 1343 | 1342 |
| 1344 ASSERT_NE(nullptr, manager->GetRoot()); | 1343 ASSERT_NE(nullptr, manager->GetRoot()); |
| 1345 BrowserAccessibilityWin* root_accessible = | 1344 BrowserAccessibilityWin* root_accessible = |
| 1346 manager->GetRoot()->ToBrowserAccessibilityWin(); | 1345 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 1347 ASSERT_NE(nullptr, root_accessible); | 1346 ASSERT_NE(nullptr, root_accessible); |
| 1348 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); | 1347 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); |
| 1349 | 1348 |
| 1350 BrowserAccessibilityWin* div_editable_accessible = | 1349 BrowserAccessibilityWin* div_editable_accessible = |
| 1351 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1350 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
| 1352 ASSERT_NE(nullptr, div_editable_accessible); | 1351 ASSERT_NE(nullptr, div_editable_accessible); |
| 1353 ASSERT_EQ(2U, div_editable_accessible->PlatformChildCount()); | 1352 ASSERT_EQ(2U, div_editable_accessible->PlatformChildCount()); |
| 1354 | 1353 |
| 1355 // -2 is never a valid offset. | 1354 // -2 is never a valid offset. |
| 1356 LONG caret_offset = -2; | 1355 LONG caret_offset = -2; |
| 1357 LONG n_selections = -2; | 1356 LONG n_selections = -2; |
| 1358 | 1357 |
| 1359 // No selection should be present. | 1358 // No selection should be present. |
| 1360 HRESULT hr = div_editable_accessible->get_nSelections(&n_selections); | 1359 HRESULT hr = div_editable_accessible->get_nSelections(&n_selections); |
| 1361 EXPECT_EQ(S_OK, hr); | 1360 EXPECT_EQ(S_OK, hr); |
| 1362 EXPECT_EQ(0L, n_selections); | 1361 EXPECT_EQ(0L, n_selections); |
| 1363 | 1362 |
| 1364 // The caret should be on the embedded object character. | 1363 // The caret should be on the embedded object character. |
| 1365 hr = div_editable_accessible->get_caretOffset(&caret_offset); | 1364 hr = div_editable_accessible->get_caretOffset(&caret_offset); |
| 1366 EXPECT_EQ(S_OK, hr); | 1365 EXPECT_EQ(S_OK, hr); |
| 1367 EXPECT_EQ(6L, caret_offset); | 1366 EXPECT_EQ(6L, caret_offset); |
| 1368 | 1367 |
| 1369 // Move the focus to the content editable. | 1368 // Move the focus to the content editable. |
| 1370 manager->SetFocusLocallyForTesting(div_editable_accessible); | 1369 manager->SetFocusLocallyForTesting(div_editable_accessible); |
| 1371 ASSERT_EQ(div_editable_accessible, | 1370 ASSERT_EQ(div_editable_accessible, |
| 1372 manager->GetFocus()->ToBrowserAccessibilityWin()); | 1371 ToBrowserAccessibilityWin(manager->GetFocus())); |
| 1373 | 1372 |
| 1374 BrowserAccessibilityWin* text_accessible = | 1373 BrowserAccessibilityWin* text_accessible = |
| 1375 div_editable_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1374 ToBrowserAccessibilityWin(div_editable_accessible->PlatformGetChild(0)); |
| 1376 ASSERT_NE(nullptr, text_accessible); | 1375 ASSERT_NE(nullptr, text_accessible); |
| 1377 BrowserAccessibilityWin* link_accessible = | 1376 BrowserAccessibilityWin* link_accessible = |
| 1378 div_editable_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); | 1377 ToBrowserAccessibilityWin(div_editable_accessible->PlatformGetChild(1)); |
| 1379 ASSERT_NE(nullptr, link_accessible); | 1378 ASSERT_NE(nullptr, link_accessible); |
| 1380 ASSERT_EQ(1U, link_accessible->PlatformChildCount()); | 1379 ASSERT_EQ(1U, link_accessible->PlatformChildCount()); |
| 1381 | 1380 |
| 1382 BrowserAccessibilityWin* link_text_accessible = | 1381 BrowserAccessibilityWin* link_text_accessible = |
| 1383 link_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1382 ToBrowserAccessibilityWin(link_accessible->PlatformGetChild(0)); |
| 1384 ASSERT_NE(nullptr, link_text_accessible); | 1383 ASSERT_NE(nullptr, link_text_accessible); |
| 1385 | 1384 |
| 1386 // The caret should not have moved. | 1385 // The caret should not have moved. |
| 1387 hr = div_editable_accessible->get_nSelections(&n_selections); | 1386 hr = div_editable_accessible->get_nSelections(&n_selections); |
| 1388 EXPECT_EQ(S_OK, hr); | 1387 EXPECT_EQ(S_OK, hr); |
| 1389 EXPECT_EQ(0L, n_selections); | 1388 EXPECT_EQ(0L, n_selections); |
| 1390 hr = div_editable_accessible->get_caretOffset(&caret_offset); | 1389 hr = div_editable_accessible->get_caretOffset(&caret_offset); |
| 1391 EXPECT_EQ(S_OK, hr); | 1390 EXPECT_EQ(S_OK, hr); |
| 1392 EXPECT_EQ(6L, caret_offset); | 1391 EXPECT_EQ(6L, caret_offset); |
| 1393 | 1392 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 | 1453 |
| 1455 CountedBrowserAccessibility::reset(); | 1454 CountedBrowserAccessibility::reset(); |
| 1456 scoped_ptr<BrowserAccessibilityManager> manager( | 1455 scoped_ptr<BrowserAccessibilityManager> manager( |
| 1457 BrowserAccessibilityManager::Create( | 1456 BrowserAccessibilityManager::Create( |
| 1458 update, | 1457 update, |
| 1459 nullptr, new CountedBrowserAccessibilityFactory())); | 1458 nullptr, new CountedBrowserAccessibilityFactory())); |
| 1460 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); | 1459 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); |
| 1461 | 1460 |
| 1462 ASSERT_NE(nullptr, manager->GetRoot()); | 1461 ASSERT_NE(nullptr, manager->GetRoot()); |
| 1463 BrowserAccessibilityWin* root_accessible = | 1462 BrowserAccessibilityWin* root_accessible = |
| 1464 manager->GetRoot()->ToBrowserAccessibilityWin(); | 1463 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 1465 ASSERT_NE(nullptr, root_accessible); | 1464 ASSERT_NE(nullptr, root_accessible); |
| 1466 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); | 1465 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); |
| 1467 | 1466 |
| 1468 BrowserAccessibilityWin* div_editable_accessible = | 1467 BrowserAccessibilityWin* div_editable_accessible = |
| 1469 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1468 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
| 1470 ASSERT_NE(nullptr, div_editable_accessible); | 1469 ASSERT_NE(nullptr, div_editable_accessible); |
| 1471 ASSERT_EQ(2U, div_editable_accessible->PlatformChildCount()); | 1470 ASSERT_EQ(2U, div_editable_accessible->PlatformChildCount()); |
| 1472 | 1471 |
| 1473 // -2 is never a valid offset. | 1472 // -2 is never a valid offset. |
| 1474 LONG caret_offset = -2; | 1473 LONG caret_offset = -2; |
| 1475 LONG n_selections = -2; | 1474 LONG n_selections = -2; |
| 1476 LONG selection_start = -2; | 1475 LONG selection_start = -2; |
| 1477 LONG selection_end = -2; | 1476 LONG selection_end = -2; |
| 1478 | 1477 |
| 1479 BrowserAccessibilityWin* text_accessible = | 1478 BrowserAccessibilityWin* text_accessible = |
| 1480 div_editable_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1479 ToBrowserAccessibilityWin(div_editable_accessible->PlatformGetChild(0)); |
| 1481 ASSERT_NE(nullptr, text_accessible); | 1480 ASSERT_NE(nullptr, text_accessible); |
| 1482 BrowserAccessibilityWin* link_accessible = | 1481 BrowserAccessibilityWin* link_accessible = |
| 1483 div_editable_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); | 1482 ToBrowserAccessibilityWin(div_editable_accessible->PlatformGetChild(1)); |
| 1484 ASSERT_NE(nullptr, link_accessible); | 1483 ASSERT_NE(nullptr, link_accessible); |
| 1485 ASSERT_EQ(1U, link_accessible->PlatformChildCount()); | 1484 ASSERT_EQ(1U, link_accessible->PlatformChildCount()); |
| 1486 | 1485 |
| 1487 BrowserAccessibilityWin* link_text_accessible = | 1486 BrowserAccessibilityWin* link_text_accessible = |
| 1488 link_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1487 ToBrowserAccessibilityWin(link_accessible->PlatformGetChild(0)); |
| 1489 ASSERT_NE(nullptr, link_text_accessible); | 1488 ASSERT_NE(nullptr, link_text_accessible); |
| 1490 | 1489 |
| 1491 // get_nSelections should work on all objects. | 1490 // get_nSelections should work on all objects. |
| 1492 HRESULT hr = div_editable_accessible->get_nSelections(&n_selections); | 1491 HRESULT hr = div_editable_accessible->get_nSelections(&n_selections); |
| 1493 EXPECT_EQ(S_OK, hr); | 1492 EXPECT_EQ(S_OK, hr); |
| 1494 EXPECT_EQ(1L, n_selections); | 1493 EXPECT_EQ(1L, n_selections); |
| 1495 hr = text_accessible->get_nSelections(&n_selections); | 1494 hr = text_accessible->get_nSelections(&n_selections); |
| 1496 EXPECT_EQ(S_OK, hr); | 1495 EXPECT_EQ(S_OK, hr); |
| 1497 EXPECT_EQ(1L, n_selections); | 1496 EXPECT_EQ(1L, n_selections); |
| 1498 hr = link_accessible->get_nSelections(&n_selections); | 1497 hr = link_accessible->get_nSelections(&n_selections); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1528 EXPECT_EQ(4L, selection_end); | 1527 EXPECT_EQ(4L, selection_end); |
| 1529 | 1528 |
| 1530 // The caret should be at the focus (the end) of the selection. | 1529 // The caret should be at the focus (the end) of the selection. |
| 1531 hr = div_editable_accessible->get_caretOffset(&caret_offset); | 1530 hr = div_editable_accessible->get_caretOffset(&caret_offset); |
| 1532 EXPECT_EQ(S_OK, hr); | 1531 EXPECT_EQ(S_OK, hr); |
| 1533 EXPECT_EQ(7L, caret_offset); | 1532 EXPECT_EQ(7L, caret_offset); |
| 1534 | 1533 |
| 1535 // Move the focus to the content editable. | 1534 // Move the focus to the content editable. |
| 1536 manager->SetFocusLocallyForTesting(div_editable_accessible); | 1535 manager->SetFocusLocallyForTesting(div_editable_accessible); |
| 1537 ASSERT_EQ(div_editable_accessible, | 1536 ASSERT_EQ(div_editable_accessible, |
| 1538 manager->GetFocus()->ToBrowserAccessibilityWin()); | 1537 ToBrowserAccessibilityWin(manager->GetFocus())); |
| 1539 | 1538 |
| 1540 // The caret should not have moved. | 1539 // The caret should not have moved. |
| 1541 hr = div_editable_accessible->get_caretOffset(&caret_offset); | 1540 hr = div_editable_accessible->get_caretOffset(&caret_offset); |
| 1542 EXPECT_EQ(S_OK, hr); | 1541 EXPECT_EQ(S_OK, hr); |
| 1543 EXPECT_EQ(7L, caret_offset); | 1542 EXPECT_EQ(7L, caret_offset); |
| 1544 | 1543 |
| 1545 // The caret offset should reflect the position of the selection's focus in | 1544 // The caret offset should reflect the position of the selection's focus in |
| 1546 // any given object. | 1545 // any given object. |
| 1547 hr = link_accessible->get_caretOffset(&caret_offset); | 1546 hr = link_accessible->get_caretOffset(&caret_offset); |
| 1548 EXPECT_EQ(S_OK, hr); | 1547 EXPECT_EQ(S_OK, hr); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 | 1589 |
| 1591 CountedBrowserAccessibility::reset(); | 1590 CountedBrowserAccessibility::reset(); |
| 1592 scoped_ptr<BrowserAccessibilityManager> manager( | 1591 scoped_ptr<BrowserAccessibilityManager> manager( |
| 1593 BrowserAccessibilityManager::Create( | 1592 BrowserAccessibilityManager::Create( |
| 1594 MakeAXTreeUpdate(root, div, link, text), nullptr, | 1593 MakeAXTreeUpdate(root, div, link, text), nullptr, |
| 1595 new CountedBrowserAccessibilityFactory())); | 1594 new CountedBrowserAccessibilityFactory())); |
| 1596 ASSERT_EQ(4, CountedBrowserAccessibility::num_instances()); | 1595 ASSERT_EQ(4, CountedBrowserAccessibility::num_instances()); |
| 1597 | 1596 |
| 1598 ASSERT_NE(nullptr, manager->GetRoot()); | 1597 ASSERT_NE(nullptr, manager->GetRoot()); |
| 1599 BrowserAccessibilityWin* root_accessible = | 1598 BrowserAccessibilityWin* root_accessible = |
| 1600 manager->GetRoot()->ToBrowserAccessibilityWin(); | 1599 ToBrowserAccessibilityWin(manager->GetRoot()); |
| 1601 ASSERT_NE(nullptr, root_accessible); | 1600 ASSERT_NE(nullptr, root_accessible); |
| 1602 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); | 1601 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); |
| 1603 | 1602 |
| 1604 BrowserAccessibilityWin* div_accessible = | 1603 BrowserAccessibilityWin* div_accessible = |
| 1605 root_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1604 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
| 1606 ASSERT_NE(nullptr, div_accessible); | 1605 ASSERT_NE(nullptr, div_accessible); |
| 1607 ASSERT_EQ(2U, div_accessible->PlatformChildCount()); | 1606 ASSERT_EQ(2U, div_accessible->PlatformChildCount()); |
| 1608 | 1607 |
| 1609 BrowserAccessibilityWin* text_accessible = | 1608 BrowserAccessibilityWin* text_accessible = |
| 1610 div_accessible->PlatformGetChild(0)->ToBrowserAccessibilityWin(); | 1609 ToBrowserAccessibilityWin(div_accessible->PlatformGetChild(0)); |
| 1611 ASSERT_NE(nullptr, text_accessible); | 1610 ASSERT_NE(nullptr, text_accessible); |
| 1612 BrowserAccessibilityWin* link_accessible = | 1611 BrowserAccessibilityWin* link_accessible = |
| 1613 div_accessible->PlatformGetChild(1)->ToBrowserAccessibilityWin(); | 1612 ToBrowserAccessibilityWin(div_accessible->PlatformGetChild(1)); |
| 1614 ASSERT_NE(nullptr, link_accessible); | 1613 ASSERT_NE(nullptr, link_accessible); |
| 1615 | 1614 |
| 1616 // -1 is never a valid value. | 1615 // -1 is never a valid value. |
| 1617 LONG n_actions = -1; | 1616 LONG n_actions = -1; |
| 1618 LONG start_index = -1; | 1617 LONG start_index = -1; |
| 1619 LONG end_index = -1; | 1618 LONG end_index = -1; |
| 1620 | 1619 |
| 1621 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; | 1620 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; |
| 1622 base::win::ScopedVariant anchor; | 1621 base::win::ScopedVariant anchor; |
| 1623 base::win::ScopedVariant anchor_target; | 1622 base::win::ScopedVariant anchor_target; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 child_node.id = 2; | 1809 child_node.id = 2; |
| 1811 root_node.child_ids.push_back(2); | 1810 root_node.child_ids.push_back(2); |
| 1812 | 1811 |
| 1813 scoped_ptr<BrowserAccessibilityManagerWin> manager( | 1812 scoped_ptr<BrowserAccessibilityManagerWin> manager( |
| 1814 new BrowserAccessibilityManagerWin( | 1813 new BrowserAccessibilityManagerWin( |
| 1815 MakeAXTreeUpdate(root_node, child_node), | 1814 MakeAXTreeUpdate(root_node, child_node), |
| 1816 nullptr, | 1815 nullptr, |
| 1817 new CountedBrowserAccessibilityFactory())); | 1816 new CountedBrowserAccessibilityFactory())); |
| 1818 | 1817 |
| 1819 BrowserAccessibility* root = manager->GetRoot(); | 1818 BrowserAccessibility* root = manager->GetRoot(); |
| 1820 LONG root_unique_id = root->ToBrowserAccessibilityWin()->unique_id_win(); | 1819 int32_t root_unique_id = root->unique_id(); |
| 1821 BrowserAccessibility* child = root->PlatformGetChild(0); | 1820 BrowserAccessibility* child = root->PlatformGetChild(0); |
| 1822 LONG child_unique_id = child->ToBrowserAccessibilityWin()->unique_id_win(); | 1821 int32_t child_unique_id = child->unique_id(); |
| 1823 | 1822 |
| 1824 // Now destroy that original tree and create a new tree. | 1823 // Now destroy that original tree and create a new tree. |
| 1825 manager.reset( | 1824 manager.reset( |
| 1826 new BrowserAccessibilityManagerWin( | 1825 new BrowserAccessibilityManagerWin( |
| 1827 MakeAXTreeUpdate(root_node, child_node), | 1826 MakeAXTreeUpdate(root_node, child_node), |
| 1828 nullptr, | 1827 nullptr, |
| 1829 new CountedBrowserAccessibilityFactory())); | 1828 new CountedBrowserAccessibilityFactory())); |
| 1830 root = manager->GetRoot(); | 1829 root = manager->GetRoot(); |
| 1831 LONG root_unique_id_2 = root->ToBrowserAccessibilityWin()->unique_id_win(); | 1830 int32_t root_unique_id_2 = root->unique_id(); |
| 1832 child = root->PlatformGetChild(0); | 1831 child = root->PlatformGetChild(0); |
| 1833 LONG child_unique_id_2 = child->ToBrowserAccessibilityWin()->unique_id_win(); | 1832 int32_t child_unique_id_2 = child->unique_id(); |
| 1834 | 1833 |
| 1835 // The nodes in the new tree should not have the same ids. | 1834 // The nodes in the new tree should not have the same ids. |
| 1836 EXPECT_NE(root_unique_id, root_unique_id_2); | 1835 EXPECT_NE(root_unique_id, root_unique_id_2); |
| 1837 EXPECT_NE(child_unique_id, child_unique_id_2); | 1836 EXPECT_NE(child_unique_id, child_unique_id_2); |
| 1838 | 1837 |
| 1839 // Trying to access the unique IDs of the old, deleted objects should fail. | 1838 // Trying to access the unique IDs of the old, deleted objects should fail. |
| 1840 base::win::ScopedVariant old_root_variant(root_unique_id); | 1839 base::win::ScopedVariant old_root_variant(-root_unique_id); |
| 1841 base::win::ScopedComPtr<IDispatch> old_root_dispatch; | 1840 base::win::ScopedComPtr<IDispatch> old_root_dispatch; |
| 1842 HRESULT hr = root->ToBrowserAccessibilityWin()->get_accChild( | 1841 HRESULT hr = ToBrowserAccessibilityWin(root)->get_accChild( |
| 1843 old_root_variant, old_root_dispatch.Receive()); | 1842 old_root_variant, old_root_dispatch.Receive()); |
| 1844 EXPECT_EQ(E_INVALIDARG, hr); | 1843 EXPECT_EQ(E_INVALIDARG, hr); |
| 1845 | 1844 |
| 1846 base::win::ScopedVariant old_child_variant(child_unique_id); | 1845 base::win::ScopedVariant old_child_variant(-child_unique_id); |
| 1847 base::win::ScopedComPtr<IDispatch> old_child_dispatch; | 1846 base::win::ScopedComPtr<IDispatch> old_child_dispatch; |
| 1848 hr = root->ToBrowserAccessibilityWin()->get_accChild( | 1847 hr = ToBrowserAccessibilityWin(root)->get_accChild( |
| 1849 old_child_variant, old_child_dispatch.Receive()); | 1848 old_child_variant, old_child_dispatch.Receive()); |
| 1850 EXPECT_EQ(E_INVALIDARG, hr); | 1849 EXPECT_EQ(E_INVALIDARG, hr); |
| 1851 | 1850 |
| 1852 // Trying to access the unique IDs of the new objects should succeed. | 1851 // Trying to access the unique IDs of the new objects should succeed. |
| 1853 base::win::ScopedVariant new_root_variant(root_unique_id_2); | 1852 base::win::ScopedVariant new_root_variant(-root_unique_id_2); |
| 1854 base::win::ScopedComPtr<IDispatch> new_root_dispatch; | 1853 base::win::ScopedComPtr<IDispatch> new_root_dispatch; |
| 1855 hr = root->ToBrowserAccessibilityWin()->get_accChild( | 1854 hr = ToBrowserAccessibilityWin(root)->get_accChild( |
| 1856 new_root_variant, new_root_dispatch.Receive()); | 1855 new_root_variant, new_root_dispatch.Receive()); |
| 1857 EXPECT_EQ(S_OK, hr); | 1856 EXPECT_EQ(S_OK, hr); |
| 1858 | 1857 |
| 1859 base::win::ScopedVariant new_child_variant(child_unique_id_2); | 1858 base::win::ScopedVariant new_child_variant(-child_unique_id_2); |
| 1860 base::win::ScopedComPtr<IDispatch> new_child_dispatch; | 1859 base::win::ScopedComPtr<IDispatch> new_child_dispatch; |
| 1861 hr = root->ToBrowserAccessibilityWin()->get_accChild( | 1860 hr = ToBrowserAccessibilityWin(root)->get_accChild( |
| 1862 new_child_variant, new_child_dispatch.Receive()); | 1861 new_child_variant, new_child_dispatch.Receive()); |
| 1863 EXPECT_EQ(S_OK, hr); | 1862 EXPECT_EQ(S_OK, hr); |
| 1864 } | 1863 } |
| 1865 | 1864 |
| 1866 } // namespace content | 1865 } // namespace content |
| OLD | NEW |