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

Side by Side Diff: content/browser/accessibility/accessibility_win_browsertest.cc

Issue 985853005: base: Remove operator& from ScopedVariant and ScopedPropVariant. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scoped-operator: ptr() Created 5 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
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/win/scoped_bstr.h" 10 #include "base/win/scoped_bstr.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 std::wstring name(name_bstr, name_bstr.Length()); 272 std::wstring name(name_bstr, name_bstr.Length());
273 base::win::ScopedVariant role; 273 base::win::ScopedVariant role;
274 node->get_accRole(childid_self, role.Receive()); 274 node->get_accRole(childid_self, role.Receive());
275 ASSERT_EQ(VT_I4, role.type()); 275 ASSERT_EQ(VT_I4, role.type());
276 276
277 // Print the accessibility tree as we go, because if this test fails 277 // Print the accessibility tree as we go, because if this test fails
278 // on the bots, this is really helpful in figuring out why. 278 // on the bots, this is really helpful in figuring out why.
279 for (int i = 0; i < depth; i++) 279 for (int i = 0; i < depth; i++)
280 printf(" "); 280 printf(" ");
281 printf("role=%s name=%s\n", 281 printf("role=%s name=%s\n",
282 base::WideToUTF8(IAccessibleRoleToString(V_I4(&role))).c_str(), 282 base::WideToUTF8(IAccessibleRoleToString(V_I4(role.ptr()))).c_str(),
283 base::WideToUTF8(name).c_str()); 283 base::WideToUTF8(name).c_str());
284 284
285 if (expected_role == V_I4(&role) && expected_name == name) { 285 if (expected_role == V_I4(role.ptr()) && expected_name == name) {
286 *found = true; 286 *found = true;
287 return; 287 return;
288 } 288 }
289 289
290 std::vector<base::win::ScopedVariant> children = GetAllAccessibleChildren( 290 std::vector<base::win::ScopedVariant> children = GetAllAccessibleChildren(
291 node); 291 node);
292 for (size_t i = 0; i < children.size(); ++i) { 292 for (size_t i = 0; i < children.size(); ++i) {
293 base::win::ScopedComPtr<IAccessible> child_accessible( 293 base::win::ScopedComPtr<IAccessible> child_accessible(
294 GetAccessibleFromVariant(node, children[i].AsInput())); 294 GetAccessibleFromVariant(node, children[i].AsInput()));
295 if (child_accessible) { 295 if (child_accessible) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 521
522 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleValue( 522 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleValue(
523 IAccessible* accessible) { 523 IAccessible* accessible) {
524 // Don't check the value if if's a DOCUMENT role, because the value 524 // Don't check the value if if's a DOCUMENT role, because the value
525 // is supposed to be the url (and we don't keep track of that in the 525 // is supposed to be the url (and we don't keep track of that in the
526 // test expectations). 526 // test expectations).
527 base::win::ScopedVariant role; 527 base::win::ScopedVariant role;
528 base::win::ScopedVariant childid_self(CHILDID_SELF); 528 base::win::ScopedVariant childid_self(CHILDID_SELF);
529 HRESULT hr = accessible->get_accRole(childid_self, role.Receive()); 529 HRESULT hr = accessible->get_accRole(childid_self, role.Receive());
530 ASSERT_EQ(S_OK, hr); 530 ASSERT_EQ(S_OK, hr);
531 if (role.type() == VT_I4 && V_I4(&role) == ROLE_SYSTEM_DOCUMENT) 531 if (role.type() == VT_I4 && V_I4(role.ptr()) == ROLE_SYSTEM_DOCUMENT)
532 return; 532 return;
533 533
534 // Get the value. 534 // Get the value.
535 base::win::ScopedBstr value; 535 base::win::ScopedBstr value;
536 hr = accessible->get_accValue(childid_self, value.Receive()); 536 hr = accessible->get_accValue(childid_self, value.Receive());
537 EXPECT_EQ(S_OK, hr); 537 EXPECT_EQ(S_OK, hr);
538 538
539 // Test that the correct string was returned. 539 // Test that the correct string was returned.
540 EXPECT_EQ(value_, std::wstring(value, value.Length())); 540 EXPECT_EQ(value_, std::wstring(value, value.Length()));
541 } 541 }
542 542
543 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleState( 543 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleState(
544 IAccessible* accessible) { 544 IAccessible* accessible) {
545 if (state_ < 0) 545 if (state_ < 0)
546 return; 546 return;
547 547
548 base::win::ScopedVariant state; 548 base::win::ScopedVariant state;
549 base::win::ScopedVariant childid_self(CHILDID_SELF); 549 base::win::ScopedVariant childid_self(CHILDID_SELF);
550 HRESULT hr = accessible->get_accState(childid_self, state.Receive()); 550 HRESULT hr = accessible->get_accState(childid_self, state.Receive());
551 EXPECT_EQ(S_OK, hr); 551 EXPECT_EQ(S_OK, hr);
552 ASSERT_EQ(VT_I4, state.type()); 552 ASSERT_EQ(VT_I4, state.type());
553 LONG obj_state = V_I4(&state); 553 LONG obj_state = V_I4(state.ptr());
554 // Avoid flakiness. The "offscreen" state depends on whether the browser 554 // Avoid flakiness. The "offscreen" state depends on whether the browser
555 // window is frontmost or not, and "hottracked" depends on whether the 555 // window is frontmost or not, and "hottracked" depends on whether the
556 // mouse cursor happens to be over the element. 556 // mouse cursor happens to be over the element.
557 obj_state &= ~(STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_HOTTRACKED); 557 obj_state &= ~(STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_HOTTRACKED);
558 EXPECT_EQ(state_, obj_state) 558 EXPECT_EQ(state_, obj_state)
559 << "Expected state: " << IAccessibleStateToString(state_) 559 << "Expected state: " << IAccessibleStateToString(state_)
560 << "\nGot state: " << IAccessibleStateToString(obj_state); 560 << "\nGot state: " << IAccessibleStateToString(obj_state);
561 } 561 }
562 562
563 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleChildren( 563 void AccessibilityWinBrowserTest::AccessibleChecker::CheckAccessibleChildren(
(...skipping 14 matching lines...) Expand all
578 GetAccessibleFromVariant(parent, child->AsInput())); 578 GetAccessibleFromVariant(parent, child->AsInput()));
579 ASSERT_TRUE(child_accessible.get()); 579 ASSERT_TRUE(child_accessible.get());
580 (*child_checker)->CheckAccessible(child_accessible.get()); 580 (*child_checker)->CheckAccessible(child_accessible.get());
581 } 581 }
582 } 582 }
583 583
584 base::string16 584 base::string16
585 AccessibilityWinBrowserTest::AccessibleChecker::RoleVariantToString( 585 AccessibilityWinBrowserTest::AccessibleChecker::RoleVariantToString(
586 const base::win::ScopedVariant& role) { 586 const base::win::ScopedVariant& role) {
587 if (role.type() == VT_I4) 587 if (role.type() == VT_I4)
588 return IAccessibleRoleToString(V_I4(&role)); 588 return IAccessibleRoleToString(V_I4(role.ptr()));
589 if (role.type() == VT_BSTR) 589 if (role.type() == VT_BSTR)
590 return base::string16(V_BSTR(&role), SysStringLen(V_BSTR(&role))); 590 return base::string16(V_BSTR(role.ptr()), SysStringLen(V_BSTR(role.ptr())));
591 return base::string16(); 591 return base::string16();
592 } 592 }
593 593
594 } // namespace 594 } // namespace
595 595
596 596
597 // Tests ---------------------------------------------------------------------- 597 // Tests ----------------------------------------------------------------------
598 598
599 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 599 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
600 TestBusyAccessibilityTree) { 600 TestBusyAccessibilityTree) {
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 1461 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
1462 TestMultiLineTextAtOffsetWithBoundaryAll) { 1462 TestMultiLineTextAtOffsetWithBoundaryAll) {
1463 base::win::ScopedComPtr<IAccessibleText> textarea_text; 1463 base::win::ScopedComPtr<IAccessibleText> textarea_text;
1464 SetUpTextareaField(&textarea_text); 1464 SetUpTextareaField(&textarea_text);
1465 1465
1466 CheckTextAtOffset(textarea_text, CONTENTS_LENGTH - 1, IA2_TEXT_BOUNDARY_ALL, 1466 CheckTextAtOffset(textarea_text, CONTENTS_LENGTH - 1, IA2_TEXT_BOUNDARY_ALL,
1467 0, CONTENTS_LENGTH, base::SysUTF8ToWide(TEXTAREA_CONTENTS)); 1467 0, CONTENTS_LENGTH, base::SysUTF8ToWide(TEXTAREA_CONTENTS));
1468 } 1468 }
1469 1469
1470 } // namespace content 1470 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698