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 "content/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
6 | 6 |
| 7 #include <objbase.h> |
7 #include <stdint.h> | 8 #include <stdint.h> |
8 | 9 |
9 #include <memory> | 10 #include <memory> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/win/scoped_bstr.h" | 15 #include "base/win/scoped_bstr.h" |
15 #include "base/win/scoped_comptr.h" | 16 #include "base/win/scoped_comptr.h" |
16 #include "base/win/scoped_variant.h" | 17 #include "base/win/scoped_variant.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 std::unique_ptr<BrowserAccessibilityManager> manager( | 136 std::unique_ptr<BrowserAccessibilityManager> manager( |
136 BrowserAccessibilityManager::Create(MakeAXTreeUpdate(root, text), nullptr, | 137 BrowserAccessibilityManager::Create(MakeAXTreeUpdate(root, text), nullptr, |
137 new BrowserAccessibilityFactory())); | 138 new BrowserAccessibilityFactory())); |
138 | 139 |
139 // Query for the text IAccessible and verify that it returns "old text" as its | 140 // Query for the text IAccessible and verify that it returns "old text" as its |
140 // value. | 141 // value. |
141 base::win::ScopedVariant one(1); | 142 base::win::ScopedVariant one(1); |
142 base::win::ScopedComPtr<IDispatch> text_dispatch; | 143 base::win::ScopedComPtr<IDispatch> text_dispatch; |
143 HRESULT hr = ToBrowserAccessibilityWin(manager->GetRoot()) | 144 HRESULT hr = ToBrowserAccessibilityWin(manager->GetRoot()) |
144 ->GetCOM() | 145 ->GetCOM() |
145 ->get_accChild(one, text_dispatch.Receive()); | 146 ->get_accChild(one, text_dispatch.GetAddressOf()); |
146 ASSERT_EQ(S_OK, hr); | 147 ASSERT_EQ(S_OK, hr); |
147 | 148 |
148 base::win::ScopedComPtr<IAccessible> text_accessible; | 149 base::win::ScopedComPtr<IAccessible> text_accessible; |
149 hr = text_dispatch.CopyTo(text_accessible.Receive()); | 150 hr = text_dispatch.CopyTo(text_accessible.GetAddressOf()); |
150 ASSERT_EQ(S_OK, hr); | 151 ASSERT_EQ(S_OK, hr); |
151 | 152 |
152 base::win::ScopedVariant childid_self(CHILDID_SELF); | 153 base::win::ScopedVariant childid_self(CHILDID_SELF); |
153 base::win::ScopedBstr name; | 154 base::win::ScopedBstr name; |
154 hr = text_accessible->get_accName(childid_self, name.Receive()); | 155 hr = text_accessible->get_accName(childid_self, name.Receive()); |
155 ASSERT_EQ(S_OK, hr); | 156 ASSERT_EQ(S_OK, hr); |
156 EXPECT_EQ(L"old text", base::string16(name)); | 157 EXPECT_EQ(L"old text", base::string16(name)); |
157 name.Reset(); | 158 name.Reset(); |
158 | 159 |
159 text_dispatch.Reset(); | 160 text_dispatch.Reset(); |
160 text_accessible.Reset(); | 161 text_accessible.Reset(); |
161 | 162 |
162 // Notify the BrowserAccessibilityManager that the text child has changed. | 163 // Notify the BrowserAccessibilityManager that the text child has changed. |
163 AXContentNodeData text2; | 164 AXContentNodeData text2; |
164 text2.id = 2; | 165 text2.id = 2; |
165 text2.role = ui::AX_ROLE_STATIC_TEXT; | 166 text2.role = ui::AX_ROLE_STATIC_TEXT; |
166 text2.SetName("new text"); | 167 text2.SetName("new text"); |
167 AXEventNotificationDetails param; | 168 AXEventNotificationDetails param; |
168 param.event_type = ui::AX_EVENT_CHILDREN_CHANGED; | 169 param.event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
169 param.update.nodes.push_back(text2); | 170 param.update.nodes.push_back(text2); |
170 param.id = text2.id; | 171 param.id = text2.id; |
171 std::vector<AXEventNotificationDetails> events; | 172 std::vector<AXEventNotificationDetails> events; |
172 events.push_back(param); | 173 events.push_back(param); |
173 manager->OnAccessibilityEvents(events); | 174 manager->OnAccessibilityEvents(events); |
174 | 175 |
175 // Query for the text IAccessible and verify that it now returns "new text" | 176 // Query for the text IAccessible and verify that it now returns "new text" |
176 // as its value. | 177 // as its value. |
177 hr = ToBrowserAccessibilityWin(manager->GetRoot()) | 178 hr = ToBrowserAccessibilityWin(manager->GetRoot()) |
178 ->GetCOM() | 179 ->GetCOM() |
179 ->get_accChild(one, text_dispatch.Receive()); | 180 ->get_accChild(one, text_dispatch.GetAddressOf()); |
180 ASSERT_EQ(S_OK, hr); | 181 ASSERT_EQ(S_OK, hr); |
181 | 182 |
182 hr = text_dispatch.CopyTo(text_accessible.Receive()); | 183 hr = text_dispatch.CopyTo(text_accessible.GetAddressOf()); |
183 ASSERT_EQ(S_OK, hr); | 184 ASSERT_EQ(S_OK, hr); |
184 | 185 |
185 hr = text_accessible->get_accName(childid_self, name.Receive()); | 186 hr = text_accessible->get_accName(childid_self, name.Receive()); |
186 ASSERT_EQ(S_OK, hr); | 187 ASSERT_EQ(S_OK, hr); |
187 EXPECT_EQ(L"new text", base::string16(name)); | 188 EXPECT_EQ(L"new text", base::string16(name)); |
188 | 189 |
189 text_dispatch.Reset(); | 190 text_dispatch.Reset(); |
190 text_accessible.Reset(); | 191 text_accessible.Reset(); |
191 | 192 |
192 // Delete the manager and test that all BrowserAccessibility instances are | 193 // Delete the manager and test that all BrowserAccessibility instances are |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 443 |
443 base::win::ScopedBstr text; | 444 base::win::ScopedBstr text; |
444 EXPECT_EQ(S_OK, root_obj->get_text(0, text_name_len, text.Receive())); | 445 EXPECT_EQ(S_OK, root_obj->get_text(0, text_name_len, text.Receive())); |
445 EXPECT_EQ(text1_name + text2_name, base::UTF16ToUTF8(base::string16(text))); | 446 EXPECT_EQ(text1_name + text2_name, base::UTF16ToUTF8(base::string16(text))); |
446 | 447 |
447 long hyperlink_count; | 448 long hyperlink_count; |
448 EXPECT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count)); | 449 EXPECT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count)); |
449 EXPECT_EQ(0, hyperlink_count); | 450 EXPECT_EQ(0, hyperlink_count); |
450 | 451 |
451 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; | 452 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; |
452 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive())); | |
453 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(0, hyperlink.Receive())); | |
454 EXPECT_EQ(E_INVALIDARG, | 453 EXPECT_EQ(E_INVALIDARG, |
455 root_obj->get_hyperlink(text_name_len, hyperlink.Receive())); | 454 root_obj->get_hyperlink(-1, hyperlink.GetAddressOf())); |
| 455 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(0, hyperlink.GetAddressOf())); |
456 EXPECT_EQ(E_INVALIDARG, | 456 EXPECT_EQ(E_INVALIDARG, |
457 root_obj->get_hyperlink(text_name_len + 1, hyperlink.Receive())); | 457 root_obj->get_hyperlink(text_name_len, hyperlink.GetAddressOf())); |
| 458 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(text_name_len + 1, |
| 459 hyperlink.GetAddressOf())); |
458 | 460 |
459 long hyperlink_index; | 461 long hyperlink_index; |
460 EXPECT_EQ(S_FALSE, root_obj->get_hyperlinkIndex(0, &hyperlink_index)); | 462 EXPECT_EQ(S_FALSE, root_obj->get_hyperlinkIndex(0, &hyperlink_index)); |
461 EXPECT_EQ(-1, hyperlink_index); | 463 EXPECT_EQ(-1, hyperlink_index); |
462 // Invalid arguments should not be modified. | 464 // Invalid arguments should not be modified. |
463 hyperlink_index = -2; | 465 hyperlink_index = -2; |
464 EXPECT_EQ(E_INVALIDARG, | 466 EXPECT_EQ(E_INVALIDARG, |
465 root_obj->get_hyperlinkIndex(text_name_len, &hyperlink_index)); | 467 root_obj->get_hyperlinkIndex(text_name_len, &hyperlink_index)); |
466 EXPECT_EQ(-2, hyperlink_index); | 468 EXPECT_EQ(-2, hyperlink_index); |
467 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlinkIndex(-1, &hyperlink_index)); | 469 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlinkIndex(-1, &hyperlink_index)); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 EXPECT_EQ(S_OK, root_obj->get_text(0, root_hypertext_len, text.Receive())); | 565 EXPECT_EQ(S_OK, root_obj->get_text(0, root_hypertext_len, text.Receive())); |
564 EXPECT_STREQ(root_hypertext.c_str(), text); | 566 EXPECT_STREQ(root_hypertext.c_str(), text); |
565 text.Reset(); | 567 text.Reset(); |
566 | 568 |
567 long hyperlink_count; | 569 long hyperlink_count; |
568 EXPECT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count)); | 570 EXPECT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count)); |
569 EXPECT_EQ(4, hyperlink_count); | 571 EXPECT_EQ(4, hyperlink_count); |
570 | 572 |
571 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; | 573 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; |
572 base::win::ScopedComPtr<IAccessibleText> hypertext; | 574 base::win::ScopedComPtr<IAccessibleText> hypertext; |
573 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive())); | 575 EXPECT_EQ(E_INVALIDARG, |
574 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(4, hyperlink.Receive())); | 576 root_obj->get_hyperlink(-1, hyperlink.GetAddressOf())); |
| 577 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(4, hyperlink.GetAddressOf())); |
575 | 578 |
576 // Get the text of the combo box. | 579 // Get the text of the combo box. |
577 // It should be its value. | 580 // It should be its value. |
578 EXPECT_EQ(S_OK, root_obj->get_hyperlink(0, hyperlink.Receive())); | 581 EXPECT_EQ(S_OK, root_obj->get_hyperlink(0, hyperlink.GetAddressOf())); |
579 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); | 582 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.GetAddressOf())); |
580 EXPECT_EQ(S_OK, | 583 EXPECT_EQ(S_OK, |
581 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 584 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
582 EXPECT_STREQ(combo_box_value.c_str(), text); | 585 EXPECT_STREQ(combo_box_value.c_str(), text); |
583 text.Reset(); | 586 text.Reset(); |
584 hyperlink.Reset(); | 587 hyperlink.Reset(); |
585 hypertext.Reset(); | 588 hypertext.Reset(); |
586 | 589 |
587 // Get the text of the check box. | 590 // Get the text of the check box. |
588 // It should be its name. | 591 // It should be its name. |
589 EXPECT_EQ(S_OK, root_obj->get_hyperlink(1, hyperlink.Receive())); | 592 EXPECT_EQ(S_OK, root_obj->get_hyperlink(1, hyperlink.GetAddressOf())); |
590 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); | 593 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.GetAddressOf())); |
591 EXPECT_EQ(S_OK, | 594 EXPECT_EQ(S_OK, |
592 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 595 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
593 EXPECT_STREQ(check_box_name.c_str(), text); | 596 EXPECT_STREQ(check_box_name.c_str(), text); |
594 text.Reset(); | 597 text.Reset(); |
595 hyperlink.Reset(); | 598 hyperlink.Reset(); |
596 hypertext.Reset(); | 599 hypertext.Reset(); |
597 | 600 |
598 // Get the text of the button. | 601 // Get the text of the button. |
599 EXPECT_EQ(S_OK, root_obj->get_hyperlink(2, hyperlink.Receive())); | 602 EXPECT_EQ(S_OK, root_obj->get_hyperlink(2, hyperlink.GetAddressOf())); |
600 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); | 603 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.GetAddressOf())); |
601 EXPECT_EQ(S_OK, | 604 EXPECT_EQ(S_OK, |
602 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 605 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
603 EXPECT_STREQ(button_text_name.c_str(), text); | 606 EXPECT_STREQ(button_text_name.c_str(), text); |
604 text.Reset(); | 607 text.Reset(); |
605 hyperlink.Reset(); | 608 hyperlink.Reset(); |
606 hypertext.Reset(); | 609 hypertext.Reset(); |
607 | 610 |
608 // Get the text of the link. | 611 // Get the text of the link. |
609 EXPECT_EQ(S_OK, root_obj->get_hyperlink(3, hyperlink.Receive())); | 612 EXPECT_EQ(S_OK, root_obj->get_hyperlink(3, hyperlink.GetAddressOf())); |
610 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); | 613 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.GetAddressOf())); |
611 EXPECT_EQ(S_OK, hypertext->get_text(0, 4, text.Receive())); | 614 EXPECT_EQ(S_OK, hypertext->get_text(0, 4, text.Receive())); |
612 EXPECT_STREQ(link_text_name.c_str(), text); | 615 EXPECT_STREQ(link_text_name.c_str(), text); |
613 text.Reset(); | 616 text.Reset(); |
614 hyperlink.Reset(); | 617 hyperlink.Reset(); |
615 hypertext.Reset(); | 618 hypertext.Reset(); |
616 | 619 |
617 long hyperlink_index; | 620 long hyperlink_index; |
618 EXPECT_EQ(S_FALSE, root_obj->get_hyperlinkIndex(0, &hyperlink_index)); | 621 EXPECT_EQ(S_FALSE, root_obj->get_hyperlinkIndex(0, &hyperlink_index)); |
619 EXPECT_EQ(-1, hyperlink_index); | 622 EXPECT_EQ(-1, hyperlink_index); |
620 // Invalid arguments should not be modified. | 623 // Invalid arguments should not be modified. |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 BrowserAccessibilityWin* textarea_accessible = | 1048 BrowserAccessibilityWin* textarea_accessible = |
1046 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); | 1049 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(0)); |
1047 ASSERT_NE(nullptr, textarea_accessible); | 1050 ASSERT_NE(nullptr, textarea_accessible); |
1048 BrowserAccessibilityWin* text_field_accessible = | 1051 BrowserAccessibilityWin* text_field_accessible = |
1049 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(1)); | 1052 ToBrowserAccessibilityWin(root_accessible->PlatformGetChild(1)); |
1050 ASSERT_NE(nullptr, text_field_accessible); | 1053 ASSERT_NE(nullptr, text_field_accessible); |
1051 | 1054 |
1052 base::win::ScopedComPtr<IAccessibleText> textarea_object; | 1055 base::win::ScopedComPtr<IAccessibleText> textarea_object; |
1053 EXPECT_HRESULT_SUCCEEDED(textarea_accessible->GetCOM()->QueryInterface( | 1056 EXPECT_HRESULT_SUCCEEDED(textarea_accessible->GetCOM()->QueryInterface( |
1054 IID_IAccessibleText, | 1057 IID_IAccessibleText, |
1055 reinterpret_cast<void**>(textarea_object.Receive()))); | 1058 reinterpret_cast<void**>(textarea_object.GetAddressOf()))); |
1056 base::win::ScopedComPtr<IAccessibleText> text_field_object; | 1059 base::win::ScopedComPtr<IAccessibleText> text_field_object; |
1057 EXPECT_HRESULT_SUCCEEDED(text_field_accessible->GetCOM()->QueryInterface( | 1060 EXPECT_HRESULT_SUCCEEDED(text_field_accessible->GetCOM()->QueryInterface( |
1058 IID_IAccessibleText, | 1061 IID_IAccessibleText, |
1059 reinterpret_cast<void**>(text_field_object.Receive()))); | 1062 reinterpret_cast<void**>(text_field_object.GetAddressOf()))); |
1060 | 1063 |
1061 LONG offset = 0; | 1064 LONG offset = 0; |
1062 while (offset < static_cast<LONG>(text.length())) { | 1065 while (offset < static_cast<LONG>(text.length())) { |
1063 LONG start, end; | 1066 LONG start, end; |
1064 base::win::ScopedBstr word; | 1067 base::win::ScopedBstr word; |
1065 EXPECT_EQ(S_OK, | 1068 EXPECT_EQ(S_OK, |
1066 textarea_object->get_textAtOffset(offset, IA2_TEXT_BOUNDARY_WORD, | 1069 textarea_object->get_textAtOffset(offset, IA2_TEXT_BOUNDARY_WORD, |
1067 &start, &end, word.Receive())); | 1070 &start, &end, word.Receive())); |
1068 EXPECT_EQ(offset, start); | 1071 EXPECT_EQ(offset, start); |
1069 EXPECT_LT(offset, end); | 1072 EXPECT_LT(offset, end); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 | 1536 |
1534 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; | 1537 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; |
1535 base::win::ScopedVariant anchor; | 1538 base::win::ScopedVariant anchor; |
1536 base::win::ScopedVariant anchor_target; | 1539 base::win::ScopedVariant anchor_target; |
1537 base::win::ScopedBstr bstr; | 1540 base::win::ScopedBstr bstr; |
1538 | 1541 |
1539 base::string16 div_hypertext(L"Click "); | 1542 base::string16 div_hypertext(L"Click "); |
1540 div_hypertext.push_back(BrowserAccessibilityComWin::kEmbeddedCharacter); | 1543 div_hypertext.push_back(BrowserAccessibilityComWin::kEmbeddedCharacter); |
1541 | 1544 |
1542 // div_accessible and link_accessible are the only IA2 hyperlinks. | 1545 // div_accessible and link_accessible are the only IA2 hyperlinks. |
1543 EXPECT_HRESULT_FAILED(root_accessible->GetCOM()->QueryInterface( | 1546 EXPECT_HRESULT_FAILED( |
1544 IID_IAccessibleHyperlink, reinterpret_cast<void**>(hyperlink.Receive()))); | 1547 root_accessible->GetCOM()->QueryInterface(IID_PPV_ARGS(&hyperlink))); |
1545 hyperlink.Reset(); | 1548 hyperlink.Reset(); |
1546 EXPECT_HRESULT_SUCCEEDED(div_accessible->GetCOM()->QueryInterface( | 1549 EXPECT_HRESULT_SUCCEEDED( |
1547 IID_IAccessibleHyperlink, reinterpret_cast<void**>(hyperlink.Receive()))); | 1550 div_accessible->GetCOM()->QueryInterface(IID_PPV_ARGS(&hyperlink))); |
1548 hyperlink.Reset(); | 1551 hyperlink.Reset(); |
1549 EXPECT_HRESULT_FAILED(text_accessible->GetCOM()->QueryInterface( | 1552 EXPECT_HRESULT_FAILED( |
1550 IID_IAccessibleHyperlink, reinterpret_cast<void**>(hyperlink.Receive()))); | 1553 text_accessible->GetCOM()->QueryInterface(IID_PPV_ARGS(&hyperlink))); |
1551 hyperlink.Reset(); | 1554 hyperlink.Reset(); |
1552 EXPECT_HRESULT_SUCCEEDED(link_accessible->GetCOM()->QueryInterface( | 1555 EXPECT_HRESULT_SUCCEEDED( |
1553 IID_IAccessibleHyperlink, reinterpret_cast<void**>(hyperlink.Receive()))); | 1556 link_accessible->GetCOM()->QueryInterface(IID_PPV_ARGS(&hyperlink))); |
1554 hyperlink.Reset(); | 1557 hyperlink.Reset(); |
1555 | 1558 |
1556 EXPECT_HRESULT_SUCCEEDED(root_accessible->GetCOM()->nActions(&n_actions)); | 1559 EXPECT_HRESULT_SUCCEEDED(root_accessible->GetCOM()->nActions(&n_actions)); |
1557 EXPECT_EQ(0, n_actions); | 1560 EXPECT_EQ(0, n_actions); |
1558 EXPECT_HRESULT_SUCCEEDED(div_accessible->GetCOM()->nActions(&n_actions)); | 1561 EXPECT_HRESULT_SUCCEEDED(div_accessible->GetCOM()->nActions(&n_actions)); |
1559 EXPECT_EQ(1, n_actions); | 1562 EXPECT_EQ(1, n_actions); |
1560 EXPECT_HRESULT_SUCCEEDED(text_accessible->GetCOM()->nActions(&n_actions)); | 1563 EXPECT_HRESULT_SUCCEEDED(text_accessible->GetCOM()->nActions(&n_actions)); |
1561 EXPECT_EQ(0, n_actions); | 1564 EXPECT_EQ(0, n_actions); |
1562 EXPECT_HRESULT_SUCCEEDED(link_accessible->GetCOM()->nActions(&n_actions)); | 1565 EXPECT_HRESULT_SUCCEEDED(link_accessible->GetCOM()->nActions(&n_actions)); |
1563 EXPECT_EQ(1, n_actions); | 1566 EXPECT_EQ(1, n_actions); |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2213 int32_t child_unique_id_2 = child->unique_id(); | 2216 int32_t child_unique_id_2 = child->unique_id(); |
2214 | 2217 |
2215 // The nodes in the new tree should not have the same ids. | 2218 // The nodes in the new tree should not have the same ids. |
2216 EXPECT_NE(root_unique_id, root_unique_id_2); | 2219 EXPECT_NE(root_unique_id, root_unique_id_2); |
2217 EXPECT_NE(child_unique_id, child_unique_id_2); | 2220 EXPECT_NE(child_unique_id, child_unique_id_2); |
2218 | 2221 |
2219 // Trying to access the unique IDs of the old, deleted objects should fail. | 2222 // Trying to access the unique IDs of the old, deleted objects should fail. |
2220 base::win::ScopedVariant old_root_variant(-root_unique_id); | 2223 base::win::ScopedVariant old_root_variant(-root_unique_id); |
2221 base::win::ScopedComPtr<IDispatch> old_root_dispatch; | 2224 base::win::ScopedComPtr<IDispatch> old_root_dispatch; |
2222 HRESULT hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( | 2225 HRESULT hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( |
2223 old_root_variant, old_root_dispatch.Receive()); | 2226 old_root_variant, old_root_dispatch.GetAddressOf()); |
2224 EXPECT_EQ(E_INVALIDARG, hr); | 2227 EXPECT_EQ(E_INVALIDARG, hr); |
2225 | 2228 |
2226 base::win::ScopedVariant old_child_variant(-child_unique_id); | 2229 base::win::ScopedVariant old_child_variant(-child_unique_id); |
2227 base::win::ScopedComPtr<IDispatch> old_child_dispatch; | 2230 base::win::ScopedComPtr<IDispatch> old_child_dispatch; |
2228 hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( | 2231 hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( |
2229 old_child_variant, old_child_dispatch.Receive()); | 2232 old_child_variant, old_child_dispatch.GetAddressOf()); |
2230 EXPECT_EQ(E_INVALIDARG, hr); | 2233 EXPECT_EQ(E_INVALIDARG, hr); |
2231 | 2234 |
2232 // Trying to access the unique IDs of the new objects should succeed. | 2235 // Trying to access the unique IDs of the new objects should succeed. |
2233 base::win::ScopedVariant new_root_variant(-root_unique_id_2); | 2236 base::win::ScopedVariant new_root_variant(-root_unique_id_2); |
2234 base::win::ScopedComPtr<IDispatch> new_root_dispatch; | 2237 base::win::ScopedComPtr<IDispatch> new_root_dispatch; |
2235 hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( | 2238 hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( |
2236 new_root_variant, new_root_dispatch.Receive()); | 2239 new_root_variant, new_root_dispatch.GetAddressOf()); |
2237 EXPECT_EQ(S_OK, hr); | 2240 EXPECT_EQ(S_OK, hr); |
2238 | 2241 |
2239 base::win::ScopedVariant new_child_variant(-child_unique_id_2); | 2242 base::win::ScopedVariant new_child_variant(-child_unique_id_2); |
2240 base::win::ScopedComPtr<IDispatch> new_child_dispatch; | 2243 base::win::ScopedComPtr<IDispatch> new_child_dispatch; |
2241 hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( | 2244 hr = ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( |
2242 new_child_variant, new_child_dispatch.Receive()); | 2245 new_child_variant, new_child_dispatch.GetAddressOf()); |
2243 EXPECT_EQ(S_OK, hr); | 2246 EXPECT_EQ(S_OK, hr); |
2244 } | 2247 } |
2245 | 2248 |
2246 TEST_F(BrowserAccessibilityTest, AccChildOnlyReturnsDescendants) { | 2249 TEST_F(BrowserAccessibilityTest, AccChildOnlyReturnsDescendants) { |
2247 ui::AXNodeData root_node; | 2250 ui::AXNodeData root_node; |
2248 root_node.id = 1; | 2251 root_node.id = 1; |
2249 root_node.role = ui::AX_ROLE_ROOT_WEB_AREA; | 2252 root_node.role = ui::AX_ROLE_ROOT_WEB_AREA; |
2250 | 2253 |
2251 ui::AXNodeData child_node; | 2254 ui::AXNodeData child_node; |
2252 child_node.id = 2; | 2255 child_node.id = 2; |
2253 root_node.child_ids.push_back(2); | 2256 root_node.child_ids.push_back(2); |
2254 | 2257 |
2255 std::unique_ptr<BrowserAccessibilityManagerWin> manager( | 2258 std::unique_ptr<BrowserAccessibilityManagerWin> manager( |
2256 new BrowserAccessibilityManagerWin( | 2259 new BrowserAccessibilityManagerWin( |
2257 MakeAXTreeUpdate(root_node, child_node), nullptr, | 2260 MakeAXTreeUpdate(root_node, child_node), nullptr, |
2258 new BrowserAccessibilityFactory())); | 2261 new BrowserAccessibilityFactory())); |
2259 | 2262 |
2260 BrowserAccessibility* root = manager->GetRoot(); | 2263 BrowserAccessibility* root = manager->GetRoot(); |
2261 BrowserAccessibility* child = root->PlatformGetChild(0); | 2264 BrowserAccessibility* child = root->PlatformGetChild(0); |
2262 | 2265 |
2263 base::win::ScopedVariant root_unique_id_variant(-root->unique_id()); | 2266 base::win::ScopedVariant root_unique_id_variant(-root->unique_id()); |
2264 base::win::ScopedComPtr<IDispatch> result; | 2267 base::win::ScopedComPtr<IDispatch> result; |
2265 EXPECT_EQ(E_INVALIDARG, | 2268 EXPECT_EQ(E_INVALIDARG, |
2266 ToBrowserAccessibilityWin(child)->GetCOM()->get_accChild( | 2269 ToBrowserAccessibilityWin(child)->GetCOM()->get_accChild( |
2267 root_unique_id_variant, result.Receive())); | 2270 root_unique_id_variant, result.GetAddressOf())); |
2268 | 2271 |
2269 base::win::ScopedVariant child_unique_id_variant(-child->unique_id()); | 2272 base::win::ScopedVariant child_unique_id_variant(-child->unique_id()); |
2270 EXPECT_EQ(S_OK, ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( | 2273 EXPECT_EQ(S_OK, ToBrowserAccessibilityWin(root)->GetCOM()->get_accChild( |
2271 child_unique_id_variant, result.Receive())); | 2274 child_unique_id_variant, result.GetAddressOf())); |
2272 } | 2275 } |
2273 | 2276 |
2274 TEST_F(BrowserAccessibilityTest, TestIAccessible2Relations) { | 2277 TEST_F(BrowserAccessibilityTest, TestIAccessible2Relations) { |
2275 ui::AXNodeData root; | 2278 ui::AXNodeData root; |
2276 root.id = 1; | 2279 root.id = 1; |
2277 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 2280 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
2278 // Reflexive relations should be ignored. | 2281 // Reflexive relations should be ignored. |
2279 std::vector<int32_t> describedby_ids = {1, 2, 3}; | 2282 std::vector<int32_t> describedby_ids = {1, 2, 3}; |
2280 root.AddIntListAttribute(ui::AX_ATTR_DESCRIBEDBY_IDS, describedby_ids); | 2283 root.AddIntListAttribute(ui::AX_ATTR_DESCRIBEDBY_IDS, describedby_ids); |
2281 | 2284 |
(...skipping 28 matching lines...) Expand all Loading... |
2310 base::win::ScopedBstr relation_type; | 2313 base::win::ScopedBstr relation_type; |
2311 base::win::ScopedComPtr<IAccessibleRelation> describedby_relation; | 2314 base::win::ScopedComPtr<IAccessibleRelation> describedby_relation; |
2312 base::win::ScopedComPtr<IAccessibleRelation> description_for_relation; | 2315 base::win::ScopedComPtr<IAccessibleRelation> description_for_relation; |
2313 base::win::ScopedComPtr<IUnknown> target; | 2316 base::win::ScopedComPtr<IUnknown> target; |
2314 base::win::ScopedComPtr<IAccessible2> ax_target; | 2317 base::win::ScopedComPtr<IAccessible2> ax_target; |
2315 | 2318 |
2316 EXPECT_HRESULT_SUCCEEDED(ax_root->GetCOM()->get_nRelations(&n_relations)); | 2319 EXPECT_HRESULT_SUCCEEDED(ax_root->GetCOM()->get_nRelations(&n_relations)); |
2317 EXPECT_EQ(1, n_relations); | 2320 EXPECT_EQ(1, n_relations); |
2318 | 2321 |
2319 EXPECT_HRESULT_SUCCEEDED( | 2322 EXPECT_HRESULT_SUCCEEDED( |
2320 ax_root->GetCOM()->get_relation(0, describedby_relation.Receive())); | 2323 ax_root->GetCOM()->get_relation(0, describedby_relation.GetAddressOf())); |
2321 EXPECT_HRESULT_SUCCEEDED( | 2324 EXPECT_HRESULT_SUCCEEDED( |
2322 describedby_relation->get_relationType(relation_type.Receive())); | 2325 describedby_relation->get_relationType(relation_type.Receive())); |
2323 EXPECT_EQ(L"describedBy", base::string16(relation_type)); | 2326 EXPECT_EQ(L"describedBy", base::string16(relation_type)); |
2324 relation_type.Reset(); | 2327 relation_type.Reset(); |
2325 | 2328 |
2326 EXPECT_HRESULT_SUCCEEDED(describedby_relation->get_nTargets(&n_targets)); | 2329 EXPECT_HRESULT_SUCCEEDED(describedby_relation->get_nTargets(&n_targets)); |
2327 EXPECT_EQ(2, n_targets); | 2330 EXPECT_EQ(2, n_targets); |
2328 | 2331 |
2329 EXPECT_HRESULT_SUCCEEDED( | 2332 EXPECT_HRESULT_SUCCEEDED( |
2330 describedby_relation->get_target(0, target.Receive())); | 2333 describedby_relation->get_target(0, target.GetAddressOf())); |
2331 target.CopyTo(ax_target.Receive()); | 2334 target.CopyTo(ax_target.GetAddressOf()); |
2332 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2335 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
2333 EXPECT_EQ(-ax_child1->unique_id(), unique_id); | 2336 EXPECT_EQ(-ax_child1->unique_id(), unique_id); |
2334 ax_target.Reset(); | 2337 ax_target.Reset(); |
2335 target.Reset(); | 2338 target.Reset(); |
2336 | 2339 |
2337 EXPECT_HRESULT_SUCCEEDED( | 2340 EXPECT_HRESULT_SUCCEEDED( |
2338 describedby_relation->get_target(1, target.Receive())); | 2341 describedby_relation->get_target(1, target.GetAddressOf())); |
2339 target.CopyTo(ax_target.Receive()); | 2342 target.CopyTo(ax_target.GetAddressOf()); |
2340 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2343 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
2341 EXPECT_EQ(-ax_child2->unique_id(), unique_id); | 2344 EXPECT_EQ(-ax_child2->unique_id(), unique_id); |
2342 ax_target.Reset(); | 2345 ax_target.Reset(); |
2343 target.Reset(); | 2346 target.Reset(); |
2344 describedby_relation.Reset(); | 2347 describedby_relation.Reset(); |
2345 | 2348 |
2346 // Test the reverse relations. | 2349 // Test the reverse relations. |
2347 EXPECT_HRESULT_SUCCEEDED(ax_child1->GetCOM()->get_nRelations(&n_relations)); | 2350 EXPECT_HRESULT_SUCCEEDED(ax_child1->GetCOM()->get_nRelations(&n_relations)); |
2348 EXPECT_EQ(1, n_relations); | 2351 EXPECT_EQ(1, n_relations); |
2349 | 2352 |
2350 EXPECT_HRESULT_SUCCEEDED( | 2353 EXPECT_HRESULT_SUCCEEDED(ax_child1->GetCOM()->get_relation( |
2351 ax_child1->GetCOM()->get_relation(0, description_for_relation.Receive())); | 2354 0, description_for_relation.GetAddressOf())); |
2352 EXPECT_HRESULT_SUCCEEDED( | 2355 EXPECT_HRESULT_SUCCEEDED( |
2353 description_for_relation->get_relationType(relation_type.Receive())); | 2356 description_for_relation->get_relationType(relation_type.Receive())); |
2354 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); | 2357 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); |
2355 relation_type.Reset(); | 2358 relation_type.Reset(); |
2356 | 2359 |
2357 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); | 2360 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); |
2358 EXPECT_EQ(1, n_targets); | 2361 EXPECT_EQ(1, n_targets); |
2359 | 2362 |
2360 EXPECT_HRESULT_SUCCEEDED( | 2363 EXPECT_HRESULT_SUCCEEDED( |
2361 description_for_relation->get_target(0, target.Receive())); | 2364 description_for_relation->get_target(0, target.GetAddressOf())); |
2362 target.CopyTo(ax_target.Receive()); | 2365 target.CopyTo(ax_target.GetAddressOf()); |
2363 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2366 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
2364 EXPECT_EQ(-ax_root->unique_id(), unique_id); | 2367 EXPECT_EQ(-ax_root->unique_id(), unique_id); |
2365 ax_target.Reset(); | 2368 ax_target.Reset(); |
2366 target.Reset(); | 2369 target.Reset(); |
2367 description_for_relation.Reset(); | 2370 description_for_relation.Reset(); |
2368 | 2371 |
2369 EXPECT_HRESULT_SUCCEEDED(ax_child2->GetCOM()->get_nRelations(&n_relations)); | 2372 EXPECT_HRESULT_SUCCEEDED(ax_child2->GetCOM()->get_nRelations(&n_relations)); |
2370 EXPECT_EQ(1, n_relations); | 2373 EXPECT_EQ(1, n_relations); |
2371 | 2374 |
2372 EXPECT_HRESULT_SUCCEEDED( | 2375 EXPECT_HRESULT_SUCCEEDED(ax_child2->GetCOM()->get_relation( |
2373 ax_child2->GetCOM()->get_relation(0, description_for_relation.Receive())); | 2376 0, description_for_relation.GetAddressOf())); |
2374 EXPECT_HRESULT_SUCCEEDED( | 2377 EXPECT_HRESULT_SUCCEEDED( |
2375 description_for_relation->get_relationType(relation_type.Receive())); | 2378 description_for_relation->get_relationType(relation_type.Receive())); |
2376 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); | 2379 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); |
2377 relation_type.Reset(); | 2380 relation_type.Reset(); |
2378 | 2381 |
2379 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); | 2382 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); |
2380 EXPECT_EQ(1, n_targets); | 2383 EXPECT_EQ(1, n_targets); |
2381 | 2384 |
2382 EXPECT_HRESULT_SUCCEEDED( | 2385 EXPECT_HRESULT_SUCCEEDED( |
2383 description_for_relation->get_target(0, target.Receive())); | 2386 description_for_relation->get_target(0, target.GetAddressOf())); |
2384 target.CopyTo(ax_target.Receive()); | 2387 target.CopyTo(ax_target.GetAddressOf()); |
2385 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2388 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
2386 EXPECT_EQ(-ax_root->unique_id(), unique_id); | 2389 EXPECT_EQ(-ax_root->unique_id(), unique_id); |
2387 ax_target.Reset(); | 2390 ax_target.Reset(); |
2388 target.Reset(); | 2391 target.Reset(); |
2389 | 2392 |
2390 // Try adding one more relation. | 2393 // Try adding one more relation. |
2391 std::vector<int32_t> labelledby_ids = {3}; | 2394 std::vector<int32_t> labelledby_ids = {3}; |
2392 child1.AddIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS, labelledby_ids); | 2395 child1.AddIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS, labelledby_ids); |
2393 AXEventNotificationDetails event; | 2396 AXEventNotificationDetails event; |
2394 event.event_type = ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED; | 2397 event.event_type = ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED; |
2395 event.update.nodes.push_back(child1); | 2398 event.update.nodes.push_back(child1); |
2396 event.id = child1.id; | 2399 event.id = child1.id; |
2397 std::vector<AXEventNotificationDetails> events = {event}; | 2400 std::vector<AXEventNotificationDetails> events = {event}; |
2398 manager->OnAccessibilityEvents(events); | 2401 manager->OnAccessibilityEvents(events); |
2399 | 2402 |
2400 EXPECT_HRESULT_SUCCEEDED(ax_child1->GetCOM()->get_nRelations(&n_relations)); | 2403 EXPECT_HRESULT_SUCCEEDED(ax_child1->GetCOM()->get_nRelations(&n_relations)); |
2401 EXPECT_EQ(2, n_relations); | 2404 EXPECT_EQ(2, n_relations); |
2402 EXPECT_HRESULT_SUCCEEDED(ax_child2->GetCOM()->get_nRelations(&n_relations)); | 2405 EXPECT_HRESULT_SUCCEEDED(ax_child2->GetCOM()->get_nRelations(&n_relations)); |
2403 EXPECT_EQ(2, n_relations); | 2406 EXPECT_EQ(2, n_relations); |
2404 } | 2407 } |
2405 | 2408 |
2406 } // namespace content | 2409 } // namespace content |
OLD | NEW |