| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 class AccessibleChecker; | 63 class AccessibleChecker; |
| 64 void LoadInitialAccessibilityTreeFromHtml( | 64 void LoadInitialAccessibilityTreeFromHtml( |
| 65 const std::string& html, | 65 const std::string& html, |
| 66 AccessibilityMode accessibility_mode = kAccessibilityModeComplete); | 66 AccessibilityMode accessibility_mode = kAccessibilityModeComplete); |
| 67 IAccessible* GetRendererAccessible(); | 67 IAccessible* GetRendererAccessible(); |
| 68 void ExecuteScript(const std::wstring& script); | 68 void ExecuteScript(const std::wstring& script); |
| 69 void SetUpInputField( | 69 void SetUpInputField( |
| 70 base::win::ScopedComPtr<IAccessibleText>* input_text); | 70 base::win::ScopedComPtr<IAccessibleText>* input_text); |
| 71 void SetUpTextareaField( | 71 void SetUpTextareaField( |
| 72 base::win::ScopedComPtr<IAccessibleText>* textarea_text); | 72 base::win::ScopedComPtr<IAccessibleText>* textarea_text); |
| 73 template <typename Interface> | |
| 74 void SetUpSampleParagraph( | 73 void SetUpSampleParagraph( |
| 75 base::win::ScopedComPtr<Interface>* com_interface, | 74 base::win::ScopedComPtr<IAccessibleText>* accessible_text, |
| 76 AccessibilityMode accessibility_mode = kAccessibilityModeComplete); | 75 AccessibilityMode accessibility_mode = kAccessibilityModeComplete); |
| 77 | 76 |
| 78 static base::win::ScopedComPtr<IAccessible> GetAccessibleFromVariant( | 77 static base::win::ScopedComPtr<IAccessible> GetAccessibleFromVariant( |
| 79 IAccessible* parent, | 78 IAccessible* parent, |
| 80 VARIANT* var); | 79 VARIANT* var); |
| 81 static HRESULT QueryIAccessible2(IAccessible* accessible, | 80 static HRESULT QueryIAccessible2(IAccessible* accessible, |
| 82 IAccessible2** accessible2); | 81 IAccessible2** accessible2); |
| 83 static void FindNodeInAccessibilityTree(IAccessible* node, | 82 static void FindNodeInAccessibilityTree(IAccessible* node, |
| 84 int32_t expected_role, | 83 int32_t expected_role, |
| 85 const std::wstring& expected_name, | 84 const std::wstring& expected_name, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 static_cast<int>(CONTENTS_LENGTH - 1))); | 223 static_cast<int>(CONTENTS_LENGTH - 1))); |
| 225 ExecuteScript(std::wstring( | 224 ExecuteScript(std::wstring( |
| 226 L"var textField = document.getElementById('textField');" | 225 L"var textField = document.getElementById('textField');" |
| 227 L"textField.focus();" | 226 L"textField.focus();" |
| 228 L"textField.setSelectionRange(") + | 227 L"textField.setSelectionRange(") + |
| 229 caret_offset + L"," + caret_offset + L");"); | 228 caret_offset + L"," + caret_offset + L");"); |
| 230 waiter.WaitForNotification(); | 229 waiter.WaitForNotification(); |
| 231 } | 230 } |
| 232 | 231 |
| 233 // Loads a page with a paragraph of sample text. | 232 // Loads a page with a paragraph of sample text. |
| 234 template <typename Interface> | |
| 235 void AccessibilityWinBrowserTest::SetUpSampleParagraph( | 233 void AccessibilityWinBrowserTest::SetUpSampleParagraph( |
| 236 base::win::ScopedComPtr<Interface>* com_interface, | 234 base::win::ScopedComPtr<IAccessibleText>* accessible_text, |
| 237 AccessibilityMode accessibility_mode) { | 235 AccessibilityMode accessibility_mode) { |
| 238 ASSERT_NE(nullptr, com_interface); | 236 ASSERT_NE(nullptr, accessible_text); |
| 239 LoadInitialAccessibilityTreeFromHtml( | 237 LoadInitialAccessibilityTreeFromHtml( |
| 240 "<!DOCTYPE html><html>" | 238 "<!DOCTYPE html><html>" |
| 241 "<body style=\"overflow: scroll; margin-top: 100vh\">" | 239 "<body style=\"overflow: scroll; margin-top: 100vh\">" |
| 242 "<p><b>Game theory</b> is \"the study of " | 240 "<p><b>Game theory</b> is \"the study of " |
| 243 "<a href=\"#\" title=\"Mathematical model\">mathematical models</a> " | 241 "<a href=\"#\" title=\"Mathematical model\">mathematical models</a> " |
| 244 "of conflict and<br>cooperation between intelligent rational " | 242 "of conflict and<br>cooperation between intelligent rational " |
| 245 "decision-makers.\"</p></body></html>", | 243 "decision-makers.\"</p></body></html>", |
| 246 accessibility_mode); | 244 accessibility_mode); |
| 247 | 245 |
| 248 // Retrieve the IAccessible interface for the web page. | 246 // Retrieve the IAccessible interface for the web page. |
| 249 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); | 247 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
| 250 std::vector<base::win::ScopedVariant> document_children = | 248 std::vector<base::win::ScopedVariant> document_children = |
| 251 GetAllAccessibleChildren(document.Get()); | 249 GetAllAccessibleChildren(document.Get()); |
| 252 ASSERT_EQ(1u, document_children.size()); | 250 ASSERT_EQ(1u, document_children.size()); |
| 253 | 251 |
| 254 base::win::ScopedComPtr<IAccessible2> paragraph; | 252 base::win::ScopedComPtr<IAccessible2> paragraph; |
| 255 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 253 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
| 256 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) | 254 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) |
| 257 .Get(), | 255 .Get(), |
| 258 paragraph.Receive())); | 256 paragraph.Receive())); |
| 259 LONG paragraph_role = 0; | 257 LONG paragraph_role = 0; |
| 260 ASSERT_HRESULT_SUCCEEDED(paragraph->role(¶graph_role)); | 258 ASSERT_HRESULT_SUCCEEDED(paragraph->role(¶graph_role)); |
| 261 ASSERT_EQ(IA2_ROLE_PARAGRAPH, paragraph_role); | 259 ASSERT_EQ(IA2_ROLE_PARAGRAPH, paragraph_role); |
| 262 ASSERT_HRESULT_SUCCEEDED(paragraph.QueryInterface(com_interface->Receive())); | 260 ASSERT_HRESULT_SUCCEEDED(paragraph.QueryInterface( |
| 261 accessible_text->Receive())); |
| 263 } | 262 } |
| 264 | 263 |
| 265 // Static helpers ------------------------------------------------ | 264 // Static helpers ------------------------------------------------ |
| 266 | 265 |
| 267 base::win::ScopedComPtr<IAccessible> | 266 base::win::ScopedComPtr<IAccessible> |
| 268 AccessibilityWinBrowserTest::GetAccessibleFromVariant( | 267 AccessibilityWinBrowserTest::GetAccessibleFromVariant( |
| 269 IAccessible* parent, | 268 IAccessible* parent, |
| 270 VARIANT* var) { | 269 VARIANT* var) { |
| 271 base::win::ScopedComPtr<IAccessible> ptr; | 270 base::win::ScopedComPtr<IAccessible> ptr; |
| 272 switch (V_VT(var)) { | 271 switch (V_VT(var)) { |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 // Inline text boxes should have been enabled by this point. | 1111 // Inline text boxes should have been enabled by this point. |
| 1113 EXPECT_HRESULT_SUCCEEDED(paragraph_text->get_characterExtents( | 1112 EXPECT_HRESULT_SUCCEEDED(paragraph_text->get_characterExtents( |
| 1114 0, IA2_COORDTYPE_SCREEN_RELATIVE, &x, &y, &width, &height)); | 1113 0, IA2_COORDTYPE_SCREEN_RELATIVE, &x, &y, &width, &height)); |
| 1115 EXPECT_LT(0, x); | 1114 EXPECT_LT(0, x); |
| 1116 EXPECT_LT(0, y); | 1115 EXPECT_LT(0, y); |
| 1117 EXPECT_LT(0, width); | 1116 EXPECT_LT(0, width); |
| 1118 EXPECT_LT(0, height); | 1117 EXPECT_LT(0, height); |
| 1119 } | 1118 } |
| 1120 | 1119 |
| 1121 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollToPoint) { | 1120 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollToPoint) { |
| 1121 base::win::ScopedComPtr<IAccessibleText> accessible_text; |
| 1122 SetUpSampleParagraph(&accessible_text); |
| 1122 base::win::ScopedComPtr<IAccessible2> paragraph; | 1123 base::win::ScopedComPtr<IAccessible2> paragraph; |
| 1123 SetUpSampleParagraph(¶graph); | 1124 ASSERT_HRESULT_SUCCEEDED( |
| 1125 accessible_text.QueryInterface(IID_PPV_ARGS(¶graph))); |
| 1124 | 1126 |
| 1125 LONG prev_x, prev_y, x, y, width, height; | 1127 LONG prev_x, prev_y, x, y, width, height; |
| 1126 base::win::ScopedVariant childid_self(CHILDID_SELF); | 1128 base::win::ScopedVariant childid_self(CHILDID_SELF); |
| 1127 ASSERT_HRESULT_SUCCEEDED( | 1129 ASSERT_HRESULT_SUCCEEDED( |
| 1128 paragraph->accLocation(&prev_x, &prev_y, &width, &height, childid_self)); | 1130 paragraph->accLocation(&prev_x, &prev_y, &width, &height, childid_self)); |
| 1129 AccessibilityNotificationWaiter location_changed_waiter( | 1131 AccessibilityNotificationWaiter location_changed_waiter( |
| 1130 shell()->web_contents(), kAccessibilityModeComplete, | 1132 shell()->web_contents(), kAccessibilityModeComplete, |
| 1131 ui::AX_EVENT_LOCATION_CHANGED); | 1133 ui::AX_EVENT_LOCATION_CHANGED); |
| 1132 EXPECT_HRESULT_SUCCEEDED( | 1134 EXPECT_HRESULT_SUCCEEDED( |
| 1133 paragraph->scrollToPoint(IA2_COORDTYPE_PARENT_RELATIVE, 0, 0)); | 1135 paragraph->scrollToPoint(IA2_COORDTYPE_PARENT_RELATIVE, 0, 0)); |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2039 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); | 2041 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); |
| 2040 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); | 2042 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); |
| 2041 EXPECT_EQ(1, row_index); | 2043 EXPECT_EQ(1, row_index); |
| 2042 EXPECT_EQ(1, column_index); | 2044 EXPECT_EQ(1, column_index); |
| 2043 variant.Reset(); | 2045 variant.Reset(); |
| 2044 name.Reset(); | 2046 name.Reset(); |
| 2045 accessible_cell.Reset(); | 2047 accessible_cell.Reset(); |
| 2046 } | 2048 } |
| 2047 | 2049 |
| 2048 } // namespace content | 2050 } // namespace content |
| OLD | NEW |