| 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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 962 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); |
| 963 link.SetName("here"); | 963 link.SetName("here"); |
| 964 | 964 |
| 965 ui::AXNodeData link_text; | 965 ui::AXNodeData link_text; |
| 966 link_text.id = 5; | 966 link_text.id = 5; |
| 967 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 967 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 968 link_text.state = (1 << ui::AX_STATE_EDITABLE) | | 968 link_text.state = (1 << ui::AX_STATE_EDITABLE) | |
| 969 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 969 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); |
| 970 link_text.SetName("here"); | 970 link_text.SetName("here"); |
| 971 | 971 |
| 972 // Place the caret between 'h' and 'e'. | |
| 973 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OBJECT_ID, 5); | |
| 974 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OFFSET, 1); | |
| 975 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OBJECT_ID, 5); | |
| 976 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OFFSET, 1); | |
| 977 | |
| 978 root.child_ids.push_back(2); | 972 root.child_ids.push_back(2); |
| 979 div_editable.child_ids.push_back(3); | 973 div_editable.child_ids.push_back(3); |
| 980 div_editable.child_ids.push_back(4); | 974 div_editable.child_ids.push_back(4); |
| 981 link.child_ids.push_back(5); | 975 link.child_ids.push_back(5); |
| 982 | 976 |
| 977 ui::AXTreeUpdate update = MakeAXTreeUpdate( |
| 978 root, div_editable, link, link_text, text); |
| 979 |
| 980 // Place the caret between 'h' and 'e'. |
| 981 update.has_tree_data = true; |
| 982 update.tree_data.sel_anchor_object_id = 5; |
| 983 update.tree_data.sel_anchor_offset = 1; |
| 984 update.tree_data.sel_focus_object_id = 5; |
| 985 update.tree_data.sel_focus_offset = 1; |
| 986 |
| 983 CountedBrowserAccessibility::reset(); | 987 CountedBrowserAccessibility::reset(); |
| 984 scoped_ptr<BrowserAccessibilityManager> manager( | 988 scoped_ptr<BrowserAccessibilityManager> manager( |
| 985 BrowserAccessibilityManager::Create( | 989 BrowserAccessibilityManager::Create( |
| 986 MakeAXTreeUpdate(root, div_editable, link, link_text, text), | 990 update, |
| 987 nullptr, new CountedBrowserAccessibilityFactory())); | 991 nullptr, new CountedBrowserAccessibilityFactory())); |
| 988 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); | 992 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); |
| 989 | 993 |
| 990 ASSERT_NE(nullptr, manager->GetRoot()); | 994 ASSERT_NE(nullptr, manager->GetRoot()); |
| 991 BrowserAccessibilityWin* root_accessible = | 995 BrowserAccessibilityWin* root_accessible = |
| 992 manager->GetRoot()->ToBrowserAccessibilityWin(); | 996 manager->GetRoot()->ToBrowserAccessibilityWin(); |
| 993 ASSERT_NE(nullptr, root_accessible); | 997 ASSERT_NE(nullptr, root_accessible); |
| 994 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); | 998 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); |
| 995 | 999 |
| 996 BrowserAccessibilityWin* div_editable_accessible = | 1000 BrowserAccessibilityWin* div_editable_accessible = |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 link.role = ui::AX_ROLE_LINK; | 1081 link.role = ui::AX_ROLE_LINK; |
| 1078 link.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 1082 link.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); |
| 1079 link.SetName("here"); | 1083 link.SetName("here"); |
| 1080 | 1084 |
| 1081 ui::AXNodeData link_text; | 1085 ui::AXNodeData link_text; |
| 1082 link_text.id = 5; | 1086 link_text.id = 5; |
| 1083 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 1087 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1084 link_text.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 1088 link_text.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); |
| 1085 link_text.SetName("here"); | 1089 link_text.SetName("here"); |
| 1086 | 1090 |
| 1087 // Select the following part of the text: "lick here". | |
| 1088 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OBJECT_ID, 3); | |
| 1089 root.AddIntAttribute(ui::AX_ATTR_ANCHOR_OFFSET, 1); | |
| 1090 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OBJECT_ID, 5); | |
| 1091 root.AddIntAttribute(ui::AX_ATTR_FOCUS_OFFSET, 4); | |
| 1092 | |
| 1093 root.child_ids.push_back(2); | 1091 root.child_ids.push_back(2); |
| 1094 div_editable.child_ids.push_back(3); | 1092 div_editable.child_ids.push_back(3); |
| 1095 div_editable.child_ids.push_back(4); | 1093 div_editable.child_ids.push_back(4); |
| 1096 link.child_ids.push_back(5); | 1094 link.child_ids.push_back(5); |
| 1097 | 1095 |
| 1096 ui::AXTreeUpdate update = |
| 1097 MakeAXTreeUpdate(root, div_editable, link, link_text, text); |
| 1098 |
| 1099 // Select the following part of the text: "lick here". |
| 1100 update.has_tree_data = true; |
| 1101 update.tree_data.sel_anchor_object_id = 3; |
| 1102 update.tree_data.sel_anchor_offset = 1; |
| 1103 update.tree_data.sel_focus_object_id = 5; |
| 1104 update.tree_data.sel_focus_offset = 4; |
| 1105 |
| 1098 CountedBrowserAccessibility::reset(); | 1106 CountedBrowserAccessibility::reset(); |
| 1099 scoped_ptr<BrowserAccessibilityManager> manager( | 1107 scoped_ptr<BrowserAccessibilityManager> manager( |
| 1100 BrowserAccessibilityManager::Create( | 1108 BrowserAccessibilityManager::Create( |
| 1101 MakeAXTreeUpdate(root, div_editable, link, link_text, text), | 1109 update, |
| 1102 nullptr, new CountedBrowserAccessibilityFactory())); | 1110 nullptr, new CountedBrowserAccessibilityFactory())); |
| 1103 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); | 1111 ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); |
| 1104 | 1112 |
| 1105 ASSERT_NE(nullptr, manager->GetRoot()); | 1113 ASSERT_NE(nullptr, manager->GetRoot()); |
| 1106 BrowserAccessibilityWin* root_accessible = | 1114 BrowserAccessibilityWin* root_accessible = |
| 1107 manager->GetRoot()->ToBrowserAccessibilityWin(); | 1115 manager->GetRoot()->ToBrowserAccessibilityWin(); |
| 1108 ASSERT_NE(nullptr, root_accessible); | 1116 ASSERT_NE(nullptr, root_accessible); |
| 1109 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); | 1117 ASSERT_EQ(1U, root_accessible->PlatformChildCount()); |
| 1110 | 1118 |
| 1111 BrowserAccessibilityWin* div_editable_accessible = | 1119 BrowserAccessibilityWin* div_editable_accessible = |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 } | 1422 } |
| 1415 | 1423 |
| 1416 TEST_F(BrowserAccessibilityTest, TestSanitizeStringAttributeForIA2) { | 1424 TEST_F(BrowserAccessibilityTest, TestSanitizeStringAttributeForIA2) { |
| 1417 base::string16 input(L"\\:=,;"); | 1425 base::string16 input(L"\\:=,;"); |
| 1418 base::string16 output; | 1426 base::string16 output; |
| 1419 BrowserAccessibilityWin::SanitizeStringAttributeForIA2(input, &output); | 1427 BrowserAccessibilityWin::SanitizeStringAttributeForIA2(input, &output); |
| 1420 EXPECT_EQ(L"\\\\\\:\\=\\,\\;", output); | 1428 EXPECT_EQ(L"\\\\\\:\\=\\,\\;", output); |
| 1421 } | 1429 } |
| 1422 | 1430 |
| 1423 } // namespace content | 1431 } // namespace content |
| OLD | NEW |