| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 L"textField.focus();" | 219 L"textField.focus();" |
| 220 L"textField.setSelectionRange(") + | 220 L"textField.setSelectionRange(") + |
| 221 caret_offset + L"," + caret_offset + L");"); | 221 caret_offset + L"," + caret_offset + L");"); |
| 222 waiter.WaitForNotification(); | 222 waiter.WaitForNotification(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 // Loads a page with a paragraph of sample text. | 225 // Loads a page with a paragraph of sample text. |
| 226 void AccessibilityWinBrowserTest::SetUpSampleParagraph( | 226 void AccessibilityWinBrowserTest::SetUpSampleParagraph( |
| 227 base::win::ScopedComPtr<IAccessibleText>* paragraph_text) { | 227 base::win::ScopedComPtr<IAccessibleText>* paragraph_text) { |
| 228 ASSERT_NE(nullptr, paragraph_text); | 228 ASSERT_NE(nullptr, paragraph_text); |
| 229 LoadInitialAccessibilityTreeFromHtml(std::string( | 229 LoadInitialAccessibilityTreeFromHtml( |
| 230 "<!DOCTYPE html><html><body>" | 230 "<!DOCTYPE html><html><body>" |
| 231 "<p><b>Game theory</b> is \"the study of " | 231 "<p><b>Game theory</b> is \"the study of " |
| 232 "<a href=\"#\" title=\"Mathematical model\">mathematical models</a> " | 232 "<a href=\"#\" title=\"Mathematical model\">mathematical models</a> " |
| 233 "of conflict and<br>cooperation between intelligent rational " | 233 "of conflict and<br>cooperation between intelligent rational " |
| 234 "decision-makers.\"</p></body></html>")); | 234 "decision-makers.\"</p></body></html>"); |
| 235 | 235 |
| 236 // Retrieve the IAccessible interface for the web page. | 236 // Retrieve the IAccessible interface for the web page. |
| 237 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); | 237 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
| 238 std::vector<base::win::ScopedVariant> document_children = | 238 std::vector<base::win::ScopedVariant> document_children = |
| 239 GetAllAccessibleChildren(document.get()); | 239 GetAllAccessibleChildren(document.get()); |
| 240 ASSERT_EQ(1u, document_children.size()); | 240 ASSERT_EQ(1u, document_children.size()); |
| 241 | 241 |
| 242 base::win::ScopedComPtr<IAccessible2> paragraph; | 242 base::win::ScopedComPtr<IAccessible2> paragraph; |
| 243 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 243 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
| 244 GetAccessibleFromVariant(document.get(), document_children[0].AsInput()) | 244 GetAccessibleFromVariant(document.get(), document_children[0].AsInput()) |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 | 1641 |
| 1642 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 1642 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
| 1643 TestMultiLineTextAtOffsetWithBoundaryAll) { | 1643 TestMultiLineTextAtOffsetWithBoundaryAll) { |
| 1644 base::win::ScopedComPtr<IAccessibleText> textarea_text; | 1644 base::win::ScopedComPtr<IAccessibleText> textarea_text; |
| 1645 SetUpTextareaField(&textarea_text); | 1645 SetUpTextareaField(&textarea_text); |
| 1646 | 1646 |
| 1647 CheckTextAtOffset(textarea_text, CONTENTS_LENGTH - 1, IA2_TEXT_BOUNDARY_ALL, | 1647 CheckTextAtOffset(textarea_text, CONTENTS_LENGTH - 1, IA2_TEXT_BOUNDARY_ALL, |
| 1648 0, CONTENTS_LENGTH, base::SysUTF8ToWide(TEXTAREA_CONTENTS)); | 1648 0, CONTENTS_LENGTH, base::SysUTF8ToWide(TEXTAREA_CONTENTS)); |
| 1649 } | 1649 } |
| 1650 | 1650 |
| 1651 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestIAccessibleAction) { |
| 1652 LoadInitialAccessibilityTreeFromHtml( |
| 1653 "<!DOCTYPE html><html><body>" |
| 1654 "<img src=\"\" alt=\"image\" " |
| 1655 "onclick=\"document.querySelector('img').alt = 'image2';\">" |
| 1656 "</body></html>"); |
| 1657 |
| 1658 // Retrieve the IAccessible interface for the web page. |
| 1659 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
| 1660 std::vector<base::win::ScopedVariant> document_children = |
| 1661 GetAllAccessibleChildren(document.get()); |
| 1662 ASSERT_EQ(1u, document_children.size()); |
| 1663 |
| 1664 base::win::ScopedComPtr<IAccessible2> div; |
| 1665 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
| 1666 GetAccessibleFromVariant(document.get(), document_children[0].AsInput()) |
| 1667 .get(), |
| 1668 div.Receive())); |
| 1669 std::vector<base::win::ScopedVariant> div_children = |
| 1670 GetAllAccessibleChildren(div.get()); |
| 1671 ASSERT_EQ(1u, div_children.size()); |
| 1672 |
| 1673 base::win::ScopedComPtr<IAccessible2> image; |
| 1674 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
| 1675 GetAccessibleFromVariant(div.get(), div_children[0].AsInput()).get(), |
| 1676 image.Receive())); |
| 1677 LONG image_role = 0; |
| 1678 ASSERT_HRESULT_SUCCEEDED(image->role(&image_role)); |
| 1679 ASSERT_EQ(ROLE_SYSTEM_GRAPHIC, image_role); |
| 1680 |
| 1681 base::win::ScopedComPtr<IAccessibleAction> image_action; |
| 1682 ASSERT_HRESULT_SUCCEEDED(image.QueryInterface(image_action.Receive())); |
| 1683 |
| 1684 LONG n_actions = 0; |
| 1685 EXPECT_HRESULT_SUCCEEDED(image_action->nActions(&n_actions)); |
| 1686 EXPECT_EQ(1, n_actions); |
| 1687 |
| 1688 base::win::ScopedBstr action_name; |
| 1689 EXPECT_HRESULT_SUCCEEDED(image_action->get_name(0, action_name.Receive())); |
| 1690 EXPECT_EQ(L"click", std::wstring(action_name, action_name.Length())); |
| 1691 action_name.Release(); |
| 1692 EXPECT_HRESULT_FAILED(image_action->get_name(1, action_name.Receive())); |
| 1693 EXPECT_EQ(nullptr, static_cast<BSTR>(action_name)); |
| 1694 |
| 1695 base::win::ScopedVariant childid_self(CHILDID_SELF); |
| 1696 base::win::ScopedBstr image_name; |
| 1697 EXPECT_HRESULT_SUCCEEDED( |
| 1698 image->get_accName(childid_self, image_name.Receive())); |
| 1699 EXPECT_EQ(L"image", std::wstring(image_name, image_name.Length())); |
| 1700 image_name.Release(); |
| 1701 // Cllicking the image will change its name. |
| 1702 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); |
| 1703 AccessibilityNotificationWaiter waiter(shell(), AccessibilityModeComplete, |
| 1704 ui::AX_EVENT_TEXT_CHANGED); |
| 1705 waiter.WaitForNotification(); |
| 1706 EXPECT_HRESULT_SUCCEEDED( |
| 1707 image->get_accName(childid_self, image_name.Receive())); |
| 1708 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); |
| 1709 EXPECT_HRESULT_FAILED(image_action->doAction(1)); |
| 1710 } |
| 1711 |
| 1651 } // namespace content | 1712 } // namespace content |
| OLD | NEW |