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 <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 Loading... |
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 blink::WebAXEventLoadComplete); | 152 ui::AX_EVENT_LOAD_COMPLETE); |
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 list_item_checker.AppendExpectedChild(&list_marker_checker); | 498 list_item_checker.AppendExpectedChild(&list_marker_checker); |
499 list_item_checker.AppendExpectedChild(&static_text_checker); | 499 list_item_checker.AppendExpectedChild(&static_text_checker); |
500 radio_group_checker.AppendExpectedChild(&list_item_checker); | 500 radio_group_checker.AppendExpectedChild(&list_item_checker); |
501 document_checker.AppendExpectedChild(&radio_group_checker); | 501 document_checker.AppendExpectedChild(&radio_group_checker); |
502 document_checker.CheckAccessible(GetRendererAccessible()); | 502 document_checker.CheckAccessible(GetRendererAccessible()); |
503 | 503 |
504 // Set focus to the radio group. | 504 // Set focus to the radio group. |
505 scoped_ptr<AccessibilityNotificationWaiter> waiter( | 505 scoped_ptr<AccessibilityNotificationWaiter> waiter( |
506 new AccessibilityNotificationWaiter( | 506 new AccessibilityNotificationWaiter( |
507 shell(), AccessibilityModeComplete, | 507 shell(), AccessibilityModeComplete, |
508 blink::WebAXEventFocus)); | 508 ui::AX_EVENT_FOCUS)); |
509 ExecuteScript(L"document.body.children[0].focus()"); | 509 ExecuteScript(L"document.body.children[0].focus()"); |
510 waiter->WaitForNotification(); | 510 waiter->WaitForNotification(); |
511 | 511 |
512 // Check that the accessibility tree of the browser has been updated. | 512 // Check that the accessibility tree of the browser has been updated. |
513 radio_group_checker.SetExpectedState( | 513 radio_group_checker.SetExpectedState( |
514 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); | 514 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); |
515 document_checker.CheckAccessible(GetRendererAccessible()); | 515 document_checker.CheckAccessible(GetRendererAccessible()); |
516 | 516 |
517 // Set the active descendant of the radio group | 517 // Set the active descendant of the radio group |
518 waiter.reset(new AccessibilityNotificationWaiter( | 518 waiter.reset(new AccessibilityNotificationWaiter( |
519 shell(), AccessibilityModeComplete, | 519 shell(), AccessibilityModeComplete, |
520 blink::WebAXEventFocus)); | 520 ui::AX_EVENT_FOCUS)); |
521 ExecuteScript( | 521 ExecuteScript( |
522 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); | 522 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); |
523 waiter->WaitForNotification(); | 523 waiter->WaitForNotification(); |
524 | 524 |
525 // Check that the accessibility tree of the browser has been updated. | 525 // Check that the accessibility tree of the browser has been updated. |
526 list_item_checker.SetExpectedState( | 526 list_item_checker.SetExpectedState( |
527 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); | 527 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); |
528 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 528 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
529 document_checker.CheckAccessible(GetRendererAccessible()); | 529 document_checker.CheckAccessible(GetRendererAccessible()); |
530 } | 530 } |
(...skipping 12 matching lines...) Expand all Loading... |
543 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 543 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
544 std::wstring()); | 544 std::wstring()); |
545 body_checker.AppendExpectedChild(&checkbox_checker); | 545 body_checker.AppendExpectedChild(&checkbox_checker); |
546 document_checker.AppendExpectedChild(&body_checker); | 546 document_checker.AppendExpectedChild(&body_checker); |
547 document_checker.CheckAccessible(GetRendererAccessible()); | 547 document_checker.CheckAccessible(GetRendererAccessible()); |
548 | 548 |
549 // Check the checkbox. | 549 // Check the checkbox. |
550 scoped_ptr<AccessibilityNotificationWaiter> waiter( | 550 scoped_ptr<AccessibilityNotificationWaiter> waiter( |
551 new AccessibilityNotificationWaiter( | 551 new AccessibilityNotificationWaiter( |
552 shell(), AccessibilityModeComplete, | 552 shell(), AccessibilityModeComplete, |
553 blink::WebAXEventCheckedStateChanged)); | 553 ui::AX_EVENT_CHECKED_STATE_CHANGED)); |
554 ExecuteScript(L"document.body.children[0].checked=true"); | 554 ExecuteScript(L"document.body.children[0].checked=true"); |
555 waiter->WaitForNotification(); | 555 waiter->WaitForNotification(); |
556 | 556 |
557 // Check that the accessibility tree of the browser has been updated. | 557 // Check that the accessibility tree of the browser has been updated. |
558 checkbox_checker.SetExpectedState( | 558 checkbox_checker.SetExpectedState( |
559 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); | 559 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); |
560 document_checker.CheckAccessible(GetRendererAccessible()); | 560 document_checker.CheckAccessible(GetRendererAccessible()); |
561 } | 561 } |
562 | 562 |
563 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 563 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
564 MAYBE(TestNotificationChildrenChanged)) { | 564 MAYBE(TestNotificationChildrenChanged)) { |
565 // The role attribute causes the node to be in the accessibility tree. | 565 // The role attribute causes the node to be in the accessibility tree. |
566 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); | 566 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); |
567 | 567 |
568 // Check the browser's copy of the renderer accessibility tree. | 568 // Check the browser's copy of the renderer accessibility tree. |
569 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, | 569 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, |
570 std::wstring()); | 570 std::wstring()); |
571 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 571 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
572 std::wstring()); | 572 std::wstring()); |
573 document_checker.AppendExpectedChild(&group_checker); | 573 document_checker.AppendExpectedChild(&group_checker); |
574 document_checker.CheckAccessible(GetRendererAccessible()); | 574 document_checker.CheckAccessible(GetRendererAccessible()); |
575 | 575 |
576 // Change the children of the document body. | 576 // Change the children of the document body. |
577 scoped_ptr<AccessibilityNotificationWaiter> waiter( | 577 scoped_ptr<AccessibilityNotificationWaiter> waiter( |
578 new AccessibilityNotificationWaiter( | 578 new AccessibilityNotificationWaiter( |
579 shell(), | 579 shell(), |
580 AccessibilityModeComplete, | 580 AccessibilityModeComplete, |
581 blink::WebAXEventChildrenChanged)); | 581 ui::AX_EVENT_CHILDREN_CHANGED)); |
582 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); | 582 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); |
583 waiter->WaitForNotification(); | 583 waiter->WaitForNotification(); |
584 | 584 |
585 // Check that the accessibility tree of the browser has been updated. | 585 // Check that the accessibility tree of the browser has been updated. |
586 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, std::wstring()); | 586 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, std::wstring()); |
587 group_checker.AppendExpectedChild(&text_checker); | 587 group_checker.AppendExpectedChild(&text_checker); |
588 document_checker.CheckAccessible(GetRendererAccessible()); | 588 document_checker.CheckAccessible(GetRendererAccessible()); |
589 } | 589 } |
590 | 590 |
591 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 591 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
592 MAYBE(TestNotificationChildrenChanged2)) { | 592 MAYBE(TestNotificationChildrenChanged2)) { |
593 // The role attribute causes the node to be in the accessibility tree. | 593 // The role attribute causes the node to be in the accessibility tree. |
594 LoadInitialAccessibilityTreeFromHtml( | 594 LoadInitialAccessibilityTreeFromHtml( |
595 "<div role=group style='visibility: hidden'>text</div>"); | 595 "<div role=group style='visibility: hidden'>text</div>"); |
596 | 596 |
597 // Check the accessible tree of the browser. | 597 // Check the accessible tree of the browser. |
598 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 598 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
599 std::wstring()); | 599 std::wstring()); |
600 document_checker.CheckAccessible(GetRendererAccessible()); | 600 document_checker.CheckAccessible(GetRendererAccessible()); |
601 | 601 |
602 // Change the children of the document body. | 602 // Change the children of the document body. |
603 scoped_ptr<AccessibilityNotificationWaiter> waiter( | 603 scoped_ptr<AccessibilityNotificationWaiter> waiter( |
604 new AccessibilityNotificationWaiter( | 604 new AccessibilityNotificationWaiter( |
605 shell(), AccessibilityModeComplete, | 605 shell(), AccessibilityModeComplete, |
606 blink::WebAXEventChildrenChanged)); | 606 ui::AX_EVENT_CHILDREN_CHANGED)); |
607 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); | 607 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); |
608 waiter->WaitForNotification(); | 608 waiter->WaitForNotification(); |
609 | 609 |
610 // Check that the accessibility tree of the browser has been updated. | 610 // Check that the accessibility tree of the browser has been updated. |
611 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, | 611 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, |
612 std::wstring()); | 612 std::wstring()); |
613 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, | 613 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, |
614 std::wstring()); | 614 std::wstring()); |
615 document_checker.AppendExpectedChild(&group_checker); | 615 document_checker.AppendExpectedChild(&group_checker); |
616 group_checker.AppendExpectedChild(&static_text_checker); | 616 group_checker.AppendExpectedChild(&static_text_checker); |
(...skipping 12 matching lines...) Expand all Loading... |
629 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 629 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
630 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 630 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
631 std::wstring()); | 631 std::wstring()); |
632 document_checker.AppendExpectedChild(&group_checker); | 632 document_checker.AppendExpectedChild(&group_checker); |
633 document_checker.CheckAccessible(GetRendererAccessible()); | 633 document_checker.CheckAccessible(GetRendererAccessible()); |
634 | 634 |
635 // Focus the div in the document | 635 // Focus the div in the document |
636 scoped_ptr<AccessibilityNotificationWaiter> waiter( | 636 scoped_ptr<AccessibilityNotificationWaiter> waiter( |
637 new AccessibilityNotificationWaiter( | 637 new AccessibilityNotificationWaiter( |
638 shell(), AccessibilityModeComplete, | 638 shell(), AccessibilityModeComplete, |
639 blink::WebAXEventFocus)); | 639 ui::AX_EVENT_FOCUS)); |
640 ExecuteScript(L"document.body.children[0].focus()"); | 640 ExecuteScript(L"document.body.children[0].focus()"); |
641 waiter->WaitForNotification(); | 641 waiter->WaitForNotification(); |
642 | 642 |
643 // Check that the accessibility tree of the browser has been updated. | 643 // Check that the accessibility tree of the browser has been updated. |
644 SCOPED_TRACE("Check updated tree after focusing div"); | 644 SCOPED_TRACE("Check updated tree after focusing div"); |
645 group_checker.SetExpectedState( | 645 group_checker.SetExpectedState( |
646 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); | 646 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); |
647 document_checker.CheckAccessible(GetRendererAccessible()); | 647 document_checker.CheckAccessible(GetRendererAccessible()); |
648 | 648 |
649 // Focus the document accessible. This will un-focus the current node. | 649 // Focus the document accessible. This will un-focus the current node. |
650 waiter.reset( | 650 waiter.reset( |
651 new AccessibilityNotificationWaiter( | 651 new AccessibilityNotificationWaiter( |
652 shell(), AccessibilityModeComplete, | 652 shell(), AccessibilityModeComplete, |
653 blink::WebAXEventBlur)); | 653 ui::AX_EVENT_BLUR)); |
654 base::win::ScopedComPtr<IAccessible> document_accessible( | 654 base::win::ScopedComPtr<IAccessible> document_accessible( |
655 GetRendererAccessible()); | 655 GetRendererAccessible()); |
656 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); | 656 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); |
657 base::win::ScopedVariant childid_self(CHILDID_SELF); | 657 base::win::ScopedVariant childid_self(CHILDID_SELF); |
658 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); | 658 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); |
659 ASSERT_EQ(S_OK, hr); | 659 ASSERT_EQ(S_OK, hr); |
660 waiter->WaitForNotification(); | 660 waiter->WaitForNotification(); |
661 | 661 |
662 // Check that the accessibility tree of the browser has been updated. | 662 // Check that the accessibility tree of the browser has been updated. |
663 SCOPED_TRACE("Check updated tree after focusing document again"); | 663 SCOPED_TRACE("Check updated tree after focusing document again"); |
(...skipping 15 matching lines...) Expand all Loading... |
679 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 679 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
680 std::wstring()); | 680 std::wstring()); |
681 body_checker.AppendExpectedChild(&text_field_checker); | 681 body_checker.AppendExpectedChild(&text_field_checker); |
682 document_checker.AppendExpectedChild(&body_checker); | 682 document_checker.AppendExpectedChild(&body_checker); |
683 document_checker.CheckAccessible(GetRendererAccessible()); | 683 document_checker.CheckAccessible(GetRendererAccessible()); |
684 | 684 |
685 // Set the value of the text control | 685 // Set the value of the text control |
686 scoped_ptr<AccessibilityNotificationWaiter> waiter( | 686 scoped_ptr<AccessibilityNotificationWaiter> waiter( |
687 new AccessibilityNotificationWaiter( | 687 new AccessibilityNotificationWaiter( |
688 shell(), AccessibilityModeComplete, | 688 shell(), AccessibilityModeComplete, |
689 blink::WebAXEventValueChanged)); | 689 ui::AX_EVENT_VALUE_CHANGE)); |
690 ExecuteScript(L"document.body.children[0].value='new value'"); | 690 ExecuteScript(L"document.body.children[0].value='new value'"); |
691 waiter->WaitForNotification(); | 691 waiter->WaitForNotification(); |
692 | 692 |
693 // Check that the accessibility tree of the browser has been updated. | 693 // Check that the accessibility tree of the browser has been updated. |
694 text_field_checker.SetExpectedValue(L"new value"); | 694 text_field_checker.SetExpectedValue(L"new value"); |
695 document_checker.CheckAccessible(GetRendererAccessible()); | 695 document_checker.CheckAccessible(GetRendererAccessible()); |
696 } | 696 } |
697 | 697 |
698 // This test verifies that the web content's accessibility tree is a | 698 // This test verifies that the web content's accessibility tree is a |
699 // descendant of the main browser window's accessibility tree, so that | 699 // descendant of the main browser window's accessibility tree, so that |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 AccessibleChecker grouping2_checker(std::wstring(), ROLE_SYSTEM_GROUPING, | 875 AccessibleChecker grouping2_checker(std::wstring(), ROLE_SYSTEM_GROUPING, |
876 std::wstring()); | 876 std::wstring()); |
877 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 877 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
878 std::wstring()); | 878 std::wstring()); |
879 document_checker.AppendExpectedChild(&grouping1_checker); | 879 document_checker.AppendExpectedChild(&grouping1_checker); |
880 document_checker.AppendExpectedChild(&grouping2_checker); | 880 document_checker.AppendExpectedChild(&grouping2_checker); |
881 document_checker.CheckAccessible(GetRendererAccessible()); | 881 document_checker.CheckAccessible(GetRendererAccessible()); |
882 } | 882 } |
883 | 883 |
884 } // namespace content | 884 } // namespace content |
OLD | NEW |