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

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

Issue 2558933002: Add more fine-grained accessibility modes. (Closed)
Patch Set: Rename constants Created 4 years 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() { 99 AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() {
100 } 100 }
101 101
102 AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() { 102 AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() {
103 } 103 }
104 104
105 void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( 105 void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml(
106 const std::string& html) { 106 const std::string& html) {
107 AccessibilityNotificationWaiter waiter( 107 AccessibilityNotificationWaiter waiter(
108 shell()->web_contents(), AccessibilityModeComplete, 108 shell()->web_contents(), kAccessibilityModeComplete,
109 ui::AX_EVENT_LOAD_COMPLETE); 109 ui::AX_EVENT_LOAD_COMPLETE);
110 GURL html_data_url("data:text/html," + html); 110 GURL html_data_url("data:text/html," + html);
111 NavigateToURL(shell(), html_data_url); 111 NavigateToURL(shell(), html_data_url);
112 waiter.WaitForNotification(); 112 waiter.WaitForNotification();
113 } 113 }
114 114
115 // Retrieve the MSAA client accessibility object for the Render Widget Host View 115 // Retrieve the MSAA client accessibility object for the Render Widget Host View
116 // of the selected tab. 116 // of the selected tab.
117 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() { 117 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() {
118 content::WebContents* web_contents = shell()->web_contents(); 118 content::WebContents* web_contents = shell()->web_contents();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 input.Receive())); 156 input.Receive()));
157 LONG input_role = 0; 157 LONG input_role = 0;
158 ASSERT_HRESULT_SUCCEEDED(input->role(&input_role)); 158 ASSERT_HRESULT_SUCCEEDED(input->role(&input_role));
159 ASSERT_EQ(ROLE_SYSTEM_TEXT, input_role); 159 ASSERT_EQ(ROLE_SYSTEM_TEXT, input_role);
160 160
161 // Retrieve the IAccessibleText interface for the field. 161 // Retrieve the IAccessibleText interface for the field.
162 ASSERT_HRESULT_SUCCEEDED(input.QueryInterface(input_text->Receive())); 162 ASSERT_HRESULT_SUCCEEDED(input.QueryInterface(input_text->Receive()));
163 163
164 // Set the caret on the last character. 164 // Set the caret on the last character.
165 AccessibilityNotificationWaiter waiter( 165 AccessibilityNotificationWaiter waiter(
166 shell()->web_contents(), AccessibilityModeComplete, 166 shell()->web_contents(), kAccessibilityModeComplete,
167 ui::AX_EVENT_TEXT_SELECTION_CHANGED); 167 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
168 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( 168 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16(
169 static_cast<int>(CONTENTS_LENGTH - 1))); 169 static_cast<int>(CONTENTS_LENGTH - 1)));
170 ExecuteScript(std::wstring( 170 ExecuteScript(std::wstring(
171 L"var textField = document.getElementById('textField');" 171 L"var textField = document.getElementById('textField');"
172 L"textField.focus();" 172 L"textField.focus();"
173 L"textField.setSelectionRange(") + 173 L"textField.setSelectionRange(") +
174 caret_offset + L"," + caret_offset + L");"); 174 caret_offset + L"," + caret_offset + L");");
175 waiter.WaitForNotification(); 175 waiter.WaitForNotification();
176 } 176 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 textarea.Receive())); 208 textarea.Receive()));
209 LONG textarea_role = 0; 209 LONG textarea_role = 0;
210 ASSERT_HRESULT_SUCCEEDED(textarea->role(&textarea_role)); 210 ASSERT_HRESULT_SUCCEEDED(textarea->role(&textarea_role));
211 ASSERT_EQ(ROLE_SYSTEM_TEXT, textarea_role); 211 ASSERT_EQ(ROLE_SYSTEM_TEXT, textarea_role);
212 212
213 // Retrieve the IAccessibleText interface for the field. 213 // Retrieve the IAccessibleText interface for the field.
214 ASSERT_HRESULT_SUCCEEDED(textarea.QueryInterface(textarea_text->Receive())); 214 ASSERT_HRESULT_SUCCEEDED(textarea.QueryInterface(textarea_text->Receive()));
215 215
216 // Set the caret on the last character. 216 // Set the caret on the last character.
217 AccessibilityNotificationWaiter waiter( 217 AccessibilityNotificationWaiter waiter(
218 shell()->web_contents(), AccessibilityModeComplete, 218 shell()->web_contents(), kAccessibilityModeComplete,
219 ui::AX_EVENT_TEXT_SELECTION_CHANGED); 219 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
220 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( 220 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16(
221 static_cast<int>(CONTENTS_LENGTH - 1))); 221 static_cast<int>(CONTENTS_LENGTH - 1)));
222 ExecuteScript(std::wstring( 222 ExecuteScript(std::wstring(
223 L"var textField = document.getElementById('textField');" 223 L"var textField = document.getElementById('textField');"
224 L"textField.focus();" 224 L"textField.focus();"
225 L"textField.setSelectionRange(") + 225 L"textField.setSelectionRange(") +
226 caret_offset + L"," + caret_offset + L");"); 226 caret_offset + L"," + caret_offset + L");");
227 waiter.WaitForNotification(); 227 waiter.WaitForNotification();
228 } 228 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 std::wstring()); 667 std::wstring());
668 list_item_checker.AppendExpectedChild(&list_marker_checker); 668 list_item_checker.AppendExpectedChild(&list_marker_checker);
669 list_item_checker.AppendExpectedChild(&static_text_checker); 669 list_item_checker.AppendExpectedChild(&static_text_checker);
670 radio_group_checker.AppendExpectedChild(&list_item_checker); 670 radio_group_checker.AppendExpectedChild(&list_item_checker);
671 document_checker.AppendExpectedChild(&radio_group_checker); 671 document_checker.AppendExpectedChild(&radio_group_checker);
672 document_checker.CheckAccessible(GetRendererAccessible()); 672 document_checker.CheckAccessible(GetRendererAccessible());
673 673
674 // Set focus to the radio group. 674 // Set focus to the radio group.
675 std::unique_ptr<AccessibilityNotificationWaiter> waiter( 675 std::unique_ptr<AccessibilityNotificationWaiter> waiter(
676 new AccessibilityNotificationWaiter(shell()->web_contents(), 676 new AccessibilityNotificationWaiter(shell()->web_contents(),
677 AccessibilityModeComplete, 677 kAccessibilityModeComplete,
678 ui::AX_EVENT_FOCUS)); 678 ui::AX_EVENT_FOCUS));
679 ExecuteScript(L"document.body.children[0].focus()"); 679 ExecuteScript(L"document.body.children[0].focus()");
680 waiter->WaitForNotification(); 680 waiter->WaitForNotification();
681 681
682 // Check that the accessibility tree of the browser has been updated. 682 // Check that the accessibility tree of the browser has been updated.
683 radio_group_checker.SetExpectedState( 683 radio_group_checker.SetExpectedState(
684 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 684 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
685 document_checker.CheckAccessible(GetRendererAccessible()); 685 document_checker.CheckAccessible(GetRendererAccessible());
686 686
687 // Set the active descendant of the radio group 687 // Set the active descendant of the radio group
688 waiter.reset(new AccessibilityNotificationWaiter( 688 waiter.reset(new AccessibilityNotificationWaiter(
689 shell()->web_contents(), AccessibilityModeComplete, 689 shell()->web_contents(), kAccessibilityModeComplete,
690 ui::AX_EVENT_FOCUS)); 690 ui::AX_EVENT_FOCUS));
691 ExecuteScript( 691 ExecuteScript(
692 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); 692 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')");
693 waiter->WaitForNotification(); 693 waiter->WaitForNotification();
694 694
695 // Check that the accessibility tree of the browser has been updated. 695 // Check that the accessibility tree of the browser has been updated.
696 list_item_checker.SetExpectedState( 696 list_item_checker.SetExpectedState(
697 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 697 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
698 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 698 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
699 document_checker.CheckAccessible(GetRendererAccessible()); 699 document_checker.CheckAccessible(GetRendererAccessible());
(...skipping 12 matching lines...) Expand all
712 std::wstring()); 712 std::wstring());
713 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 713 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
714 std::wstring()); 714 std::wstring());
715 body_checker.AppendExpectedChild(&checkbox_checker); 715 body_checker.AppendExpectedChild(&checkbox_checker);
716 document_checker.AppendExpectedChild(&body_checker); 716 document_checker.AppendExpectedChild(&body_checker);
717 document_checker.CheckAccessible(GetRendererAccessible()); 717 document_checker.CheckAccessible(GetRendererAccessible());
718 718
719 // Check the checkbox. 719 // Check the checkbox.
720 std::unique_ptr<AccessibilityNotificationWaiter> waiter( 720 std::unique_ptr<AccessibilityNotificationWaiter> waiter(
721 new AccessibilityNotificationWaiter(shell()->web_contents(), 721 new AccessibilityNotificationWaiter(shell()->web_contents(),
722 AccessibilityModeComplete, 722 kAccessibilityModeComplete,
723 ui::AX_EVENT_CHECKED_STATE_CHANGED)); 723 ui::AX_EVENT_CHECKED_STATE_CHANGED));
724 ExecuteScript(L"document.body.children[0].checked=true"); 724 ExecuteScript(L"document.body.children[0].checked=true");
725 waiter->WaitForNotification(); 725 waiter->WaitForNotification();
726 726
727 // Check that the accessibility tree of the browser has been updated. 727 // Check that the accessibility tree of the browser has been updated.
728 checkbox_checker.SetExpectedState( 728 checkbox_checker.SetExpectedState(
729 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); 729 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE);
730 document_checker.CheckAccessible(GetRendererAccessible()); 730 document_checker.CheckAccessible(GetRendererAccessible());
731 } 731 }
732 732
733 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 733 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
734 TestNotificationChildrenChanged) { 734 TestNotificationChildrenChanged) {
735 // The role attribute causes the node to be in the accessibility tree. 735 // The role attribute causes the node to be in the accessibility tree.
736 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); 736 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>");
737 737
738 // Check the browser's copy of the renderer accessibility tree. 738 // Check the browser's copy of the renderer accessibility tree.
739 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 739 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
740 std::wstring()); 740 std::wstring());
741 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 741 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
742 std::wstring()); 742 std::wstring());
743 document_checker.AppendExpectedChild(&group_checker); 743 document_checker.AppendExpectedChild(&group_checker);
744 document_checker.CheckAccessible(GetRendererAccessible()); 744 document_checker.CheckAccessible(GetRendererAccessible());
745 745
746 // Change the children of the document body. 746 // Change the children of the document body.
747 std::unique_ptr<AccessibilityNotificationWaiter> waiter( 747 std::unique_ptr<AccessibilityNotificationWaiter> waiter(
748 new AccessibilityNotificationWaiter(shell()->web_contents(), 748 new AccessibilityNotificationWaiter(shell()->web_contents(),
749 AccessibilityModeComplete, 749 kAccessibilityModeComplete,
750 ui::AX_EVENT_CHILDREN_CHANGED)); 750 ui::AX_EVENT_CHILDREN_CHANGED));
751 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); 751 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'");
752 waiter->WaitForNotification(); 752 waiter->WaitForNotification();
753 753
754 // Check that the accessibility tree of the browser has been updated. 754 // Check that the accessibility tree of the browser has been updated.
755 AccessibleChecker text_checker( 755 AccessibleChecker text_checker(
756 L"new text", ROLE_SYSTEM_STATICTEXT, std::wstring()); 756 L"new text", ROLE_SYSTEM_STATICTEXT, std::wstring());
757 group_checker.AppendExpectedChild(&text_checker); 757 group_checker.AppendExpectedChild(&text_checker);
758 document_checker.CheckAccessible(GetRendererAccessible()); 758 document_checker.CheckAccessible(GetRendererAccessible());
759 } 759 }
760 760
761 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 761 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
762 TestNotificationChildrenChanged2) { 762 TestNotificationChildrenChanged2) {
763 // The role attribute causes the node to be in the accessibility tree. 763 // The role attribute causes the node to be in the accessibility tree.
764 LoadInitialAccessibilityTreeFromHtml( 764 LoadInitialAccessibilityTreeFromHtml(
765 "<div role=group style='visibility: hidden'>text</div>"); 765 "<div role=group style='visibility: hidden'>text</div>");
766 766
767 // Check the accessible tree of the browser. 767 // Check the accessible tree of the browser.
768 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 768 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
769 std::wstring()); 769 std::wstring());
770 document_checker.CheckAccessible(GetRendererAccessible()); 770 document_checker.CheckAccessible(GetRendererAccessible());
771 771
772 // Change the children of the document body. 772 // Change the children of the document body.
773 std::unique_ptr<AccessibilityNotificationWaiter> waiter( 773 std::unique_ptr<AccessibilityNotificationWaiter> waiter(
774 new AccessibilityNotificationWaiter(shell()->web_contents(), 774 new AccessibilityNotificationWaiter(shell()->web_contents(),
775 AccessibilityModeComplete, 775 kAccessibilityModeComplete,
776 ui::AX_EVENT_CHILDREN_CHANGED)); 776 ui::AX_EVENT_CHILDREN_CHANGED));
777 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); 777 ExecuteScript(L"document.body.children[0].style.visibility='visible'");
778 waiter->WaitForNotification(); 778 waiter->WaitForNotification();
779 779
780 // Check that the accessibility tree of the browser has been updated. 780 // Check that the accessibility tree of the browser has been updated.
781 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_STATICTEXT, 781 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_STATICTEXT,
782 std::wstring()); 782 std::wstring());
783 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 783 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
784 std::wstring()); 784 std::wstring());
785 document_checker.AppendExpectedChild(&group_checker); 785 document_checker.AppendExpectedChild(&group_checker);
(...skipping 12 matching lines...) Expand all
798 std::wstring()); 798 std::wstring());
799 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 799 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
800 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 800 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
801 std::wstring()); 801 std::wstring());
802 document_checker.AppendExpectedChild(&group_checker); 802 document_checker.AppendExpectedChild(&group_checker);
803 document_checker.CheckAccessible(GetRendererAccessible()); 803 document_checker.CheckAccessible(GetRendererAccessible());
804 804
805 // Focus the div in the document 805 // Focus the div in the document
806 std::unique_ptr<AccessibilityNotificationWaiter> waiter( 806 std::unique_ptr<AccessibilityNotificationWaiter> waiter(
807 new AccessibilityNotificationWaiter(shell()->web_contents(), 807 new AccessibilityNotificationWaiter(shell()->web_contents(),
808 AccessibilityModeComplete, 808 kAccessibilityModeComplete,
809 ui::AX_EVENT_FOCUS)); 809 ui::AX_EVENT_FOCUS));
810 ExecuteScript(L"document.body.children[0].focus()"); 810 ExecuteScript(L"document.body.children[0].focus()");
811 waiter->WaitForNotification(); 811 waiter->WaitForNotification();
812 812
813 // Check that the accessibility tree of the browser has been updated. 813 // Check that the accessibility tree of the browser has been updated.
814 SCOPED_TRACE("Check updated tree after focusing div"); 814 SCOPED_TRACE("Check updated tree after focusing div");
815 group_checker.SetExpectedState( 815 group_checker.SetExpectedState(
816 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 816 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
817 document_checker.CheckAccessible(GetRendererAccessible()); 817 document_checker.CheckAccessible(GetRendererAccessible());
818 818
819 // Focus the document accessible. This will un-focus the current node. 819 // Focus the document accessible. This will un-focus the current node.
820 waiter.reset( 820 waiter.reset(
821 new AccessibilityNotificationWaiter( 821 new AccessibilityNotificationWaiter(
822 shell()->web_contents(), AccessibilityModeComplete, 822 shell()->web_contents(), kAccessibilityModeComplete,
823 ui::AX_EVENT_BLUR)); 823 ui::AX_EVENT_BLUR));
824 base::win::ScopedComPtr<IAccessible> document_accessible( 824 base::win::ScopedComPtr<IAccessible> document_accessible(
825 GetRendererAccessible()); 825 GetRendererAccessible());
826 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 826 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
827 base::win::ScopedVariant childid_self(CHILDID_SELF); 827 base::win::ScopedVariant childid_self(CHILDID_SELF);
828 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); 828 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self);
829 ASSERT_EQ(S_OK, hr); 829 ASSERT_EQ(S_OK, hr);
830 waiter->WaitForNotification(); 830 waiter->WaitForNotification();
831 831
832 // Check that the accessibility tree of the browser has been updated. 832 // Check that the accessibility tree of the browser has been updated.
(...skipping 15 matching lines...) Expand all
848 std::wstring()); 848 std::wstring());
849 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 849 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
850 std::wstring()); 850 std::wstring());
851 body_checker.AppendExpectedChild(&text_field_checker); 851 body_checker.AppendExpectedChild(&text_field_checker);
852 document_checker.AppendExpectedChild(&body_checker); 852 document_checker.AppendExpectedChild(&body_checker);
853 document_checker.CheckAccessible(GetRendererAccessible()); 853 document_checker.CheckAccessible(GetRendererAccessible());
854 854
855 // Set the value of the text control 855 // Set the value of the text control
856 std::unique_ptr<AccessibilityNotificationWaiter> waiter( 856 std::unique_ptr<AccessibilityNotificationWaiter> waiter(
857 new AccessibilityNotificationWaiter(shell()->web_contents(), 857 new AccessibilityNotificationWaiter(shell()->web_contents(),
858 AccessibilityModeComplete, 858 kAccessibilityModeComplete,
859 ui::AX_EVENT_VALUE_CHANGED)); 859 ui::AX_EVENT_VALUE_CHANGED));
860 ExecuteScript(L"document.body.children[0].value='new value'"); 860 ExecuteScript(L"document.body.children[0].value='new value'");
861 waiter->WaitForNotification(); 861 waiter->WaitForNotification();
862 862
863 // Check that the accessibility tree of the browser has been updated. 863 // Check that the accessibility tree of the browser has been updated.
864 text_field_checker.SetExpectedValue(L"new value"); 864 text_field_checker.SetExpectedValue(L"new value");
865 document_checker.CheckAccessible(GetRendererAccessible()); 865 document_checker.CheckAccessible(GetRendererAccessible());
866 } 866 }
867 867
868 // This test verifies that the web content's accessibility tree is a 868 // This test verifies that the web content's accessibility tree is a
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 base::win::ScopedComPtr<IAccessibleText> input_text; 1090 base::win::ScopedComPtr<IAccessibleText> input_text;
1091 SetUpInputField(&input_text); 1091 SetUpInputField(&input_text);
1092 1092
1093 LONG caret_offset = 0; 1093 LONG caret_offset = 0;
1094 HRESULT hr = input_text->get_caretOffset(&caret_offset); 1094 HRESULT hr = input_text->get_caretOffset(&caret_offset);
1095 EXPECT_EQ(S_OK, hr); 1095 EXPECT_EQ(S_OK, hr);
1096 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); 1096 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset);
1097 1097
1098 AccessibilityNotificationWaiter waiter( 1098 AccessibilityNotificationWaiter waiter(
1099 shell()->web_contents(), 1099 shell()->web_contents(),
1100 AccessibilityModeComplete, 1100 kAccessibilityModeComplete,
1101 ui::AX_EVENT_TEXT_SELECTION_CHANGED); 1101 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
1102 caret_offset = 0; 1102 caret_offset = 0;
1103 hr = input_text->setCaretOffset(caret_offset); 1103 hr = input_text->setCaretOffset(caret_offset);
1104 EXPECT_EQ(S_OK, hr); 1104 EXPECT_EQ(S_OK, hr);
1105 waiter.WaitForNotification(); 1105 waiter.WaitForNotification();
1106 1106
1107 hr = input_text->get_caretOffset(&caret_offset); 1107 hr = input_text->get_caretOffset(&caret_offset);
1108 EXPECT_EQ(S_OK, hr); 1108 EXPECT_EQ(S_OK, hr);
1109 EXPECT_EQ(0, caret_offset); 1109 EXPECT_EQ(0, caret_offset);
1110 } 1110 }
1111 1111
1112 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 1112 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
1113 TestMultiLineSetCaretOffset) { 1113 TestMultiLineSetCaretOffset) {
1114 base::win::ScopedComPtr<IAccessibleText> textarea_text; 1114 base::win::ScopedComPtr<IAccessibleText> textarea_text;
1115 SetUpTextareaField(&textarea_text); 1115 SetUpTextareaField(&textarea_text);
1116 1116
1117 LONG caret_offset = 0; 1117 LONG caret_offset = 0;
1118 HRESULT hr = textarea_text->get_caretOffset(&caret_offset); 1118 HRESULT hr = textarea_text->get_caretOffset(&caret_offset);
1119 EXPECT_EQ(S_OK, hr); 1119 EXPECT_EQ(S_OK, hr);
1120 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); 1120 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset);
1121 1121
1122 AccessibilityNotificationWaiter waiter( 1122 AccessibilityNotificationWaiter waiter(
1123 shell()->web_contents(), 1123 shell()->web_contents(),
1124 AccessibilityModeComplete, 1124 kAccessibilityModeComplete,
1125 ui::AX_EVENT_TEXT_SELECTION_CHANGED); 1125 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
1126 caret_offset = 0; 1126 caret_offset = 0;
1127 hr = textarea_text->setCaretOffset(caret_offset); 1127 hr = textarea_text->setCaretOffset(caret_offset);
1128 EXPECT_EQ(S_OK, hr); 1128 EXPECT_EQ(S_OK, hr);
1129 waiter.WaitForNotification(); 1129 waiter.WaitForNotification();
1130 1130
1131 hr = textarea_text->get_caretOffset(&caret_offset); 1131 hr = textarea_text->get_caretOffset(&caret_offset);
1132 EXPECT_EQ(S_OK, hr); 1132 EXPECT_EQ(S_OK, hr);
1133 EXPECT_EQ(0, caret_offset); 1133 EXPECT_EQ(0, caret_offset);
1134 } 1134 }
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 1709
1710 base::win::ScopedVariant childid_self(CHILDID_SELF); 1710 base::win::ScopedVariant childid_self(CHILDID_SELF);
1711 base::win::ScopedBstr image_name; 1711 base::win::ScopedBstr image_name;
1712 EXPECT_HRESULT_SUCCEEDED( 1712 EXPECT_HRESULT_SUCCEEDED(
1713 image->get_accName(childid_self, image_name.Receive())); 1713 image->get_accName(childid_self, image_name.Receive()));
1714 EXPECT_EQ(L"image", std::wstring(image_name, image_name.Length())); 1714 EXPECT_EQ(L"image", std::wstring(image_name, image_name.Length()));
1715 image_name.Release(); 1715 image_name.Release();
1716 // Cllicking the image will change its name. 1716 // Cllicking the image will change its name.
1717 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); 1717 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0));
1718 AccessibilityNotificationWaiter waiter(shell()->web_contents(), 1718 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
1719 AccessibilityModeComplete, 1719 kAccessibilityModeComplete,
1720 ui::AX_EVENT_TEXT_CHANGED); 1720 ui::AX_EVENT_TEXT_CHANGED);
1721 waiter.WaitForNotification(); 1721 waiter.WaitForNotification();
1722 EXPECT_HRESULT_SUCCEEDED( 1722 EXPECT_HRESULT_SUCCEEDED(
1723 image->get_accName(childid_self, image_name.Receive())); 1723 image->get_accName(childid_self, image_name.Receive()));
1724 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); 1724 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length()));
1725 EXPECT_HRESULT_FAILED(image_action->doAction(1)); 1725 EXPECT_HRESULT_FAILED(image_action->doAction(1));
1726 } 1726 }
1727 1727
1728 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { 1728 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) {
1729 // This test simulates a scenario where RenderWidgetHostViewAura::SetSize 1729 // This test simulates a scenario where RenderWidgetHostViewAura::SetSize
1730 // is not called again after its window is added to the root window. 1730 // is not called again after its window is added to the root window.
1731 // Ensure that we still get a legacy HWND for accessibility. 1731 // Ensure that we still get a legacy HWND for accessibility.
1732 1732
1733 host_resolver()->AddRule("*", "127.0.0.1"); 1733 host_resolver()->AddRule("*", "127.0.0.1");
1734 ASSERT_TRUE(embedded_test_server()->Start()); 1734 ASSERT_TRUE(embedded_test_server()->Start());
1735 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 1735 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
1736 shell()->web_contents()); 1736 shell()->web_contents());
1737 WebContentsView* web_contents_view = web_contents->GetView(); 1737 WebContentsView* web_contents_view = web_contents->GetView();
1738 WebContentsViewAura* web_contents_view_aura = 1738 WebContentsViewAura* web_contents_view_aura =
1739 static_cast<WebContentsViewAura*>(web_contents_view); 1739 static_cast<WebContentsViewAura*>(web_contents_view);
1740 1740
1741 // Set a flag that will cause WebContentsViewAura to initialize a 1741 // Set a flag that will cause WebContentsViewAura to initialize a
1742 // RenderWidgetHostViewAura with a null parent view. 1742 // RenderWidgetHostViewAura with a null parent view.
1743 web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true); 1743 web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true);
1744 1744
1745 // Navigate to a new page and wait for the accessibility tree to load. 1745 // Navigate to a new page and wait for the accessibility tree to load.
1746 AccessibilityNotificationWaiter waiter( 1746 AccessibilityNotificationWaiter waiter(
1747 shell()->web_contents(), 1747 shell()->web_contents(),
1748 AccessibilityModeComplete, 1748 kAccessibilityModeComplete,
1749 ui::AX_EVENT_LOAD_COMPLETE); 1749 ui::AX_EVENT_LOAD_COMPLETE);
1750 NavigateToURL(shell(), embedded_test_server()->GetURL( 1750 NavigateToURL(shell(), embedded_test_server()->GetURL(
1751 "/accessibility/html/article.html")); 1751 "/accessibility/html/article.html"));
1752 waiter.WaitForNotification(); 1752 waiter.WaitForNotification();
1753 1753
1754 // At this point the root of the accessibility tree shouldn't have an HWND 1754 // At this point the root of the accessibility tree shouldn't have an HWND
1755 // because we never gave a parent window to the RWHVA. 1755 // because we never gave a parent window to the RWHVA.
1756 BrowserAccessibilityManagerWin* manager = 1756 BrowserAccessibilityManagerWin* manager =
1757 static_cast<BrowserAccessibilityManagerWin*>( 1757 static_cast<BrowserAccessibilityManagerWin*>(
1758 web_contents->GetRootBrowserAccessibilityManager()); 1758 web_contents->GetRootBrowserAccessibilityManager());
1759 ASSERT_EQ(nullptr, manager->GetParentHWND()); 1759 ASSERT_EQ(nullptr, manager->GetParentHWND());
1760 1760
1761 // Now add the RWHVA's window to the root window and ensure that we have 1761 // Now add the RWHVA's window to the root window and ensure that we have
1762 // an HWND for accessibility now. 1762 // an HWND for accessibility now.
1763 web_contents_view->GetNativeView()->AddChild( 1763 web_contents_view->GetNativeView()->AddChild(
1764 web_contents->GetRenderWidgetHostView()->GetNativeView()); 1764 web_contents->GetRenderWidgetHostView()->GetNativeView());
1765 ASSERT_NE(nullptr, manager->GetParentHWND()); 1765 ASSERT_NE(nullptr, manager->GetParentHWND());
1766 } 1766 }
1767 1767
1768 } // namespace content 1768 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698