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 <objbase.h> |
5 #include <stddef.h> | 6 #include <stddef.h> |
6 #include <stdint.h> | 7 #include <stdint.h> |
7 | 8 |
8 #include <memory> | 9 #include <memory> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
14 #include "base/win/scoped_bstr.h" | 15 #include "base/win/scoped_bstr.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Retrieve the IAccessible interface for the web page. | 140 // Retrieve the IAccessible interface for the web page. |
140 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); | 141 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
141 std::vector<base::win::ScopedVariant> document_children = | 142 std::vector<base::win::ScopedVariant> document_children = |
142 GetAllAccessibleChildren(document.Get()); | 143 GetAllAccessibleChildren(document.Get()); |
143 ASSERT_EQ(1u, document_children.size()); | 144 ASSERT_EQ(1u, document_children.size()); |
144 | 145 |
145 base::win::ScopedComPtr<IAccessible2> form; | 146 base::win::ScopedComPtr<IAccessible2> form; |
146 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 147 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
147 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) | 148 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) |
148 .Get(), | 149 .Get(), |
149 form.Receive())); | 150 form.GetAddressOf())); |
150 std::vector<base::win::ScopedVariant> form_children = | 151 std::vector<base::win::ScopedVariant> form_children = |
151 GetAllAccessibleChildren(form.Get()); | 152 GetAllAccessibleChildren(form.Get()); |
152 ASSERT_EQ(2u, form_children.size()); | 153 ASSERT_EQ(2u, form_children.size()); |
153 | 154 |
154 // Find the input text field. | 155 // Find the input text field. |
155 base::win::ScopedComPtr<IAccessible2> input; | 156 base::win::ScopedComPtr<IAccessible2> input; |
156 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 157 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
157 GetAccessibleFromVariant(form.Get(), form_children[1].AsInput()).Get(), | 158 GetAccessibleFromVariant(form.Get(), form_children[1].AsInput()).Get(), |
158 input.Receive())); | 159 input.GetAddressOf())); |
159 LONG input_role = 0; | 160 LONG input_role = 0; |
160 ASSERT_HRESULT_SUCCEEDED(input->role(&input_role)); | 161 ASSERT_HRESULT_SUCCEEDED(input->role(&input_role)); |
161 ASSERT_EQ(ROLE_SYSTEM_TEXT, input_role); | 162 ASSERT_EQ(ROLE_SYSTEM_TEXT, input_role); |
162 | 163 |
163 // Retrieve the IAccessibleText interface for the field. | 164 // Retrieve the IAccessibleText interface for the field. |
164 ASSERT_HRESULT_SUCCEEDED(input.CopyTo(input_text->Receive())); | 165 ASSERT_HRESULT_SUCCEEDED(input.CopyTo(input_text->GetAddressOf())); |
165 | 166 |
166 // Set the caret on the last character. | 167 // Set the caret on the last character. |
167 AccessibilityNotificationWaiter waiter(shell()->web_contents(), | 168 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
168 kAccessibilityModeComplete, | 169 kAccessibilityModeComplete, |
169 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | 170 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
170 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( | 171 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( |
171 static_cast<int>(CONTENTS_LENGTH - 1))); | 172 static_cast<int>(CONTENTS_LENGTH - 1))); |
172 ExecuteScript(std::wstring( | 173 ExecuteScript(std::wstring( |
173 L"var textField = document.getElementById('textField');" | 174 L"var textField = document.getElementById('textField');" |
174 L"textField.focus();" | 175 L"textField.focus();" |
(...skipping 15 matching lines...) Expand all Loading... |
190 // Retrieve the IAccessible interface for the web page. | 191 // Retrieve the IAccessible interface for the web page. |
191 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); | 192 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
192 std::vector<base::win::ScopedVariant> document_children = | 193 std::vector<base::win::ScopedVariant> document_children = |
193 GetAllAccessibleChildren(document.Get()); | 194 GetAllAccessibleChildren(document.Get()); |
194 ASSERT_EQ(1u, document_children.size()); | 195 ASSERT_EQ(1u, document_children.size()); |
195 | 196 |
196 base::win::ScopedComPtr<IAccessible2> section; | 197 base::win::ScopedComPtr<IAccessible2> section; |
197 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 198 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
198 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) | 199 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) |
199 .Get(), | 200 .Get(), |
200 section.Receive())); | 201 section.GetAddressOf())); |
201 std::vector<base::win::ScopedVariant> section_children = | 202 std::vector<base::win::ScopedVariant> section_children = |
202 GetAllAccessibleChildren(section.Get()); | 203 GetAllAccessibleChildren(section.Get()); |
203 ASSERT_EQ(1u, section_children.size()); | 204 ASSERT_EQ(1u, section_children.size()); |
204 | 205 |
205 // Find the textarea text field. | 206 // Find the textarea text field. |
206 base::win::ScopedComPtr<IAccessible2> textarea; | 207 base::win::ScopedComPtr<IAccessible2> textarea; |
207 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 208 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
208 GetAccessibleFromVariant(section.Get(), section_children[0].AsInput()) | 209 GetAccessibleFromVariant(section.Get(), section_children[0].AsInput()) |
209 .Get(), | 210 .Get(), |
210 textarea.Receive())); | 211 textarea.GetAddressOf())); |
211 LONG textarea_role = 0; | 212 LONG textarea_role = 0; |
212 ASSERT_HRESULT_SUCCEEDED(textarea->role(&textarea_role)); | 213 ASSERT_HRESULT_SUCCEEDED(textarea->role(&textarea_role)); |
213 ASSERT_EQ(ROLE_SYSTEM_TEXT, textarea_role); | 214 ASSERT_EQ(ROLE_SYSTEM_TEXT, textarea_role); |
214 | 215 |
215 // Retrieve the IAccessibleText interface for the field. | 216 // Retrieve the IAccessibleText interface for the field. |
216 ASSERT_HRESULT_SUCCEEDED(textarea.CopyTo(textarea_text->Receive())); | 217 ASSERT_HRESULT_SUCCEEDED(textarea.CopyTo(textarea_text->GetAddressOf())); |
217 | 218 |
218 // Set the caret on the last character. | 219 // Set the caret on the last character. |
219 AccessibilityNotificationWaiter waiter(shell()->web_contents(), | 220 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
220 kAccessibilityModeComplete, | 221 kAccessibilityModeComplete, |
221 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | 222 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
222 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( | 223 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( |
223 static_cast<int>(CONTENTS_LENGTH - 1))); | 224 static_cast<int>(CONTENTS_LENGTH - 1))); |
224 ExecuteScript(std::wstring( | 225 ExecuteScript(std::wstring( |
225 L"var textField = document.getElementById('textField');" | 226 L"var textField = document.getElementById('textField');" |
226 L"textField.focus();" | 227 L"textField.focus();" |
(...skipping 19 matching lines...) Expand all Loading... |
246 // Retrieve the IAccessible interface for the web page. | 247 // Retrieve the IAccessible interface for the web page. |
247 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); | 248 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
248 std::vector<base::win::ScopedVariant> document_children = | 249 std::vector<base::win::ScopedVariant> document_children = |
249 GetAllAccessibleChildren(document.Get()); | 250 GetAllAccessibleChildren(document.Get()); |
250 ASSERT_EQ(1u, document_children.size()); | 251 ASSERT_EQ(1u, document_children.size()); |
251 | 252 |
252 base::win::ScopedComPtr<IAccessible2> paragraph; | 253 base::win::ScopedComPtr<IAccessible2> paragraph; |
253 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 254 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
254 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) | 255 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) |
255 .Get(), | 256 .Get(), |
256 paragraph.Receive())); | 257 paragraph.GetAddressOf())); |
257 LONG paragraph_role = 0; | 258 LONG paragraph_role = 0; |
258 ASSERT_HRESULT_SUCCEEDED(paragraph->role(¶graph_role)); | 259 ASSERT_HRESULT_SUCCEEDED(paragraph->role(¶graph_role)); |
259 ASSERT_EQ(IA2_ROLE_PARAGRAPH, paragraph_role); | 260 ASSERT_EQ(IA2_ROLE_PARAGRAPH, paragraph_role); |
260 ASSERT_HRESULT_SUCCEEDED(paragraph.CopyTo( | 261 ASSERT_HRESULT_SUCCEEDED(paragraph.CopyTo(accessible_text->GetAddressOf())); |
261 accessible_text->Receive())); | |
262 } | 262 } |
263 | 263 |
264 // Static helpers ------------------------------------------------ | 264 // Static helpers ------------------------------------------------ |
265 | 265 |
266 base::win::ScopedComPtr<IAccessible> | 266 base::win::ScopedComPtr<IAccessible> |
267 AccessibilityWinBrowserTest::GetAccessibleFromVariant( | 267 AccessibilityWinBrowserTest::GetAccessibleFromVariant( |
268 IAccessible* parent, | 268 IAccessible* parent, |
269 VARIANT* var) { | 269 VARIANT* var) { |
270 base::win::ScopedComPtr<IAccessible> ptr; | 270 base::win::ScopedComPtr<IAccessible> ptr; |
271 switch (V_VT(var)) { | 271 switch (V_VT(var)) { |
272 case VT_DISPATCH: { | 272 case VT_DISPATCH: { |
273 IDispatch* dispatch = V_DISPATCH(var); | 273 IDispatch* dispatch = V_DISPATCH(var); |
274 if (dispatch) | 274 if (dispatch) |
275 dispatch->QueryInterface(ptr.Receive()); | 275 dispatch->QueryInterface(ptr.GetAddressOf()); |
276 break; | 276 break; |
277 } | 277 } |
278 | 278 |
279 case VT_I4: { | 279 case VT_I4: { |
280 base::win::ScopedComPtr<IDispatch> dispatch; | 280 base::win::ScopedComPtr<IDispatch> dispatch; |
281 HRESULT hr = parent->get_accChild(*var, dispatch.Receive()); | 281 HRESULT hr = parent->get_accChild(*var, dispatch.GetAddressOf()); |
282 EXPECT_TRUE(SUCCEEDED(hr)); | 282 EXPECT_TRUE(SUCCEEDED(hr)); |
283 if (dispatch.Get()) | 283 if (dispatch.Get()) |
284 dispatch.CopyTo(ptr.Receive()); | 284 dispatch.CopyTo(ptr.GetAddressOf()); |
285 break; | 285 break; |
286 } | 286 } |
287 } | 287 } |
288 return ptr; | 288 return ptr; |
289 } | 289 } |
290 | 290 |
291 HRESULT AccessibilityWinBrowserTest::QueryIAccessible2( | 291 HRESULT AccessibilityWinBrowserTest::QueryIAccessible2( |
292 IAccessible* accessible, | 292 IAccessible* accessible, |
293 IAccessible2** accessible2) { | 293 IAccessible2** accessible2) { |
294 // IA2 Spec dictates that IServiceProvider should be used instead of | 294 // IA2 Spec dictates that IServiceProvider should be used instead of |
295 // QueryInterface when retrieving IAccessible2. | 295 // QueryInterface when retrieving IAccessible2. |
296 base::win::ScopedComPtr<IServiceProvider> service_provider; | 296 base::win::ScopedComPtr<IServiceProvider> service_provider; |
297 HRESULT hr = accessible->QueryInterface(service_provider.Receive()); | 297 HRESULT hr = accessible->QueryInterface(service_provider.GetAddressOf()); |
298 return SUCCEEDED(hr) ? | 298 return SUCCEEDED(hr) ? |
299 service_provider->QueryService(IID_IAccessible2, accessible2) : hr; | 299 service_provider->QueryService(IID_IAccessible2, accessible2) : hr; |
300 } | 300 } |
301 | 301 |
302 // Recursively search through all of the descendants reachable from an | 302 // Recursively search through all of the descendants reachable from an |
303 // IAccessible node and return true if we find one with the given role | 303 // IAccessible node and return true if we find one with the given role |
304 // and name. | 304 // and name. |
305 void AccessibilityWinBrowserTest::FindNodeInAccessibilityTree( | 305 void AccessibilityWinBrowserTest::FindNodeInAccessibilityTree( |
306 IAccessible* node, | 306 IAccessible* node, |
307 int32_t expected_role, | 307 int32_t expected_role, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 HRESULT hr = accessible->get_accRole(childid_self, role.Receive()); | 540 HRESULT hr = accessible->get_accRole(childid_self, role.Receive()); |
541 ASSERT_EQ(S_OK, hr); | 541 ASSERT_EQ(S_OK, hr); |
542 EXPECT_EQ(0, role_.Compare(role)) | 542 EXPECT_EQ(0, role_.Compare(role)) |
543 << "Expected role: " << RoleVariantToString(role_) | 543 << "Expected role: " << RoleVariantToString(role_) |
544 << "\nGot role: " << RoleVariantToString(role); | 544 << "\nGot role: " << RoleVariantToString(role); |
545 } | 545 } |
546 | 546 |
547 void AccessibilityWinBrowserTest::AccessibleChecker::CheckIA2Role( | 547 void AccessibilityWinBrowserTest::AccessibleChecker::CheckIA2Role( |
548 IAccessible* accessible) { | 548 IAccessible* accessible) { |
549 base::win::ScopedComPtr<IAccessible2> accessible2; | 549 base::win::ScopedComPtr<IAccessible2> accessible2; |
550 HRESULT hr = QueryIAccessible2(accessible, accessible2.Receive()); | 550 HRESULT hr = QueryIAccessible2(accessible, accessible2.GetAddressOf()); |
551 ASSERT_EQ(S_OK, hr); | 551 ASSERT_EQ(S_OK, hr); |
552 long ia2_role = 0; | 552 long ia2_role = 0; |
553 hr = accessible2->role(&ia2_role); | 553 hr = accessible2->role(&ia2_role); |
554 ASSERT_EQ(S_OK, hr); | 554 ASSERT_EQ(S_OK, hr); |
555 EXPECT_EQ(ia2_role_, ia2_role) | 555 EXPECT_EQ(ia2_role_, ia2_role) |
556 << "Expected ia2 role: " << IAccessible2RoleToString(ia2_role_) | 556 << "Expected ia2 role: " << IAccessible2RoleToString(ia2_role_) |
557 << "\nGot ia2 role: " << IAccessible2RoleToString(ia2_role); | 557 << "\nGot ia2 role: " << IAccessible2RoleToString(ia2_role); |
558 } | 558 } |
559 | 559 |
560 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleValue( | 560 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleValue( |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 | 882 |
883 // Get the accessibility object for the window tree host. | 883 // Get the accessibility object for the window tree host. |
884 aura::Window* window = shell()->window(); | 884 aura::Window* window = shell()->window(); |
885 CHECK(window); | 885 CHECK(window); |
886 aura::WindowTreeHost* window_tree_host = window->GetHost(); | 886 aura::WindowTreeHost* window_tree_host = window->GetHost(); |
887 CHECK(window_tree_host); | 887 CHECK(window_tree_host); |
888 HWND hwnd = window_tree_host->GetAcceleratedWidget(); | 888 HWND hwnd = window_tree_host->GetAcceleratedWidget(); |
889 CHECK(hwnd); | 889 CHECK(hwnd); |
890 base::win::ScopedComPtr<IAccessible> browser_accessible; | 890 base::win::ScopedComPtr<IAccessible> browser_accessible; |
891 HRESULT hr = AccessibleObjectFromWindow( | 891 HRESULT hr = AccessibleObjectFromWindow( |
892 hwnd, | 892 hwnd, OBJID_WINDOW, IID_IAccessible, |
893 OBJID_WINDOW, | 893 reinterpret_cast<void**>(browser_accessible.GetAddressOf())); |
894 IID_IAccessible, | |
895 reinterpret_cast<void**>(browser_accessible.Receive())); | |
896 ASSERT_EQ(S_OK, hr); | 894 ASSERT_EQ(S_OK, hr); |
897 | 895 |
898 bool found = false; | 896 bool found = false; |
899 FindNodeInAccessibilityTree( | 897 FindNodeInAccessibilityTree( |
900 browser_accessible.Get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found); | 898 browser_accessible.Get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found); |
901 ASSERT_EQ(found, true); | 899 ASSERT_EQ(found, true); |
902 } | 900 } |
903 | 901 |
904 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 902 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
905 SupportsISimpleDOM) { | 903 SupportsISimpleDOM) { |
906 LoadInitialAccessibilityTreeFromHtml( | 904 LoadInitialAccessibilityTreeFromHtml( |
907 "<body><input type='checkbox'></body>"); | 905 "<body><input type='checkbox'></body>"); |
908 | 906 |
909 // Get the IAccessible object for the document. | 907 // Get the IAccessible object for the document. |
910 base::win::ScopedComPtr<IAccessible> document_accessible( | 908 base::win::ScopedComPtr<IAccessible> document_accessible( |
911 GetRendererAccessible()); | 909 GetRendererAccessible()); |
912 ASSERT_NE(document_accessible.Get(), reinterpret_cast<IAccessible*>(NULL)); | 910 ASSERT_NE(document_accessible.Get(), reinterpret_cast<IAccessible*>(NULL)); |
913 | 911 |
914 // Get the ISimpleDOM object for the document. | 912 // Get the ISimpleDOM object for the document. |
915 base::win::ScopedComPtr<IServiceProvider> service_provider; | 913 base::win::ScopedComPtr<IServiceProvider> service_provider; |
916 HRESULT hr = static_cast<IAccessible*>(document_accessible.Get()) | 914 HRESULT hr = static_cast<IAccessible*>(document_accessible.Get()) |
917 ->QueryInterface(service_provider.Receive()); | 915 ->QueryInterface(service_provider.GetAddressOf()); |
918 ASSERT_EQ(S_OK, hr); | 916 ASSERT_EQ(S_OK, hr); |
919 const GUID refguid = {0x0c539790, | 917 const GUID refguid = {0x0c539790, |
920 0x12e4, | 918 0x12e4, |
921 0x11cf, | 919 0x11cf, |
922 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}}; | 920 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}}; |
923 base::win::ScopedComPtr<ISimpleDOMNode> document_isimpledomnode; | 921 base::win::ScopedComPtr<ISimpleDOMNode> document_isimpledomnode; |
924 hr = static_cast<IServiceProvider*>(service_provider.Get()) | 922 hr = service_provider->QueryService(refguid, |
925 ->QueryService( | 923 IID_PPV_ARGS(&document_isimpledomnode)); |
926 refguid, IID_ISimpleDOMNode, | |
927 reinterpret_cast<void**>(document_isimpledomnode.Receive())); | |
928 ASSERT_EQ(S_OK, hr); | 924 ASSERT_EQ(S_OK, hr); |
929 | 925 |
930 base::win::ScopedBstr node_name; | 926 base::win::ScopedBstr node_name; |
931 short name_space_id; // NOLINT | 927 short name_space_id; // NOLINT |
932 base::win::ScopedBstr node_value; | 928 base::win::ScopedBstr node_value; |
933 unsigned int num_children; | 929 unsigned int num_children; |
934 unsigned int unique_id; | 930 unsigned int unique_id; |
935 unsigned short node_type; // NOLINT | 931 unsigned short node_type; // NOLINT |
936 hr = document_isimpledomnode->get_nodeInfo( | 932 hr = document_isimpledomnode->get_nodeInfo( |
937 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children, | 933 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children, |
938 &unique_id, &node_type); | 934 &unique_id, &node_type); |
939 ASSERT_EQ(S_OK, hr); | 935 ASSERT_EQ(S_OK, hr); |
940 EXPECT_EQ(NODETYPE_DOCUMENT, node_type); | 936 EXPECT_EQ(NODETYPE_DOCUMENT, node_type); |
941 EXPECT_EQ(1u, num_children); | 937 EXPECT_EQ(1u, num_children); |
942 node_name.Reset(); | 938 node_name.Reset(); |
943 node_value.Reset(); | 939 node_value.Reset(); |
944 | 940 |
945 base::win::ScopedComPtr<ISimpleDOMNode> body_isimpledomnode; | 941 base::win::ScopedComPtr<ISimpleDOMNode> body_isimpledomnode; |
946 hr = document_isimpledomnode->get_firstChild( | 942 hr = document_isimpledomnode->get_firstChild( |
947 body_isimpledomnode.Receive()); | 943 body_isimpledomnode.GetAddressOf()); |
948 ASSERT_EQ(S_OK, hr); | 944 ASSERT_EQ(S_OK, hr); |
949 hr = body_isimpledomnode->get_nodeInfo( | 945 hr = body_isimpledomnode->get_nodeInfo( |
950 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children, | 946 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children, |
951 &unique_id, &node_type); | 947 &unique_id, &node_type); |
952 ASSERT_EQ(S_OK, hr); | 948 ASSERT_EQ(S_OK, hr); |
953 EXPECT_EQ(L"body", std::wstring(node_name, node_name.Length())); | 949 EXPECT_EQ(L"body", std::wstring(node_name, node_name.Length())); |
954 EXPECT_EQ(NODETYPE_ELEMENT, node_type); | 950 EXPECT_EQ(NODETYPE_ELEMENT, node_type); |
955 EXPECT_EQ(1u, num_children); | 951 EXPECT_EQ(1u, num_children); |
956 node_name.Reset(); | 952 node_name.Reset(); |
957 node_value.Reset(); | 953 node_value.Reset(); |
958 | 954 |
959 base::win::ScopedComPtr<ISimpleDOMNode> checkbox_isimpledomnode; | 955 base::win::ScopedComPtr<ISimpleDOMNode> checkbox_isimpledomnode; |
960 hr = body_isimpledomnode->get_firstChild( | 956 hr = body_isimpledomnode->get_firstChild( |
961 checkbox_isimpledomnode.Receive()); | 957 checkbox_isimpledomnode.GetAddressOf()); |
962 ASSERT_EQ(S_OK, hr); | 958 ASSERT_EQ(S_OK, hr); |
963 hr = checkbox_isimpledomnode->get_nodeInfo( | 959 hr = checkbox_isimpledomnode->get_nodeInfo( |
964 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children, | 960 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children, |
965 &unique_id, &node_type); | 961 &unique_id, &node_type); |
966 ASSERT_EQ(S_OK, hr); | 962 ASSERT_EQ(S_OK, hr); |
967 EXPECT_EQ(L"input", std::wstring(node_name, node_name.Length())); | 963 EXPECT_EQ(L"input", std::wstring(node_name, node_name.Length())); |
968 EXPECT_EQ(NODETYPE_ELEMENT, node_type); | 964 EXPECT_EQ(NODETYPE_ELEMENT, node_type); |
969 EXPECT_EQ(0u, num_children); | 965 EXPECT_EQ(0u, num_children); |
970 } | 966 } |
971 | 967 |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 // Retrieve the IAccessible interface for the web page. | 1856 // Retrieve the IAccessible interface for the web page. |
1861 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); | 1857 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
1862 std::vector<base::win::ScopedVariant> document_children = | 1858 std::vector<base::win::ScopedVariant> document_children = |
1863 GetAllAccessibleChildren(document.Get()); | 1859 GetAllAccessibleChildren(document.Get()); |
1864 ASSERT_EQ(1u, document_children.size()); | 1860 ASSERT_EQ(1u, document_children.size()); |
1865 | 1861 |
1866 base::win::ScopedComPtr<IAccessible2> div; | 1862 base::win::ScopedComPtr<IAccessible2> div; |
1867 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 1863 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
1868 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) | 1864 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) |
1869 .Get(), | 1865 .Get(), |
1870 div.Receive())); | 1866 div.GetAddressOf())); |
1871 std::vector<base::win::ScopedVariant> div_children = | 1867 std::vector<base::win::ScopedVariant> div_children = |
1872 GetAllAccessibleChildren(div.Get()); | 1868 GetAllAccessibleChildren(div.Get()); |
1873 ASSERT_EQ(1u, div_children.size()); | 1869 ASSERT_EQ(1u, div_children.size()); |
1874 | 1870 |
1875 base::win::ScopedComPtr<IAccessible2> image; | 1871 base::win::ScopedComPtr<IAccessible2> image; |
1876 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 1872 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
1877 GetAccessibleFromVariant(div.Get(), div_children[0].AsInput()).Get(), | 1873 GetAccessibleFromVariant(div.Get(), div_children[0].AsInput()).Get(), |
1878 image.Receive())); | 1874 image.GetAddressOf())); |
1879 LONG image_role = 0; | 1875 LONG image_role = 0; |
1880 ASSERT_HRESULT_SUCCEEDED(image->role(&image_role)); | 1876 ASSERT_HRESULT_SUCCEEDED(image->role(&image_role)); |
1881 ASSERT_EQ(ROLE_SYSTEM_GRAPHIC, image_role); | 1877 ASSERT_EQ(ROLE_SYSTEM_GRAPHIC, image_role); |
1882 | 1878 |
1883 base::win::ScopedComPtr<IAccessibleAction> image_action; | 1879 base::win::ScopedComPtr<IAccessibleAction> image_action; |
1884 ASSERT_HRESULT_SUCCEEDED(image.CopyTo(image_action.Receive())); | 1880 ASSERT_HRESULT_SUCCEEDED(image.CopyTo(image_action.GetAddressOf())); |
1885 | 1881 |
1886 LONG n_actions = 0; | 1882 LONG n_actions = 0; |
1887 EXPECT_HRESULT_SUCCEEDED(image_action->nActions(&n_actions)); | 1883 EXPECT_HRESULT_SUCCEEDED(image_action->nActions(&n_actions)); |
1888 EXPECT_EQ(1, n_actions); | 1884 EXPECT_EQ(1, n_actions); |
1889 | 1885 |
1890 base::win::ScopedBstr action_name; | 1886 base::win::ScopedBstr action_name; |
1891 EXPECT_HRESULT_SUCCEEDED(image_action->get_name(0, action_name.Receive())); | 1887 EXPECT_HRESULT_SUCCEEDED(image_action->get_name(0, action_name.Receive())); |
1892 EXPECT_EQ(L"click", std::wstring(action_name, action_name.Length())); | 1888 EXPECT_EQ(L"click", std::wstring(action_name, action_name.Length())); |
1893 action_name.Release(); | 1889 action_name.Release(); |
1894 EXPECT_HRESULT_FAILED(image_action->get_name(1, action_name.Receive())); | 1890 EXPECT_HRESULT_FAILED(image_action->get_name(1, action_name.Receive())); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); | 1958 base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
1963 std::vector<base::win::ScopedVariant> document_children = | 1959 std::vector<base::win::ScopedVariant> document_children = |
1964 GetAllAccessibleChildren(document.Get()); | 1960 GetAllAccessibleChildren(document.Get()); |
1965 // There are two tables in this test file. Use only the first one. | 1961 // There are two tables in this test file. Use only the first one. |
1966 ASSERT_EQ(2u, document_children.size()); | 1962 ASSERT_EQ(2u, document_children.size()); |
1967 | 1963 |
1968 base::win::ScopedComPtr<IAccessible2> table; | 1964 base::win::ScopedComPtr<IAccessible2> table; |
1969 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( | 1965 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2( |
1970 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) | 1966 GetAccessibleFromVariant(document.Get(), document_children[0].AsInput()) |
1971 .Get(), | 1967 .Get(), |
1972 table.Receive())); | 1968 table.GetAddressOf())); |
1973 LONG role = 0; | 1969 LONG role = 0; |
1974 ASSERT_HRESULT_SUCCEEDED(table->role(&role)); | 1970 ASSERT_HRESULT_SUCCEEDED(table->role(&role)); |
1975 ASSERT_EQ(ROLE_SYSTEM_TABLE, role); | 1971 ASSERT_EQ(ROLE_SYSTEM_TABLE, role); |
1976 | 1972 |
1977 // Retrieve the first cell. | 1973 // Retrieve the first cell. |
1978 base::win::ScopedComPtr<IAccessibleTable2> table2; | 1974 base::win::ScopedComPtr<IAccessibleTable2> table2; |
1979 base::win::ScopedComPtr<IUnknown> cell; | 1975 base::win::ScopedComPtr<IUnknown> cell; |
1980 base::win::ScopedComPtr<IAccessible2> cell1; | 1976 base::win::ScopedComPtr<IAccessible2> cell1; |
1981 EXPECT_HRESULT_SUCCEEDED(table.CopyTo(table2.Receive())); | 1977 EXPECT_HRESULT_SUCCEEDED(table.CopyTo(table2.GetAddressOf())); |
1982 EXPECT_HRESULT_SUCCEEDED(table2->get_cellAt(0, 0, cell.Receive())); | 1978 EXPECT_HRESULT_SUCCEEDED(table2->get_cellAt(0, 0, cell.GetAddressOf())); |
1983 EXPECT_HRESULT_SUCCEEDED(cell.CopyTo(cell1.Receive())); | 1979 EXPECT_HRESULT_SUCCEEDED(cell.CopyTo(cell1.GetAddressOf())); |
1984 | 1980 |
1985 base::win::ScopedBstr name; | 1981 base::win::ScopedBstr name; |
1986 base::win::ScopedVariant childid_self(CHILDID_SELF); | 1982 base::win::ScopedVariant childid_self(CHILDID_SELF); |
1987 base::win::ScopedComPtr<IAccessibleTableCell> accessible_cell; | 1983 base::win::ScopedComPtr<IAccessibleTableCell> accessible_cell; |
1988 LONG row_index = -1; | 1984 LONG row_index = -1; |
1989 LONG column_index = -1; | 1985 LONG column_index = -1; |
1990 EXPECT_HRESULT_SUCCEEDED(cell1->role(&role)); | 1986 EXPECT_HRESULT_SUCCEEDED(cell1->role(&role)); |
1991 EXPECT_EQ(ROLE_SYSTEM_CELL, role); | 1987 EXPECT_EQ(ROLE_SYSTEM_CELL, role); |
1992 EXPECT_HRESULT_SUCCEEDED(cell1->get_accName(childid_self, name.Receive())); | 1988 EXPECT_HRESULT_SUCCEEDED(cell1->get_accName(childid_self, name.Receive())); |
1993 // EXPECT_STREQ(L"AD", name); | 1989 // EXPECT_STREQ(L"AD", name); |
1994 EXPECT_HRESULT_SUCCEEDED(cell1.CopyTo(accessible_cell.Receive())); | 1990 EXPECT_HRESULT_SUCCEEDED(cell1.CopyTo(accessible_cell.GetAddressOf())); |
1995 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); | 1991 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); |
1996 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); | 1992 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); |
1997 EXPECT_EQ(0, row_index); | 1993 EXPECT_EQ(0, row_index); |
1998 EXPECT_EQ(0, column_index); | 1994 EXPECT_EQ(0, column_index); |
1999 name.Reset(); | 1995 name.Reset(); |
2000 accessible_cell.Reset(); | 1996 accessible_cell.Reset(); |
2001 | 1997 |
2002 // The first cell has a rowspan of 2, try navigating down and expect to get | 1998 // The first cell has a rowspan of 2, try navigating down and expect to get |
2003 // at the end of the table. | 1999 // at the end of the table. |
2004 base::win::ScopedVariant variant; | 2000 base::win::ScopedVariant variant; |
2005 EXPECT_HRESULT_SUCCEEDED( | 2001 EXPECT_HRESULT_SUCCEEDED( |
2006 cell1->accNavigate(NAVDIR_DOWN, childid_self, variant.Receive())); | 2002 cell1->accNavigate(NAVDIR_DOWN, childid_self, variant.Receive())); |
2007 ASSERT_EQ(VT_EMPTY, variant.type()); | 2003 ASSERT_EQ(VT_EMPTY, variant.type()); |
2008 | 2004 |
2009 // Try navigating to the cell in the first row, 2nd column. | 2005 // Try navigating to the cell in the first row, 2nd column. |
2010 base::win::ScopedComPtr<IAccessible2> cell2; | 2006 base::win::ScopedComPtr<IAccessible2> cell2; |
2011 EXPECT_HRESULT_SUCCEEDED( | 2007 EXPECT_HRESULT_SUCCEEDED( |
2012 cell1->accNavigate(NAVDIR_RIGHT, childid_self, variant.Receive())); | 2008 cell1->accNavigate(NAVDIR_RIGHT, childid_self, variant.Receive())); |
2013 ASSERT_NE(nullptr, V_DISPATCH(variant.AsInput())); | 2009 ASSERT_NE(nullptr, V_DISPATCH(variant.AsInput())); |
2014 ASSERT_EQ(VT_DISPATCH, variant.type()); | 2010 ASSERT_EQ(VT_DISPATCH, variant.type()); |
2015 V_DISPATCH(variant.AsInput())->QueryInterface(cell2.Receive()); | 2011 V_DISPATCH(variant.AsInput())->QueryInterface(cell2.GetAddressOf()); |
2016 EXPECT_HRESULT_SUCCEEDED(cell2->role(&role)); | 2012 EXPECT_HRESULT_SUCCEEDED(cell2->role(&role)); |
2017 EXPECT_EQ(ROLE_SYSTEM_CELL, role); | 2013 EXPECT_EQ(ROLE_SYSTEM_CELL, role); |
2018 EXPECT_HRESULT_SUCCEEDED(cell2->get_accName(childid_self, name.Receive())); | 2014 EXPECT_HRESULT_SUCCEEDED(cell2->get_accName(childid_self, name.Receive())); |
2019 // EXPECT_STREQ(L"BC", name); | 2015 // EXPECT_STREQ(L"BC", name); |
2020 EXPECT_HRESULT_SUCCEEDED(cell2.CopyTo(accessible_cell.Receive())); | 2016 EXPECT_HRESULT_SUCCEEDED(cell2.CopyTo(accessible_cell.GetAddressOf())); |
2021 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); | 2017 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); |
2022 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); | 2018 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); |
2023 EXPECT_EQ(0, row_index); | 2019 EXPECT_EQ(0, row_index); |
2024 EXPECT_EQ(1, column_index); | 2020 EXPECT_EQ(1, column_index); |
2025 variant.Reset(); | 2021 variant.Reset(); |
2026 name.Reset(); | 2022 name.Reset(); |
2027 accessible_cell.Reset(); | 2023 accessible_cell.Reset(); |
2028 | 2024 |
2029 // Try navigating to the cell in the second row, 2nd column. | 2025 // Try navigating to the cell in the second row, 2nd column. |
2030 base::win::ScopedComPtr<IAccessible2> cell3; | 2026 base::win::ScopedComPtr<IAccessible2> cell3; |
2031 EXPECT_HRESULT_SUCCEEDED( | 2027 EXPECT_HRESULT_SUCCEEDED( |
2032 cell2->accNavigate(NAVDIR_DOWN, childid_self, variant.Receive())); | 2028 cell2->accNavigate(NAVDIR_DOWN, childid_self, variant.Receive())); |
2033 ASSERT_NE(nullptr, V_DISPATCH(variant.AsInput())); | 2029 ASSERT_NE(nullptr, V_DISPATCH(variant.AsInput())); |
2034 ASSERT_EQ(VT_DISPATCH, variant.type()); | 2030 ASSERT_EQ(VT_DISPATCH, variant.type()); |
2035 V_DISPATCH(variant.AsInput())->QueryInterface(cell3.Receive()); | 2031 V_DISPATCH(variant.AsInput())->QueryInterface(cell3.GetAddressOf()); |
2036 EXPECT_HRESULT_SUCCEEDED(cell3->role(&role)); | 2032 EXPECT_HRESULT_SUCCEEDED(cell3->role(&role)); |
2037 EXPECT_EQ(ROLE_SYSTEM_CELL, role); | 2033 EXPECT_EQ(ROLE_SYSTEM_CELL, role); |
2038 EXPECT_HRESULT_SUCCEEDED(cell3->get_accName(childid_self, name.Receive())); | 2034 EXPECT_HRESULT_SUCCEEDED(cell3->get_accName(childid_self, name.Receive())); |
2039 // EXPECT_STREQ(L"EF", name); | 2035 // EXPECT_STREQ(L"EF", name); |
2040 EXPECT_HRESULT_SUCCEEDED(cell3.CopyTo(accessible_cell.Receive())); | 2036 EXPECT_HRESULT_SUCCEEDED(cell3.CopyTo(accessible_cell.GetAddressOf())); |
2041 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); | 2037 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); |
2042 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); | 2038 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); |
2043 EXPECT_EQ(1, row_index); | 2039 EXPECT_EQ(1, row_index); |
2044 EXPECT_EQ(1, column_index); | 2040 EXPECT_EQ(1, column_index); |
2045 variant.Reset(); | 2041 variant.Reset(); |
2046 name.Reset(); | 2042 name.Reset(); |
2047 accessible_cell.Reset(); | 2043 accessible_cell.Reset(); |
2048 } | 2044 } |
2049 | 2045 |
2050 } // namespace content | 2046 } // namespace content |
OLD | NEW |