Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: ui/accessibility/platform/ax_platform_node_win_unittest.cc

Issue 1811403002: IAccessible::get_accChild should only return a descendant. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlcom.h> 6 #include <atlcom.h>
7 #include <oleacc.h> 7 #include <oleacc.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/win/scoped_bstr.h" 10 #include "base/win/scoped_bstr.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ScopedComPtr<IDispatch> result; 308 ScopedComPtr<IDispatch> result;
309 ScopedVariant child2(2); 309 ScopedVariant child2(2);
310 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(child2, result.Receive())); 310 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(child2, result.Receive()));
311 ASSERT_EQ(result.get(), checkbox_iaccessible); 311 ASSERT_EQ(result.get(), checkbox_iaccessible);
312 } 312 }
313 313
314 { 314 {
315 // Asking for child id 3 should fail. 315 // Asking for child id 3 should fail.
316 ScopedComPtr<IDispatch> result; 316 ScopedComPtr<IDispatch> result;
317 ScopedVariant child3(3); 317 ScopedVariant child3(3);
318 ASSERT_EQ(E_FAIL, root_iaccessible->get_accChild(child3, result.Receive())); 318 ASSERT_EQ(E_INVALIDARG,
319 root_iaccessible->get_accChild(child3, result.Receive()));
319 } 320 }
320 321
321 // We should be able to ask for the button by its unique id too. 322 // We should be able to ask for the button by its unique id too.
322 LONG button_unique_id; 323 LONG button_unique_id;
323 ScopedComPtr<IAccessible2> button_iaccessible2 = 324 ScopedComPtr<IAccessible2> button_iaccessible2 =
324 ToIAccessible2(button_iaccessible); 325 ToIAccessible2(button_iaccessible);
325 button_iaccessible2->get_uniqueID(&button_unique_id); 326 button_iaccessible2->get_uniqueID(&button_unique_id);
326 ASSERT_LT(button_unique_id, 0); 327 ASSERT_LT(button_unique_id, 0);
327 { 328 {
328 ScopedComPtr<IDispatch> result; 329 ScopedComPtr<IDispatch> result;
329 ScopedVariant button_id_variant(button_unique_id); 330 ScopedVariant button_id_variant(button_unique_id);
330 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(button_id_variant, 331 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(button_id_variant,
331 result.Receive())); 332 result.Receive()));
332 ASSERT_EQ(result.get(), button_iaccessible); 333 ASSERT_EQ(result.get(), button_iaccessible);
333 } 334 }
334 335
336 // We shouldn't be able to ask for the root node by its unique ID
337 // from one of its children, though.
338 LONG root_unique_id;
339 ScopedComPtr<IAccessible2> root_iaccessible2 =
340 ToIAccessible2(root_iaccessible);
341 root_iaccessible2->get_uniqueID(&root_unique_id);
342 ASSERT_LT(root_unique_id, 0);
343 {
344 ScopedComPtr<IDispatch> result;
345 ScopedVariant root_id_variant(root_unique_id);
346 ASSERT_EQ(E_INVALIDARG, button_iaccessible->get_accChild(root_id_variant,
347 result.Receive()));
348 }
349
335 // Now check parents. 350 // Now check parents.
336 { 351 {
337 ScopedComPtr<IDispatch> result; 352 ScopedComPtr<IDispatch> result;
338 ASSERT_EQ(S_OK, button_iaccessible->get_accParent(result.Receive())); 353 ASSERT_EQ(S_OK, button_iaccessible->get_accParent(result.Receive()));
339 ASSERT_EQ(result.get(), root_iaccessible); 354 ASSERT_EQ(result.get(), root_iaccessible);
340 } 355 }
341 356
342 { 357 {
343 ScopedComPtr<IDispatch> result; 358 ScopedComPtr<IDispatch> result;
344 ASSERT_EQ(S_OK, checkbox_iaccessible->get_accParent(result.Receive())); 359 ASSERT_EQ(S_OK, checkbox_iaccessible->get_accParent(result.Receive()));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 ASSERT_EQ(E_FAIL, root_iaccessible2->get_indexInParent(&index)); 396 ASSERT_EQ(E_FAIL, root_iaccessible2->get_indexInParent(&index));
382 397
383 ASSERT_EQ(S_OK, left_iaccessible2->get_indexInParent(&index)); 398 ASSERT_EQ(S_OK, left_iaccessible2->get_indexInParent(&index));
384 EXPECT_EQ(0, index); 399 EXPECT_EQ(0, index);
385 400
386 ASSERT_EQ(S_OK, right_iaccessible2->get_indexInParent(&index)); 401 ASSERT_EQ(S_OK, right_iaccessible2->get_indexInParent(&index));
387 EXPECT_EQ(1, index); 402 EXPECT_EQ(1, index);
388 } 403 }
389 404
390 } // namespace ui 405 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698