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 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/win/scoped_bstr.h" 9 #include "base/win/scoped_bstr.h"
10 #include "base/win/scoped_comptr.h" 10 #include "base/win/scoped_comptr.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() { 142 AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() {
143 } 143 }
144 144
145 AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() { 145 AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() {
146 } 146 }
147 147
148 void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( 148 void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml(
149 const std::string& html) { 149 const std::string& html) {
150 AccessibilityNotificationWaiter waiter( 150 AccessibilityNotificationWaiter waiter(
151 shell(), AccessibilityModeComplete, 151 shell(), AccessibilityModeComplete,
152 WebKit::WebAXEventLoadComplete); 152 blink::WebAXEventLoadComplete);
153 GURL html_data_url("data:text/html," + html); 153 GURL html_data_url("data:text/html," + html);
154 NavigateToURL(shell(), html_data_url); 154 NavigateToURL(shell(), html_data_url);
155 waiter.WaitForNotification(); 155 waiter.WaitForNotification();
156 } 156 }
157 157
158 // Retrieve the MSAA client accessibility object for the Render Widget Host View 158 // Retrieve the MSAA client accessibility object for the Render Widget Host View
159 // of the selected tab. 159 // of the selected tab.
160 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() { 160 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() {
161 HWND hwnd_render_widget_host_view = 161 HWND hwnd_render_widget_host_view =
162 shell()->web_contents()->GetRenderWidgetHostView()->GetNativeView(); 162 shell()->web_contents()->GetRenderWidgetHostView()->GetNativeView();
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 list_item_checker.AppendExpectedChild(&list_marker_checker); 497 list_item_checker.AppendExpectedChild(&list_marker_checker);
498 list_item_checker.AppendExpectedChild(&static_text_checker); 498 list_item_checker.AppendExpectedChild(&static_text_checker);
499 radio_group_checker.AppendExpectedChild(&list_item_checker); 499 radio_group_checker.AppendExpectedChild(&list_item_checker);
500 document_checker.AppendExpectedChild(&radio_group_checker); 500 document_checker.AppendExpectedChild(&radio_group_checker);
501 document_checker.CheckAccessible(GetRendererAccessible()); 501 document_checker.CheckAccessible(GetRendererAccessible());
502 502
503 // Set focus to the radio group. 503 // Set focus to the radio group.
504 scoped_ptr<AccessibilityNotificationWaiter> waiter( 504 scoped_ptr<AccessibilityNotificationWaiter> waiter(
505 new AccessibilityNotificationWaiter( 505 new AccessibilityNotificationWaiter(
506 shell(), AccessibilityModeComplete, 506 shell(), AccessibilityModeComplete,
507 WebKit::WebAXEventFocus)); 507 blink::WebAXEventFocus));
508 ExecuteScript(L"document.body.children[0].focus()"); 508 ExecuteScript(L"document.body.children[0].focus()");
509 waiter->WaitForNotification(); 509 waiter->WaitForNotification();
510 510
511 // Check that the accessibility tree of the browser has been updated. 511 // Check that the accessibility tree of the browser has been updated.
512 radio_group_checker.SetExpectedState( 512 radio_group_checker.SetExpectedState(
513 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 513 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
514 document_checker.CheckAccessible(GetRendererAccessible()); 514 document_checker.CheckAccessible(GetRendererAccessible());
515 515
516 // Set the active descendant of the radio group 516 // Set the active descendant of the radio group
517 waiter.reset(new AccessibilityNotificationWaiter( 517 waiter.reset(new AccessibilityNotificationWaiter(
518 shell(), AccessibilityModeComplete, 518 shell(), AccessibilityModeComplete,
519 WebKit::WebAXEventFocus)); 519 blink::WebAXEventFocus));
520 ExecuteScript( 520 ExecuteScript(
521 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); 521 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')");
522 waiter->WaitForNotification(); 522 waiter->WaitForNotification();
523 523
524 // Check that the accessibility tree of the browser has been updated. 524 // Check that the accessibility tree of the browser has been updated.
525 list_item_checker.SetExpectedState( 525 list_item_checker.SetExpectedState(
526 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 526 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
527 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 527 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
528 document_checker.CheckAccessible(GetRendererAccessible()); 528 document_checker.CheckAccessible(GetRendererAccessible());
529 } 529 }
(...skipping 12 matching lines...) Expand all
542 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 542 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
543 std::wstring()); 543 std::wstring());
544 body_checker.AppendExpectedChild(&checkbox_checker); 544 body_checker.AppendExpectedChild(&checkbox_checker);
545 document_checker.AppendExpectedChild(&body_checker); 545 document_checker.AppendExpectedChild(&body_checker);
546 document_checker.CheckAccessible(GetRendererAccessible()); 546 document_checker.CheckAccessible(GetRendererAccessible());
547 547
548 // Check the checkbox. 548 // Check the checkbox.
549 scoped_ptr<AccessibilityNotificationWaiter> waiter( 549 scoped_ptr<AccessibilityNotificationWaiter> waiter(
550 new AccessibilityNotificationWaiter( 550 new AccessibilityNotificationWaiter(
551 shell(), AccessibilityModeComplete, 551 shell(), AccessibilityModeComplete,
552 WebKit::WebAXEventCheckedStateChanged)); 552 blink::WebAXEventCheckedStateChanged));
553 ExecuteScript(L"document.body.children[0].checked=true"); 553 ExecuteScript(L"document.body.children[0].checked=true");
554 waiter->WaitForNotification(); 554 waiter->WaitForNotification();
555 555
556 // Check that the accessibility tree of the browser has been updated. 556 // Check that the accessibility tree of the browser has been updated.
557 checkbox_checker.SetExpectedState( 557 checkbox_checker.SetExpectedState(
558 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); 558 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE);
559 document_checker.CheckAccessible(GetRendererAccessible()); 559 document_checker.CheckAccessible(GetRendererAccessible());
560 } 560 }
561 561
562 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 562 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
563 MAYBE(TestNotificationChildrenChanged)) { 563 MAYBE(TestNotificationChildrenChanged)) {
564 // The role attribute causes the node to be in the accessibility tree. 564 // The role attribute causes the node to be in the accessibility tree.
565 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); 565 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>");
566 566
567 // Check the browser's copy of the renderer accessibility tree. 567 // Check the browser's copy of the renderer accessibility tree.
568 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 568 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
569 std::wstring()); 569 std::wstring());
570 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 570 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
571 std::wstring()); 571 std::wstring());
572 document_checker.AppendExpectedChild(&group_checker); 572 document_checker.AppendExpectedChild(&group_checker);
573 document_checker.CheckAccessible(GetRendererAccessible()); 573 document_checker.CheckAccessible(GetRendererAccessible());
574 574
575 // Change the children of the document body. 575 // Change the children of the document body.
576 scoped_ptr<AccessibilityNotificationWaiter> waiter( 576 scoped_ptr<AccessibilityNotificationWaiter> waiter(
577 new AccessibilityNotificationWaiter( 577 new AccessibilityNotificationWaiter(
578 shell(), 578 shell(),
579 AccessibilityModeComplete, 579 AccessibilityModeComplete,
580 WebKit::WebAXEventChildrenChanged)); 580 blink::WebAXEventChildrenChanged));
581 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); 581 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'");
582 waiter->WaitForNotification(); 582 waiter->WaitForNotification();
583 583
584 // Check that the accessibility tree of the browser has been updated. 584 // Check that the accessibility tree of the browser has been updated.
585 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, std::wstring()); 585 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, std::wstring());
586 group_checker.AppendExpectedChild(&text_checker); 586 group_checker.AppendExpectedChild(&text_checker);
587 document_checker.CheckAccessible(GetRendererAccessible()); 587 document_checker.CheckAccessible(GetRendererAccessible());
588 } 588 }
589 589
590 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 590 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
591 MAYBE(TestNotificationChildrenChanged2)) { 591 MAYBE(TestNotificationChildrenChanged2)) {
592 // The role attribute causes the node to be in the accessibility tree. 592 // The role attribute causes the node to be in the accessibility tree.
593 LoadInitialAccessibilityTreeFromHtml( 593 LoadInitialAccessibilityTreeFromHtml(
594 "<div role=group style='visibility: hidden'>text</div>"); 594 "<div role=group style='visibility: hidden'>text</div>");
595 595
596 // Check the accessible tree of the browser. 596 // Check the accessible tree of the browser.
597 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 597 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
598 std::wstring()); 598 std::wstring());
599 document_checker.CheckAccessible(GetRendererAccessible()); 599 document_checker.CheckAccessible(GetRendererAccessible());
600 600
601 // Change the children of the document body. 601 // Change the children of the document body.
602 scoped_ptr<AccessibilityNotificationWaiter> waiter( 602 scoped_ptr<AccessibilityNotificationWaiter> waiter(
603 new AccessibilityNotificationWaiter( 603 new AccessibilityNotificationWaiter(
604 shell(), AccessibilityModeComplete, 604 shell(), AccessibilityModeComplete,
605 WebKit::WebAXEventChildrenChanged)); 605 blink::WebAXEventChildrenChanged));
606 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); 606 ExecuteScript(L"document.body.children[0].style.visibility='visible'");
607 waiter->WaitForNotification(); 607 waiter->WaitForNotification();
608 608
609 // Check that the accessibility tree of the browser has been updated. 609 // Check that the accessibility tree of the browser has been updated.
610 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, 610 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT,
611 std::wstring()); 611 std::wstring());
612 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 612 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
613 std::wstring()); 613 std::wstring());
614 document_checker.AppendExpectedChild(&group_checker); 614 document_checker.AppendExpectedChild(&group_checker);
615 group_checker.AppendExpectedChild(&static_text_checker); 615 group_checker.AppendExpectedChild(&static_text_checker);
(...skipping 12 matching lines...) Expand all
628 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 628 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
629 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 629 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
630 std::wstring()); 630 std::wstring());
631 document_checker.AppendExpectedChild(&group_checker); 631 document_checker.AppendExpectedChild(&group_checker);
632 document_checker.CheckAccessible(GetRendererAccessible()); 632 document_checker.CheckAccessible(GetRendererAccessible());
633 633
634 // Focus the div in the document 634 // Focus the div in the document
635 scoped_ptr<AccessibilityNotificationWaiter> waiter( 635 scoped_ptr<AccessibilityNotificationWaiter> waiter(
636 new AccessibilityNotificationWaiter( 636 new AccessibilityNotificationWaiter(
637 shell(), AccessibilityModeComplete, 637 shell(), AccessibilityModeComplete,
638 WebKit::WebAXEventFocus)); 638 blink::WebAXEventFocus));
639 ExecuteScript(L"document.body.children[0].focus()"); 639 ExecuteScript(L"document.body.children[0].focus()");
640 waiter->WaitForNotification(); 640 waiter->WaitForNotification();
641 641
642 // Check that the accessibility tree of the browser has been updated. 642 // Check that the accessibility tree of the browser has been updated.
643 SCOPED_TRACE("Check updated tree after focusing div"); 643 SCOPED_TRACE("Check updated tree after focusing div");
644 group_checker.SetExpectedState( 644 group_checker.SetExpectedState(
645 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 645 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
646 document_checker.CheckAccessible(GetRendererAccessible()); 646 document_checker.CheckAccessible(GetRendererAccessible());
647 647
648 // Focus the document accessible. This will un-focus the current node. 648 // Focus the document accessible. This will un-focus the current node.
649 waiter.reset( 649 waiter.reset(
650 new AccessibilityNotificationWaiter( 650 new AccessibilityNotificationWaiter(
651 shell(), AccessibilityModeComplete, 651 shell(), AccessibilityModeComplete,
652 WebKit::WebAXEventBlur)); 652 blink::WebAXEventBlur));
653 base::win::ScopedComPtr<IAccessible> document_accessible( 653 base::win::ScopedComPtr<IAccessible> document_accessible(
654 GetRendererAccessible()); 654 GetRendererAccessible());
655 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 655 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
656 base::win::ScopedVariant childid_self(CHILDID_SELF); 656 base::win::ScopedVariant childid_self(CHILDID_SELF);
657 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); 657 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self);
658 ASSERT_EQ(S_OK, hr); 658 ASSERT_EQ(S_OK, hr);
659 waiter->WaitForNotification(); 659 waiter->WaitForNotification();
660 660
661 // Check that the accessibility tree of the browser has been updated. 661 // Check that the accessibility tree of the browser has been updated.
662 SCOPED_TRACE("Check updated tree after focusing document again"); 662 SCOPED_TRACE("Check updated tree after focusing document again");
(...skipping 15 matching lines...) Expand all
678 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 678 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
679 std::wstring()); 679 std::wstring());
680 body_checker.AppendExpectedChild(&text_field_checker); 680 body_checker.AppendExpectedChild(&text_field_checker);
681 document_checker.AppendExpectedChild(&body_checker); 681 document_checker.AppendExpectedChild(&body_checker);
682 document_checker.CheckAccessible(GetRendererAccessible()); 682 document_checker.CheckAccessible(GetRendererAccessible());
683 683
684 // Set the value of the text control 684 // Set the value of the text control
685 scoped_ptr<AccessibilityNotificationWaiter> waiter( 685 scoped_ptr<AccessibilityNotificationWaiter> waiter(
686 new AccessibilityNotificationWaiter( 686 new AccessibilityNotificationWaiter(
687 shell(), AccessibilityModeComplete, 687 shell(), AccessibilityModeComplete,
688 WebKit::WebAXEventValueChanged)); 688 blink::WebAXEventValueChanged));
689 ExecuteScript(L"document.body.children[0].value='new value'"); 689 ExecuteScript(L"document.body.children[0].value='new value'");
690 waiter->WaitForNotification(); 690 waiter->WaitForNotification();
691 691
692 // Check that the accessibility tree of the browser has been updated. 692 // Check that the accessibility tree of the browser has been updated.
693 text_field_checker.SetExpectedValue(L"new value"); 693 text_field_checker.SetExpectedValue(L"new value");
694 document_checker.CheckAccessible(GetRendererAccessible()); 694 document_checker.CheckAccessible(GetRendererAccessible());
695 } 695 }
696 696
697 // This test verifies that the web content's accessibility tree is a 697 // This test verifies that the web content's accessibility tree is a
698 // descendant of the main browser window's accessibility tree, so that 698 // descendant of the main browser window's accessibility tree, so that
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 AccessibleChecker grouping2_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 874 AccessibleChecker grouping2_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
875 std::wstring()); 875 std::wstring());
876 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 876 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
877 std::wstring()); 877 std::wstring());
878 document_checker.AppendExpectedChild(&grouping1_checker); 878 document_checker.AppendExpectedChild(&grouping1_checker);
879 document_checker.AppendExpectedChild(&grouping2_checker); 879 document_checker.AppendExpectedChild(&grouping2_checker);
880 document_checker.CheckAccessible(GetRendererAccessible()); 880 document_checker.CheckAccessible(GetRendererAccessible());
881 } 881 }
882 882
883 } // namespace content 883 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698