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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/win/scoped_bstr.h" | 7 #include "base/win/scoped_bstr.h" |
8 #include "base/win/scoped_comptr.h" | 8 #include "base/win/scoped_comptr.h" |
9 #include "base/win/scoped_variant.h" | 9 #include "base/win/scoped_variant.h" |
10 #include "content/browser/accessibility/browser_accessibility_manager.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager.h" |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 */ | 816 */ |
817 TEST_F(BrowserAccessibilityTest, TestCaretAndSelectionInSimpleFields) { | 817 TEST_F(BrowserAccessibilityTest, TestCaretAndSelectionInSimpleFields) { |
818 ui::AXNodeData root; | 818 ui::AXNodeData root; |
819 root.id = 1; | 819 root.id = 1; |
820 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 820 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
821 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 821 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); |
822 | 822 |
823 ui::AXNodeData combo_box; | 823 ui::AXNodeData combo_box; |
824 combo_box.id = 2; | 824 combo_box.id = 2; |
825 combo_box.role = ui::AX_ROLE_COMBO_BOX; | 825 combo_box.role = ui::AX_ROLE_COMBO_BOX; |
826 combo_box.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_FOCUSED); | 826 combo_box.state = (1 << ui::AX_STATE_EDITABLE) | |
| 827 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_FOCUSED); |
827 combo_box.SetValue("Test1"); | 828 combo_box.SetValue("Test1"); |
828 // Place the caret between 't' and 'e'. | 829 // Place the caret between 't' and 'e'. |
829 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); | 830 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); |
830 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 1); | 831 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 1); |
831 | 832 |
832 ui::AXNodeData text_field; | 833 ui::AXNodeData text_field; |
833 text_field.id = 3; | 834 text_field.id = 3; |
834 text_field.role = ui::AX_ROLE_TEXT_FIELD; | 835 text_field.role = ui::AX_ROLE_TEXT_FIELD; |
835 text_field.state = 1 << ui::AX_STATE_FOCUSABLE; | 836 text_field.state = (1 << ui::AX_STATE_EDITABLE) | |
| 837 (1 << ui::AX_STATE_FOCUSABLE); |
836 text_field.SetValue("Test2"); | 838 text_field.SetValue("Test2"); |
837 // Select the letter 'e'. | 839 // Select the letter 'e'. |
838 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); | 840 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); |
839 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 2); | 841 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 2); |
840 | 842 |
841 root.child_ids.push_back(2); | 843 root.child_ids.push_back(2); |
842 root.child_ids.push_back(3); | 844 root.child_ids.push_back(3); |
843 | 845 |
844 CountedBrowserAccessibility::reset(); | 846 CountedBrowserAccessibility::reset(); |
845 scoped_ptr<BrowserAccessibilityManager> manager( | 847 scoped_ptr<BrowserAccessibilityManager> manager( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 | 920 |
919 TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) { | 921 TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) { |
920 ui::AXNodeData root; | 922 ui::AXNodeData root; |
921 root.id = 1; | 923 root.id = 1; |
922 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 924 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
923 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 925 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); |
924 | 926 |
925 ui::AXNodeData div_editable; | 927 ui::AXNodeData div_editable; |
926 div_editable.id = 2; | 928 div_editable.id = 2; |
927 div_editable.role = ui::AX_ROLE_DIV; | 929 div_editable.role = ui::AX_ROLE_DIV; |
928 div_editable.state = (1 << ui::AX_STATE_FOCUSABLE); | 930 div_editable.state = (1 << ui::AX_STATE_EDITABLE) | |
| 931 (1 << ui::AX_STATE_FOCUSABLE); |
929 | 932 |
930 ui::AXNodeData text; | 933 ui::AXNodeData text; |
931 text.id = 3; | 934 text.id = 3; |
932 text.role = ui::AX_ROLE_STATIC_TEXT; | 935 text.role = ui::AX_ROLE_STATIC_TEXT; |
| 936 text.state = (1 << ui::AX_STATE_EDITABLE); |
933 text.SetName("Click "); | 937 text.SetName("Click "); |
934 | 938 |
935 ui::AXNodeData link; | 939 ui::AXNodeData link; |
936 link.id = 4; | 940 link.id = 4; |
937 link.role = ui::AX_ROLE_LINK; | 941 link.role = ui::AX_ROLE_LINK; |
938 link.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 942 link.state = (1 << ui::AX_STATE_EDITABLE) | |
| 943 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); |
939 link.SetName("here"); | 944 link.SetName("here"); |
940 | 945 |
941 ui::AXNodeData link_text; | 946 ui::AXNodeData link_text; |
942 link_text.id = 5; | 947 link_text.id = 5; |
943 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 948 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
944 link_text.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 949 link_text.state = (1 << ui::AX_STATE_EDITABLE) | |
| 950 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); |
945 link_text.SetName("here"); | 951 link_text.SetName("here"); |
946 | 952 |
947 // Place the caret between 'h' and 'e'. | 953 // Place the caret between 'h' and 'e'. |
948 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OBJECT_ID, 4); | 954 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OBJECT_ID, 4); |
949 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OFFSET, 1); | 955 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OFFSET, 1); |
950 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OBJECT_ID, 4); | 956 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OBJECT_ID, 4); |
951 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OFFSET, 1); | 957 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OFFSET, 1); |
952 | 958 |
953 root.child_ids.push_back(2); | 959 root.child_ids.push_back(2); |
954 div_editable.child_ids.push_back(3); | 960 div_editable.child_ids.push_back(3); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 0L /* selection_index */, &selection_start, &selection_end);; | 1163 0L /* selection_index */, &selection_start, &selection_end);; |
1158 EXPECT_EQ(S_OK, hr); | 1164 EXPECT_EQ(S_OK, hr); |
1159 EXPECT_EQ(1L, selection_start); | 1165 EXPECT_EQ(1L, selection_start); |
1160 EXPECT_EQ(7L, selection_end); | 1166 EXPECT_EQ(7L, selection_end); |
1161 | 1167 |
1162 manager.reset(); | 1168 manager.reset(); |
1163 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 1169 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
1164 } | 1170 } |
1165 | 1171 |
1166 } // namespace content | 1172 } // namespace content |
OLD | NEW |