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

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

Issue 2870263002: Rename ScopedComPtr::Receive to ScopedComPtr::GetAddressOf (Closed)
Patch Set: Rebase to 2a6f440 Created 3 years, 7 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
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 "ui/accessibility/platform/ax_platform_node.h" 5 #include "ui/accessibility/platform/ax_platform_node.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 #include <oleacc.h> 9 #include <oleacc.h>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ScopedComPtr<IAccessible> GetRootIAccessible() { 92 ScopedComPtr<IAccessible> GetRootIAccessible() {
93 return IAccessibleFromNode(GetRootNode()); 93 return IAccessibleFromNode(GetRootNode());
94 } 94 }
95 95
96 ScopedComPtr<IAccessible2> ToIAccessible2( 96 ScopedComPtr<IAccessible2> ToIAccessible2(
97 ScopedComPtr<IAccessible> accessible) { 97 ScopedComPtr<IAccessible> accessible) {
98 CHECK(accessible.Get()); 98 CHECK(accessible.Get());
99 ScopedComPtr<IServiceProvider> service_provider; 99 ScopedComPtr<IServiceProvider> service_provider;
100 service_provider.QueryFrom(accessible.Get()); 100 service_provider.QueryFrom(accessible.Get());
101 ScopedComPtr<IAccessible2> result; 101 ScopedComPtr<IAccessible2> result;
102 CHECK(SUCCEEDED( 102 CHECK(SUCCEEDED(service_provider->QueryService(IID_IAccessible2,
103 service_provider->QueryService(IID_IAccessible2, result.Receive()))); 103 result.GetAddressOf())));
104 return result; 104 return result;
105 } 105 }
106 106
107 std::unique_ptr<AXTree> tree_; 107 std::unique_ptr<AXTree> tree_;
108 }; 108 };
109 109
110 TEST_F(AXPlatformNodeWinTest, TestIAccessibleDetachedObject) { 110 TEST_F(AXPlatformNodeWinTest, TestIAccessibleDetachedObject) {
111 AXNodeData root; 111 AXNodeData root;
112 root.id = 1; 112 root.id = 1;
113 root.AddStringAttribute(AX_ATTR_NAME, "Name"); 113 root.AddStringAttribute(AX_ATTR_NAME, "Name");
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 LONG child_count; 283 LONG child_count;
284 EXPECT_EQ(S_OK, root_iaccessible->get_accChildCount(&child_count)); 284 EXPECT_EQ(S_OK, root_iaccessible->get_accChildCount(&child_count));
285 EXPECT_EQ(2L, child_count); 285 EXPECT_EQ(2L, child_count);
286 EXPECT_EQ(S_OK, button_iaccessible->get_accChildCount(&child_count)); 286 EXPECT_EQ(S_OK, button_iaccessible->get_accChildCount(&child_count));
287 EXPECT_EQ(0L, child_count); 287 EXPECT_EQ(0L, child_count);
288 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accChildCount(&child_count)); 288 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accChildCount(&child_count));
289 EXPECT_EQ(0L, child_count); 289 EXPECT_EQ(0L, child_count);
290 290
291 { 291 {
292 ScopedComPtr<IDispatch> result; 292 ScopedComPtr<IDispatch> result;
293 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(SELF, result.Receive())); 293 EXPECT_EQ(S_OK,
294 root_iaccessible->get_accChild(SELF, result.GetAddressOf()));
294 EXPECT_EQ(result.Get(), root_iaccessible); 295 EXPECT_EQ(result.Get(), root_iaccessible);
295 } 296 }
296 297
297 { 298 {
298 ScopedComPtr<IDispatch> result; 299 ScopedComPtr<IDispatch> result;
299 ScopedVariant child1(1); 300 ScopedVariant child1(1);
300 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(child1, result.Receive())); 301 EXPECT_EQ(S_OK,
302 root_iaccessible->get_accChild(child1, result.GetAddressOf()));
301 EXPECT_EQ(result.Get(), button_iaccessible); 303 EXPECT_EQ(result.Get(), button_iaccessible);
302 } 304 }
303 305
304 { 306 {
305 ScopedComPtr<IDispatch> result; 307 ScopedComPtr<IDispatch> result;
306 ScopedVariant child2(2); 308 ScopedVariant child2(2);
307 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(child2, result.Receive())); 309 EXPECT_EQ(S_OK,
310 root_iaccessible->get_accChild(child2, result.GetAddressOf()));
308 EXPECT_EQ(result.Get(), checkbox_iaccessible); 311 EXPECT_EQ(result.Get(), checkbox_iaccessible);
309 } 312 }
310 313
311 { 314 {
312 // Asking for child id 3 should fail. 315 // Asking for child id 3 should fail.
313 ScopedComPtr<IDispatch> result; 316 ScopedComPtr<IDispatch> result;
314 ScopedVariant child3(3); 317 ScopedVariant child3(3);
315 EXPECT_EQ(E_INVALIDARG, 318 EXPECT_EQ(E_INVALIDARG,
316 root_iaccessible->get_accChild(child3, result.Receive())); 319 root_iaccessible->get_accChild(child3, result.GetAddressOf()));
317 } 320 }
318 321
319 // 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.
320 LONG button_unique_id; 323 LONG button_unique_id;
321 ScopedComPtr<IAccessible2> button_iaccessible2 = 324 ScopedComPtr<IAccessible2> button_iaccessible2 =
322 ToIAccessible2(button_iaccessible); 325 ToIAccessible2(button_iaccessible);
323 button_iaccessible2->get_uniqueID(&button_unique_id); 326 button_iaccessible2->get_uniqueID(&button_unique_id);
324 ASSERT_LT(button_unique_id, 0); 327 ASSERT_LT(button_unique_id, 0);
325 { 328 {
326 ScopedComPtr<IDispatch> result; 329 ScopedComPtr<IDispatch> result;
327 ScopedVariant button_id_variant(button_unique_id); 330 ScopedVariant button_id_variant(button_unique_id);
328 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(button_id_variant, 331 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(button_id_variant,
329 result.Receive())); 332 result.GetAddressOf()));
330 EXPECT_EQ(result.Get(), button_iaccessible); 333 EXPECT_EQ(result.Get(), button_iaccessible);
331 } 334 }
332 335
333 // We shouldn't be able to ask for the root node by its unique ID 336 // We shouldn't be able to ask for the root node by its unique ID
334 // from one of its children, though. 337 // from one of its children, though.
335 LONG root_unique_id; 338 LONG root_unique_id;
336 ScopedComPtr<IAccessible2> root_iaccessible2 = 339 ScopedComPtr<IAccessible2> root_iaccessible2 =
337 ToIAccessible2(root_iaccessible); 340 ToIAccessible2(root_iaccessible);
338 root_iaccessible2->get_uniqueID(&root_unique_id); 341 root_iaccessible2->get_uniqueID(&root_unique_id);
339 ASSERT_LT(root_unique_id, 0); 342 ASSERT_LT(root_unique_id, 0);
340 { 343 {
341 ScopedComPtr<IDispatch> result; 344 ScopedComPtr<IDispatch> result;
342 ScopedVariant root_id_variant(root_unique_id); 345 ScopedVariant root_id_variant(root_unique_id);
343 EXPECT_EQ(E_INVALIDARG, button_iaccessible->get_accChild(root_id_variant, 346 EXPECT_EQ(E_INVALIDARG, button_iaccessible->get_accChild(
344 result.Receive())); 347 root_id_variant, result.GetAddressOf()));
345 } 348 }
346 349
347 // Now check parents. 350 // Now check parents.
348 { 351 {
349 ScopedComPtr<IDispatch> result; 352 ScopedComPtr<IDispatch> result;
350 EXPECT_EQ(S_OK, button_iaccessible->get_accParent(result.Receive())); 353 EXPECT_EQ(S_OK, button_iaccessible->get_accParent(result.GetAddressOf()));
351 EXPECT_EQ(result.Get(), root_iaccessible); 354 EXPECT_EQ(result.Get(), root_iaccessible);
352 } 355 }
353 356
354 { 357 {
355 ScopedComPtr<IDispatch> result; 358 ScopedComPtr<IDispatch> result;
356 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accParent(result.Receive())); 359 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accParent(result.GetAddressOf()));
357 EXPECT_EQ(result.Get(), root_iaccessible); 360 EXPECT_EQ(result.Get(), root_iaccessible);
358 } 361 }
359 362
360 { 363 {
361 ScopedComPtr<IDispatch> result; 364 ScopedComPtr<IDispatch> result;
362 EXPECT_EQ(S_FALSE, root_iaccessible->get_accParent(result.Receive())); 365 EXPECT_EQ(S_FALSE, root_iaccessible->get_accParent(result.GetAddressOf()));
363 } 366 }
364 } 367 }
365 368
366 TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) { 369 TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) {
367 AXNodeData root; 370 AXNodeData root;
368 root.id = 1; 371 root.id = 1;
369 root.child_ids.push_back(2); 372 root.child_ids.push_back(2);
370 root.child_ids.push_back(3); 373 root.child_ids.push_back(3);
371 374
372 AXNodeData left; 375 AXNodeData left;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 1, 0)); 419 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 1, 0));
417 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 2, 2)); 420 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 2, 2));
418 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, IA2_TEXT_OFFSET_CARET, 421 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, IA2_TEXT_OFFSET_CARET,
419 IA2_TEXT_OFFSET_LENGTH)); 422 IA2_TEXT_OFFSET_LENGTH));
420 423
421 EXPECT_HRESULT_FAILED(text_field->setSelection(1, 0, 0)); 424 EXPECT_HRESULT_FAILED(text_field->setSelection(1, 0, 0));
422 EXPECT_HRESULT_FAILED(text_field->setSelection(0, 0, 5)); 425 EXPECT_HRESULT_FAILED(text_field->setSelection(0, 0, 5));
423 } 426 }
424 427
425 } // namespace ui 428 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.cc ('k') | ui/base/dragdrop/os_exchange_data_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698