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

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

Issue 10544099: Refactor all accessibility code out of webkit/glue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More Mac compile errors Created 8 years, 6 months 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
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/common/accessibility_node_data.h"
13 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_types.h" 15 #include "content/public/browser/notification_types.h"
15 #include "content/public/browser/render_widget_host_view.h" 16 #include "content/public/browser/render_widget_host_view.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 18
18 #if defined(OS_WIN) 19 #if defined(OS_WIN)
19 #include <atlbase.h> 20 #include <atlbase.h>
20 #include <atlcom.h> 21 #include <atlcom.h>
21 #include "ui/base/win/atl_module.h" 22 #include "ui/base/win/atl_module.h"
22 #endif 23 #endif
23 24
25 using content::AccessibilityNodeData;
24 using content::OpenURLParams; 26 using content::OpenURLParams;
25 using content::RenderViewHostImpl; 27 using content::RenderViewHostImpl;
26 using content::RenderWidgetHostImpl; 28 using content::RenderWidgetHostImpl;
27 using content::Referrer; 29 using content::Referrer;
28 using webkit_glue::WebAccessibility;
29 30
30 namespace { 31 namespace {
31 32
32 class RendererAccessibilityBrowserTest : public InProcessBrowserTest { 33 class RendererAccessibilityBrowserTest : public InProcessBrowserTest {
33 public: 34 public:
34 RendererAccessibilityBrowserTest() {} 35 RendererAccessibilityBrowserTest() {}
35 36
36 // Tell the renderer to send an accessibility tree, then wait for the 37 // Tell the renderer to send an accessibility tree, then wait for the
37 // notification that it's been received. 38 // notification that it's been received.
38 const WebAccessibility& GetWebAccessibilityTree( 39 const AccessibilityNodeData& GetAccessibilityNodeDataTree(
39 AccessibilityMode accessibility_mode = AccessibilityModeComplete) { 40 AccessibilityMode accessibility_mode = AccessibilityModeComplete) {
40 ui_test_utils::WindowedNotificationObserver tree_updated_observer( 41 ui_test_utils::WindowedNotificationObserver tree_updated_observer(
41 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 42 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
42 content::NotificationService::AllSources()); 43 content::NotificationService::AllSources());
43 content::RenderWidgetHostView* host_view = 44 content::RenderWidgetHostView* host_view =
44 browser()->GetSelectedWebContents()->GetRenderWidgetHostView(); 45 browser()->GetSelectedWebContents()->GetRenderWidgetHostView();
45 RenderWidgetHostImpl* host = 46 RenderWidgetHostImpl* host =
46 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost()); 47 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost());
47 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host); 48 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host);
48 view_host->set_save_accessibility_tree_for_testing(true); 49 view_host->set_save_accessibility_tree_for_testing(true);
49 view_host->SetAccessibilityMode(accessibility_mode); 50 view_host->SetAccessibilityMode(accessibility_mode);
50 tree_updated_observer.Wait(); 51 tree_updated_observer.Wait();
51 return view_host->accessibility_tree_for_testing(); 52 return view_host->accessibility_tree_for_testing();
52 } 53 }
53 54
54 // Make sure each node in the tree has an unique id. 55 // Make sure each node in the tree has an unique id.
55 void RecursiveAssertUniqueIds( 56 void RecursiveAssertUniqueIds(
56 const WebAccessibility& node, base::hash_set<int>* ids) { 57 const AccessibilityNodeData& node, base::hash_set<int>* ids) {
57 ASSERT_TRUE(ids->find(node.id) == ids->end()); 58 ASSERT_TRUE(ids->find(node.id) == ids->end());
58 ids->insert(node.id); 59 ids->insert(node.id);
59 for (size_t i = 0; i < node.children.size(); i++) 60 for (size_t i = 0; i < node.children.size(); i++)
60 RecursiveAssertUniqueIds(node.children[i], ids); 61 RecursiveAssertUniqueIds(node.children[i], ids);
61 } 62 }
62 63
63 // InProcessBrowserTest 64 // InProcessBrowserTest
64 void SetUpInProcessBrowserTestFixture(); 65 void SetUpInProcessBrowserTestFixture();
65 void TearDownInProcessBrowserTestFixture(); 66 void TearDownInProcessBrowserTestFixture();
66 67
67 protected: 68 protected:
68 std::string GetAttr(const WebAccessibility& node, 69 std::string GetAttr(const AccessibilityNodeData& node,
69 const WebAccessibility::StringAttribute attr); 70 const AccessibilityNodeData::StringAttribute attr);
70 int GetIntAttr(const WebAccessibility& node, 71 int GetIntAttr(const AccessibilityNodeData& node,
71 const WebAccessibility::IntAttribute attr); 72 const AccessibilityNodeData::IntAttribute attr);
72 bool GetBoolAttr(const WebAccessibility& node, 73 bool GetBoolAttr(const AccessibilityNodeData& node,
73 const WebAccessibility::BoolAttribute attr); 74 const AccessibilityNodeData::BoolAttribute attr);
74 }; 75 };
75 76
76 void RendererAccessibilityBrowserTest::SetUpInProcessBrowserTestFixture() { 77 void RendererAccessibilityBrowserTest::SetUpInProcessBrowserTestFixture() {
77 #if defined(OS_WIN) 78 #if defined(OS_WIN)
78 ui::win::CreateATLModuleIfNeeded(); 79 ui::win::CreateATLModuleIfNeeded();
79 ::CoInitialize(NULL); 80 ::CoInitialize(NULL);
80 #endif 81 #endif
81 } 82 }
82 83
83 void RendererAccessibilityBrowserTest::TearDownInProcessBrowserTestFixture() { 84 void RendererAccessibilityBrowserTest::TearDownInProcessBrowserTestFixture() {
84 #if defined(OS_WIN) 85 #if defined(OS_WIN)
85 ::CoUninitialize(); 86 ::CoUninitialize();
86 #endif 87 #endif
87 } 88 }
88 89
89 // Convenience method to get the value of a particular WebAccessibility 90 // Convenience method to get the value of a particular AccessibilityNodeData
90 // node attribute as a UTF-8 const char*. 91 // node attribute as a UTF-8 const char*.
91 std::string RendererAccessibilityBrowserTest::GetAttr( 92 std::string RendererAccessibilityBrowserTest::GetAttr(
92 const WebAccessibility& node, 93 const AccessibilityNodeData& node,
93 const WebAccessibility::StringAttribute attr) { 94 const AccessibilityNodeData::StringAttribute attr) {
94 std::map<WebAccessibility::StringAttribute, string16>::const_iterator iter = 95 std::map<AccessibilityNodeData::StringAttribute, string16>::const_iterator
95 node.string_attributes.find(attr); 96 iter = node.string_attributes.find(attr);
96 if (iter != node.string_attributes.end()) 97 if (iter != node.string_attributes.end())
97 return UTF16ToUTF8(iter->second); 98 return UTF16ToUTF8(iter->second);
98 else 99 else
99 return ""; 100 return "";
100 } 101 }
101 102
102 // Convenience method to get the value of a particular WebAccessibility 103 // Convenience method to get the value of a particular AccessibilityNodeData
103 // node integer attribute. 104 // node integer attribute.
104 int RendererAccessibilityBrowserTest::GetIntAttr( 105 int RendererAccessibilityBrowserTest::GetIntAttr(
105 const WebAccessibility& node, 106 const AccessibilityNodeData& node,
106 const WebAccessibility::IntAttribute attr) { 107 const AccessibilityNodeData::IntAttribute attr) {
107 std::map<WebAccessibility::IntAttribute, int32>::const_iterator iter = 108 std::map<AccessibilityNodeData::IntAttribute, int32>::const_iterator iter =
108 node.int_attributes.find(attr); 109 node.int_attributes.find(attr);
109 if (iter != node.int_attributes.end()) 110 if (iter != node.int_attributes.end())
110 return iter->second; 111 return iter->second;
111 else 112 else
112 return -1; 113 return -1;
113 } 114 }
114 115
115 // Convenience method to get the value of a particular WebAccessibility 116 // Convenience method to get the value of a particular AccessibilityNodeData
116 // node boolean attribute. 117 // node boolean attribute.
117 bool RendererAccessibilityBrowserTest::GetBoolAttr( 118 bool RendererAccessibilityBrowserTest::GetBoolAttr(
118 const WebAccessibility& node, 119 const AccessibilityNodeData& node,
119 const WebAccessibility::BoolAttribute attr) { 120 const AccessibilityNodeData::BoolAttribute attr) {
120 std::map<WebAccessibility::BoolAttribute, bool>::const_iterator iter = 121 std::map<AccessibilityNodeData::BoolAttribute, bool>::const_iterator iter =
121 node.bool_attributes.find(attr); 122 node.bool_attributes.find(attr);
122 if (iter != node.bool_attributes.end()) 123 if (iter != node.bool_attributes.end())
123 return iter->second; 124 return iter->second;
124 else 125 else
125 return false; 126 return false;
126 } 127 }
127 128
128 // Marked flaky per http://crbug.com/101984 129 // Marked flaky per http://crbug.com/101984
129 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 130 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
130 DISABLED_CrossPlatformWebpageAccessibility) { 131 DISABLED_CrossPlatformWebpageAccessibility) {
131 // Create a data url and load it. 132 // Create a data url and load it.
132 const char url_str[] = 133 const char url_str[] =
133 "data:text/html," 134 "data:text/html,"
134 "<!doctype html>" 135 "<!doctype html>"
135 "<html><head><title>Accessibility Test</title></head>" 136 "<html><head><title>Accessibility Test</title></head>"
136 "<body><input type='button' value='push' /><input type='checkbox' />" 137 "<body><input type='button' value='push' /><input type='checkbox' />"
137 "</body></html>"; 138 "</body></html>";
138 GURL url(url_str); 139 GURL url(url_str);
139 browser()->OpenURL(OpenURLParams( 140 browser()->OpenURL(OpenURLParams(
140 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 141 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
141 const WebAccessibility& tree = GetWebAccessibilityTree(); 142 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
142 143
143 // Check properties of the root element of the tree. 144 // Check properties of the root element of the tree.
144 EXPECT_STREQ(url_str, GetAttr(tree, WebAccessibility::ATTR_DOC_URL).c_str()); 145 EXPECT_STREQ(url_str,
146 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_URL).c_str());
145 EXPECT_STREQ( 147 EXPECT_STREQ(
146 "Accessibility Test", 148 "Accessibility Test",
147 GetAttr(tree, WebAccessibility::ATTR_DOC_TITLE).c_str()); 149 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_TITLE).c_str());
148 EXPECT_STREQ( 150 EXPECT_STREQ(
149 "html", GetAttr(tree, WebAccessibility::ATTR_DOC_DOCTYPE).c_str()); 151 "html", GetAttr(tree, AccessibilityNodeData::ATTR_DOC_DOCTYPE).c_str());
150 EXPECT_STREQ( 152 EXPECT_STREQ(
151 "text/html", GetAttr(tree, WebAccessibility::ATTR_DOC_MIMETYPE).c_str()); 153 "text/html",
154 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_MIMETYPE).c_str());
152 EXPECT_STREQ("Accessibility Test", UTF16ToUTF8(tree.name).c_str()); 155 EXPECT_STREQ("Accessibility Test", UTF16ToUTF8(tree.name).c_str());
153 EXPECT_EQ(WebAccessibility::ROLE_ROOT_WEB_AREA, tree.role); 156 EXPECT_EQ(AccessibilityNodeData::ROLE_ROOT_WEB_AREA, tree.role);
154 157
155 // Check properites of the BODY element. 158 // Check properites of the BODY element.
156 ASSERT_EQ(1U, tree.children.size()); 159 ASSERT_EQ(1U, tree.children.size());
157 const WebAccessibility& body = tree.children[0]; 160 const AccessibilityNodeData& body = tree.children[0];
158 EXPECT_EQ(WebAccessibility::ROLE_GROUP, body.role); 161 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, body.role);
159 EXPECT_STREQ("body", GetAttr(body, WebAccessibility::ATTR_HTML_TAG).c_str()); 162 EXPECT_STREQ("body",
160 EXPECT_STREQ("block", GetAttr(body, WebAccessibility::ATTR_DISPLAY).c_str()); 163 GetAttr(body, AccessibilityNodeData::ATTR_HTML_TAG).c_str());
164 EXPECT_STREQ("block",
165 GetAttr(body, AccessibilityNodeData::ATTR_DISPLAY).c_str());
161 166
162 // Check properties of the two children of the BODY element. 167 // Check properties of the two children of the BODY element.
163 ASSERT_EQ(2U, body.children.size()); 168 ASSERT_EQ(2U, body.children.size());
164 169
165 const WebAccessibility& button = body.children[0]; 170 const AccessibilityNodeData& button = body.children[0];
166 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, button.role); 171 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button.role);
167 EXPECT_STREQ( 172 EXPECT_STREQ(
168 "input", GetAttr(button, WebAccessibility::ATTR_HTML_TAG).c_str()); 173 "input", GetAttr(button, AccessibilityNodeData::ATTR_HTML_TAG).c_str());
169 EXPECT_STREQ("push", UTF16ToUTF8(button.name).c_str()); 174 EXPECT_STREQ("push", UTF16ToUTF8(button.name).c_str());
170 EXPECT_STREQ( 175 EXPECT_STREQ(
171 "inline-block", GetAttr(button, WebAccessibility::ATTR_DISPLAY).c_str()); 176 "inline-block",
177 GetAttr(button, AccessibilityNodeData::ATTR_DISPLAY).c_str());
172 ASSERT_EQ(2U, button.html_attributes.size()); 178 ASSERT_EQ(2U, button.html_attributes.size());
173 EXPECT_STREQ("type", UTF16ToUTF8(button.html_attributes[0].first).c_str()); 179 EXPECT_STREQ("type", UTF16ToUTF8(button.html_attributes[0].first).c_str());
174 EXPECT_STREQ("button", UTF16ToUTF8(button.html_attributes[0].second).c_str()); 180 EXPECT_STREQ("button", UTF16ToUTF8(button.html_attributes[0].second).c_str());
175 EXPECT_STREQ("value", UTF16ToUTF8(button.html_attributes[1].first).c_str()); 181 EXPECT_STREQ("value", UTF16ToUTF8(button.html_attributes[1].first).c_str());
176 EXPECT_STREQ("push", UTF16ToUTF8(button.html_attributes[1].second).c_str()); 182 EXPECT_STREQ("push", UTF16ToUTF8(button.html_attributes[1].second).c_str());
177 183
178 const WebAccessibility& checkbox = body.children[1]; 184 const AccessibilityNodeData& checkbox = body.children[1];
179 EXPECT_EQ(WebAccessibility::ROLE_CHECKBOX, checkbox.role); 185 EXPECT_EQ(AccessibilityNodeData::ROLE_CHECKBOX, checkbox.role);
180 EXPECT_STREQ( 186 EXPECT_STREQ(
181 "input", GetAttr(checkbox, WebAccessibility::ATTR_HTML_TAG).c_str()); 187 "input", GetAttr(checkbox, AccessibilityNodeData::ATTR_HTML_TAG).c_str());
182 EXPECT_STREQ( 188 EXPECT_STREQ(
183 "inline-block", 189 "inline-block",
184 GetAttr(checkbox, WebAccessibility::ATTR_DISPLAY).c_str()); 190 GetAttr(checkbox, AccessibilityNodeData::ATTR_DISPLAY).c_str());
185 ASSERT_EQ(1U, checkbox.html_attributes.size()); 191 ASSERT_EQ(1U, checkbox.html_attributes.size());
186 EXPECT_STREQ( 192 EXPECT_STREQ(
187 "type", UTF16ToUTF8(checkbox.html_attributes[0].first).c_str()); 193 "type", UTF16ToUTF8(checkbox.html_attributes[0].first).c_str());
188 EXPECT_STREQ( 194 EXPECT_STREQ(
189 "checkbox", UTF16ToUTF8(checkbox.html_attributes[0].second).c_str()); 195 "checkbox", UTF16ToUTF8(checkbox.html_attributes[0].second).c_str());
190 } 196 }
191 197
192 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 198 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
193 CrossPlatformUnselectedEditableTextAccessibility) { 199 CrossPlatformUnselectedEditableTextAccessibility) {
194 // Create a data url and load it. 200 // Create a data url and load it.
195 const char url_str[] = 201 const char url_str[] =
196 "data:text/html," 202 "data:text/html,"
197 "<!doctype html>" 203 "<!doctype html>"
198 "<body>" 204 "<body>"
199 "<input value=\"Hello, world.\"/>" 205 "<input value=\"Hello, world.\"/>"
200 "</body></html>"; 206 "</body></html>";
201 GURL url(url_str); 207 GURL url(url_str);
202 browser()->OpenURL(OpenURLParams( 208 browser()->OpenURL(OpenURLParams(
203 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 209 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
204 210
205 const WebAccessibility& tree = GetWebAccessibilityTree(); 211 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
206 ASSERT_EQ(1U, tree.children.size()); 212 ASSERT_EQ(1U, tree.children.size());
207 const WebAccessibility& body = tree.children[0]; 213 const AccessibilityNodeData& body = tree.children[0];
208 ASSERT_EQ(1U, body.children.size()); 214 ASSERT_EQ(1U, body.children.size());
209 const WebAccessibility& text = body.children[0]; 215 const AccessibilityNodeData& text = body.children[0];
210 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text.role); 216 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role);
211 EXPECT_STREQ( 217 EXPECT_STREQ(
212 "input", GetAttr(text, WebAccessibility::ATTR_HTML_TAG).c_str()); 218 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str());
213 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_START)); 219 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START));
214 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_END)); 220 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END));
215 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); 221 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str());
216 222
217 // TODO(dmazzoni): as soon as more accessibility code is cross-platform, 223 // TODO(dmazzoni): as soon as more accessibility code is cross-platform,
218 // this code should test that the accessible info is dynamically updated 224 // this code should test that the accessible info is dynamically updated
219 // if the selection or value changes. 225 // if the selection or value changes.
220 } 226 }
221 227
222 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 228 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
223 CrossPlatformSelectedEditableTextAccessibility) { 229 CrossPlatformSelectedEditableTextAccessibility) {
224 // Create a data url and load it. 230 // Create a data url and load it.
225 const char url_str[] = 231 const char url_str[] =
226 "data:text/html," 232 "data:text/html,"
227 "<!doctype html>" 233 "<!doctype html>"
228 "<body onload=\"document.body.children[0].select();\">" 234 "<body onload=\"document.body.children[0].select();\">"
229 "<input value=\"Hello, world.\"/>" 235 "<input value=\"Hello, world.\"/>"
230 "</body></html>"; 236 "</body></html>";
231 GURL url(url_str); 237 GURL url(url_str);
232 browser()->OpenURL(OpenURLParams( 238 browser()->OpenURL(OpenURLParams(
233 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 239 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
234 240
235 const WebAccessibility& tree = GetWebAccessibilityTree(); 241 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
236 ASSERT_EQ(1U, tree.children.size()); 242 ASSERT_EQ(1U, tree.children.size());
237 const WebAccessibility& body = tree.children[0]; 243 const AccessibilityNodeData& body = tree.children[0];
238 ASSERT_EQ(1U, body.children.size()); 244 ASSERT_EQ(1U, body.children.size());
239 const WebAccessibility& text = body.children[0]; 245 const AccessibilityNodeData& text = body.children[0];
240 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text.role); 246 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role);
241 EXPECT_STREQ( 247 EXPECT_STREQ(
242 "input", GetAttr(text, WebAccessibility::ATTR_HTML_TAG).c_str()); 248 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str());
243 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_START)); 249 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START));
244 EXPECT_EQ(13, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_END)); 250 EXPECT_EQ(13, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END));
245 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); 251 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str());
246 } 252 }
247 253
248 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 254 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
249 CrossPlatformMultipleInheritanceAccessibility) { 255 CrossPlatformMultipleInheritanceAccessibility) {
250 // In a WebKit accessibility render tree for a table, each cell is a 256 // In a WebKit accessibility render tree for a table, each cell is a
251 // child of both a row and a column, so it appears to use multiple 257 // child of both a row and a column, so it appears to use multiple
252 // inheritance. Make sure that the WebAccessibilityObject tree only 258 // inheritance. Make sure that the AccessibilityNodeDataObject tree only
253 // keeps one copy of each cell, and uses an indirect child id for the 259 // keeps one copy of each cell, and uses an indirect child id for the
254 // additional reference to it. 260 // additional reference to it.
255 const char url_str[] = 261 const char url_str[] =
256 "data:text/html," 262 "data:text/html,"
257 "<!doctype html>" 263 "<!doctype html>"
258 "<table border=1><tr><td>1</td><td>2</td></tr></table>"; 264 "<table border=1><tr><td>1</td><td>2</td></tr></table>";
259 GURL url(url_str); 265 GURL url(url_str);
260 browser()->OpenURL(OpenURLParams( 266 browser()->OpenURL(OpenURLParams(
261 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 267 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
262 268
263 const WebAccessibility& tree = GetWebAccessibilityTree(); 269 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
264 ASSERT_EQ(1U, tree.children.size()); 270 ASSERT_EQ(1U, tree.children.size());
265 const WebAccessibility& table = tree.children[0]; 271 const AccessibilityNodeData& table = tree.children[0];
266 EXPECT_EQ(WebAccessibility::ROLE_TABLE, table.role); 272 EXPECT_EQ(AccessibilityNodeData::ROLE_TABLE, table.role);
267 const WebAccessibility& row = table.children[0]; 273 const AccessibilityNodeData& row = table.children[0];
268 EXPECT_EQ(WebAccessibility::ROLE_ROW, row.role); 274 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, row.role);
269 const WebAccessibility& cell1 = row.children[0]; 275 const AccessibilityNodeData& cell1 = row.children[0];
270 EXPECT_EQ(WebAccessibility::ROLE_CELL, cell1.role); 276 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell1.role);
271 const WebAccessibility& cell2 = row.children[1]; 277 const AccessibilityNodeData& cell2 = row.children[1];
272 EXPECT_EQ(WebAccessibility::ROLE_CELL, cell2.role); 278 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell2.role);
273 const WebAccessibility& column1 = table.children[1]; 279 const AccessibilityNodeData& column1 = table.children[1];
274 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, column1.role); 280 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column1.role);
275 EXPECT_EQ(0U, column1.children.size()); 281 EXPECT_EQ(0U, column1.children.size());
276 EXPECT_EQ(1U, column1.indirect_child_ids.size()); 282 EXPECT_EQ(1U, column1.indirect_child_ids.size());
277 EXPECT_EQ(cell1.id, column1.indirect_child_ids[0]); 283 EXPECT_EQ(cell1.id, column1.indirect_child_ids[0]);
278 const WebAccessibility& column2 = table.children[2]; 284 const AccessibilityNodeData& column2 = table.children[2];
279 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, column2.role); 285 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column2.role);
280 EXPECT_EQ(0U, column2.children.size()); 286 EXPECT_EQ(0U, column2.children.size());
281 EXPECT_EQ(1U, column2.indirect_child_ids.size()); 287 EXPECT_EQ(1U, column2.indirect_child_ids.size());
282 EXPECT_EQ(cell2.id, column2.indirect_child_ids[0]); 288 EXPECT_EQ(cell2.id, column2.indirect_child_ids[0]);
283 } 289 }
284 290
285 IN_PROC_BROWSER_TEST_F( 291 IN_PROC_BROWSER_TEST_F(
286 RendererAccessibilityBrowserTest, 292 RendererAccessibilityBrowserTest,
287 CrossPlatformMultipleInheritanceAccessibility2) { 293 CrossPlatformMultipleInheritanceAccessibility2) {
288 // Here's another html snippet where WebKit puts the same node as a child 294 // Here's another html snippet where WebKit puts the same node as a child
289 // of two different parents. Instead of checking the exact output, just 295 // of two different parents. Instead of checking the exact output, just
290 // make sure that no id is reused in the resulting tree. 296 // make sure that no id is reused in the resulting tree.
291 const char url_str[] = 297 const char url_str[] =
292 "data:text/html," 298 "data:text/html,"
293 "<!doctype html>" 299 "<!doctype html>"
294 "<script>\n" 300 "<script>\n"
295 " document.writeln('<q><section></section></q><q><li>');\n" 301 " document.writeln('<q><section></section></q><q><li>');\n"
296 " setTimeout(function() {\n" 302 " setTimeout(function() {\n"
297 " document.close();\n" 303 " document.close();\n"
298 " }, 1);\n" 304 " }, 1);\n"
299 "</script>"; 305 "</script>";
300 GURL url(url_str); 306 GURL url(url_str);
301 browser()->OpenURL(OpenURLParams( 307 browser()->OpenURL(OpenURLParams(
302 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 308 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
303 309
304 const WebAccessibility& tree = GetWebAccessibilityTree(); 310 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
305 base::hash_set<int> ids; 311 base::hash_set<int> ids;
306 RecursiveAssertUniqueIds(tree, &ids); 312 RecursiveAssertUniqueIds(tree, &ids);
307 } 313 }
308 314
309 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 315 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
310 CrossPlatformIframeAccessibility) { 316 CrossPlatformIframeAccessibility) {
311 // Create a data url and load it. 317 // Create a data url and load it.
312 const char url_str[] = 318 const char url_str[] =
313 "data:text/html," 319 "data:text/html,"
314 "<!doctype html><html><body>" 320 "<!doctype html><html><body>"
315 "<button>Button 1</button>" 321 "<button>Button 1</button>"
316 "<iframe src='data:text/html," 322 "<iframe src='data:text/html,"
317 "<!doctype html><html><body><button>Button 2</button></body></html>" 323 "<!doctype html><html><body><button>Button 2</button></body></html>"
318 "'></iframe>" 324 "'></iframe>"
319 "<button>Button 3</button>" 325 "<button>Button 3</button>"
320 "</body></html>"; 326 "</body></html>";
321 GURL url(url_str); 327 GURL url(url_str);
322 browser()->OpenURL(OpenURLParams( 328 browser()->OpenURL(OpenURLParams(
323 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 329 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
324 330
325 const WebAccessibility& tree = GetWebAccessibilityTree(); 331 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
326 ASSERT_EQ(1U, tree.children.size()); 332 ASSERT_EQ(1U, tree.children.size());
327 const WebAccessibility& body = tree.children[0]; 333 const AccessibilityNodeData& body = tree.children[0];
328 ASSERT_EQ(3U, body.children.size()); 334 ASSERT_EQ(3U, body.children.size());
329 335
330 const WebAccessibility& button1 = body.children[0]; 336 const AccessibilityNodeData& button1 = body.children[0];
331 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, button1.role); 337 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button1.role);
332 EXPECT_STREQ("Button 1", UTF16ToUTF8(button1.name).c_str()); 338 EXPECT_STREQ("Button 1", UTF16ToUTF8(button1.name).c_str());
333 339
334 const WebAccessibility& iframe = body.children[1]; 340 const AccessibilityNodeData& iframe = body.children[1];
335 EXPECT_STREQ("iframe", 341 EXPECT_STREQ("iframe",
336 GetAttr(iframe, WebAccessibility::ATTR_HTML_TAG).c_str()); 342 GetAttr(iframe, AccessibilityNodeData::ATTR_HTML_TAG).c_str());
337 ASSERT_EQ(1U, iframe.children.size()); 343 ASSERT_EQ(1U, iframe.children.size());
338 344
339 const WebAccessibility& scroll_area = iframe.children[0]; 345 const AccessibilityNodeData& scroll_area = iframe.children[0];
340 EXPECT_EQ(WebAccessibility::ROLE_SCROLLAREA, scroll_area.role); 346 EXPECT_EQ(AccessibilityNodeData::ROLE_SCROLLAREA, scroll_area.role);
341 ASSERT_EQ(1U, scroll_area.children.size()); 347 ASSERT_EQ(1U, scroll_area.children.size());
342 348
343 const WebAccessibility& sub_document = scroll_area.children[0]; 349 const AccessibilityNodeData& sub_document = scroll_area.children[0];
344 EXPECT_EQ(WebAccessibility::ROLE_WEB_AREA, sub_document.role); 350 EXPECT_EQ(AccessibilityNodeData::ROLE_WEB_AREA, sub_document.role);
345 ASSERT_EQ(1U, sub_document.children.size()); 351 ASSERT_EQ(1U, sub_document.children.size());
346 352
347 const WebAccessibility& sub_body = sub_document.children[0]; 353 const AccessibilityNodeData& sub_body = sub_document.children[0];
348 ASSERT_EQ(1U, sub_body.children.size()); 354 ASSERT_EQ(1U, sub_body.children.size());
349 355
350 const WebAccessibility& button2 = sub_body.children[0]; 356 const AccessibilityNodeData& button2 = sub_body.children[0];
351 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, button2.role); 357 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button2.role);
352 EXPECT_STREQ("Button 2", UTF16ToUTF8(button2.name).c_str()); 358 EXPECT_STREQ("Button 2", UTF16ToUTF8(button2.name).c_str());
353 359
354 const WebAccessibility& button3 = body.children[2]; 360 const AccessibilityNodeData& button3 = body.children[2];
355 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, button3.role); 361 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button3.role);
356 EXPECT_STREQ("Button 3", UTF16ToUTF8(button3.name).c_str()); 362 EXPECT_STREQ("Button 3", UTF16ToUTF8(button3.name).c_str());
357 } 363 }
358 364
359 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 365 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
360 CrossPlatformDuplicateChildrenAccessibility) { 366 CrossPlatformDuplicateChildrenAccessibility) {
361 // Here's another html snippet where WebKit has a parent node containing 367 // Here's another html snippet where WebKit has a parent node containing
362 // two duplicate child nodes. Instead of checking the exact output, just 368 // two duplicate child nodes. Instead of checking the exact output, just
363 // make sure that no id is reused in the resulting tree. 369 // make sure that no id is reused in the resulting tree.
364 const char url_str[] = 370 const char url_str[] =
365 "data:text/html," 371 "data:text/html,"
366 "<!doctype html>" 372 "<!doctype html>"
367 "<em><code ><h4 ></em>"; 373 "<em><code ><h4 ></em>";
368 GURL url(url_str); 374 GURL url(url_str);
369 browser()->OpenURL(OpenURLParams( 375 browser()->OpenURL(OpenURLParams(
370 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 376 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
371 377
372 const WebAccessibility& tree = GetWebAccessibilityTree(); 378 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
373 base::hash_set<int> ids; 379 base::hash_set<int> ids;
374 RecursiveAssertUniqueIds(tree, &ids); 380 RecursiveAssertUniqueIds(tree, &ids);
375 } 381 }
376 382
377 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 383 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
378 CrossPlatformTableSpan) { 384 CrossPlatformTableSpan) {
379 // +---+---+---+ 385 // +---+---+---+
380 // | 1 | 2 | 386 // | 1 | 2 |
381 // +---+---+---+ 387 // +---+---+---+
382 // | 3 | 4 | 388 // | 3 | 4 |
383 // +---+---+---+ 389 // +---+---+---+
384 390
385 const char url_str[] = 391 const char url_str[] =
386 "data:text/html," 392 "data:text/html,"
387 "<!doctype html>" 393 "<!doctype html>"
388 "<table border=1>" 394 "<table border=1>"
389 " <tr>" 395 " <tr>"
390 " <td colspan=2>1</td><td>2</td>" 396 " <td colspan=2>1</td><td>2</td>"
391 " </tr>" 397 " </tr>"
392 " <tr>" 398 " <tr>"
393 " <td>3</td><td colspan=2>4</td>" 399 " <td>3</td><td colspan=2>4</td>"
394 " </tr>" 400 " </tr>"
395 "</table>"; 401 "</table>";
396 GURL url(url_str); 402 GURL url(url_str);
397 browser()->OpenURL(OpenURLParams( 403 browser()->OpenURL(OpenURLParams(
398 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 404 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
399 405
400 const WebAccessibility& tree = GetWebAccessibilityTree(); 406 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
401 const WebAccessibility& table = tree.children[0]; 407 const AccessibilityNodeData& table = tree.children[0];
402 EXPECT_EQ(WebAccessibility::ROLE_TABLE, table.role); 408 EXPECT_EQ(AccessibilityNodeData::ROLE_TABLE, table.role);
403 ASSERT_GE(table.children.size(), 5U); 409 ASSERT_GE(table.children.size(), 5U);
404 EXPECT_EQ(WebAccessibility::ROLE_ROW, table.children[0].role); 410 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, table.children[0].role);
405 EXPECT_EQ(WebAccessibility::ROLE_ROW, table.children[1].role); 411 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, table.children[1].role);
406 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[2].role); 412 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[2].role);
407 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[3].role); 413 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[3].role);
408 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[4].role); 414 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[4].role);
409 EXPECT_EQ(3, GetIntAttr(table, WebAccessibility::ATTR_TABLE_COLUMN_COUNT)); 415 EXPECT_EQ(3,
410 EXPECT_EQ(2, GetIntAttr(table, WebAccessibility::ATTR_TABLE_ROW_COUNT)); 416 GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT));
417 EXPECT_EQ(2, GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_ROW_COUNT));
411 418
412 const WebAccessibility& cell1 = table.children[0].children[0]; 419 const AccessibilityNodeData& cell1 = table.children[0].children[0];
413 const WebAccessibility& cell2 = table.children[0].children[1]; 420 const AccessibilityNodeData& cell2 = table.children[0].children[1];
414 const WebAccessibility& cell3 = table.children[1].children[0]; 421 const AccessibilityNodeData& cell3 = table.children[1].children[0];
415 const WebAccessibility& cell4 = table.children[1].children[1]; 422 const AccessibilityNodeData& cell4 = table.children[1].children[1];
416 423
417 ASSERT_EQ(6U, table.cell_ids.size()); 424 ASSERT_EQ(6U, table.cell_ids.size());
418 EXPECT_EQ(cell1.id, table.cell_ids[0]); 425 EXPECT_EQ(cell1.id, table.cell_ids[0]);
419 EXPECT_EQ(cell1.id, table.cell_ids[1]); 426 EXPECT_EQ(cell1.id, table.cell_ids[1]);
420 EXPECT_EQ(cell2.id, table.cell_ids[2]); 427 EXPECT_EQ(cell2.id, table.cell_ids[2]);
421 EXPECT_EQ(cell3.id, table.cell_ids[3]); 428 EXPECT_EQ(cell3.id, table.cell_ids[3]);
422 EXPECT_EQ(cell4.id, table.cell_ids[4]); 429 EXPECT_EQ(cell4.id, table.cell_ids[4]);
423 EXPECT_EQ(cell4.id, table.cell_ids[5]); 430 EXPECT_EQ(cell4.id, table.cell_ids[5]);
424 431
425 EXPECT_EQ(0, GetIntAttr(cell1, 432 EXPECT_EQ(0, GetIntAttr(cell1,
426 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX)); 433 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX));
427 EXPECT_EQ(0, GetIntAttr(cell1, 434 EXPECT_EQ(0, GetIntAttr(cell1,
428 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX)); 435 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX));
429 EXPECT_EQ(2, GetIntAttr(cell1, 436 EXPECT_EQ(2, GetIntAttr(cell1,
430 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN)); 437 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN));
431 EXPECT_EQ(1, GetIntAttr(cell1, 438 EXPECT_EQ(1, GetIntAttr(cell1,
432 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN)); 439 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN));
433 EXPECT_EQ(2, GetIntAttr(cell2, 440 EXPECT_EQ(2, GetIntAttr(cell2,
434 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX)); 441 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX));
435 EXPECT_EQ(1, GetIntAttr(cell2, 442 EXPECT_EQ(1, GetIntAttr(cell2,
436 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN)); 443 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN));
437 EXPECT_EQ(0, GetIntAttr(cell3, 444 EXPECT_EQ(0, GetIntAttr(cell3,
438 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX)); 445 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX));
439 EXPECT_EQ(1, GetIntAttr(cell3, 446 EXPECT_EQ(1, GetIntAttr(cell3,
440 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN)); 447 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN));
441 EXPECT_EQ(1, GetIntAttr(cell4, 448 EXPECT_EQ(1, GetIntAttr(cell4,
442 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX)); 449 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX));
443 EXPECT_EQ(2, GetIntAttr(cell4, 450 EXPECT_EQ(2, GetIntAttr(cell4,
444 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN)); 451 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN));
445 } 452 }
446 453
447 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 454 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
448 CrossPlatformWritableElement) { 455 CrossPlatformWritableElement) {
449 const char url_str[] = 456 const char url_str[] =
450 "data:text/html," 457 "data:text/html,"
451 "<!doctype html>" 458 "<!doctype html>"
452 "<div role='textbox' tabindex=0>" 459 "<div role='textbox' tabindex=0>"
453 " Some text" 460 " Some text"
454 "</div>"; 461 "</div>";
455 GURL url(url_str); 462 GURL url(url_str);
456 browser()->OpenURL(OpenURLParams( 463 browser()->OpenURL(OpenURLParams(
457 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 464 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
458 const WebAccessibility& tree = GetWebAccessibilityTree(); 465 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
459 466
460 ASSERT_EQ(1U, tree.children.size()); 467 ASSERT_EQ(1U, tree.children.size());
461 const WebAccessibility& textbox = tree.children[0]; 468 const AccessibilityNodeData& textbox = tree.children[0];
462 469
463 EXPECT_EQ( 470 EXPECT_EQ(
464 true, GetBoolAttr(textbox, WebAccessibility::ATTR_CAN_SET_VALUE)); 471 true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE));
465 } 472 }
466 473
467 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, 474 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest,
468 CrossPlatformEditableTextOnlyMode) { 475 CrossPlatformEditableTextOnlyMode) {
469 const char url_str[] = 476 const char url_str[] =
470 "data:text/html," 477 "data:text/html,"
471 "<!doctype html>" 478 "<!doctype html>"
472 "<h1>Heading</h1>" 479 "<h1>Heading</h1>"
473 "<input type=text value=text0>" 480 "<input type=text value=text0>"
474 "<input disabled type=text value=skip0>" 481 "<input disabled type=text value=skip0>"
475 "<textarea>text1</textarea>" 482 "<textarea>text1</textarea>"
476 "<textarea disabled>skip1</textarea>" 483 "<textarea disabled>skip1</textarea>"
477 "<div role=textbox>text2</div>" 484 "<div role=textbox>text2</div>"
478 "<div contentEditable>text3</div>" 485 "<div contentEditable>text3</div>"
479 "<ul>" 486 "<ul>"
480 " <li><input type=text value=text4>" 487 " <li><input type=text value=text4>"
481 " <li><textarea>text5</textarea>" 488 " <li><textarea>text5</textarea>"
482 " <li><div role=textbox>text6</div>" 489 " <li><div role=textbox>text6</div>"
483 " <li><div contentEditable>text7</div>" 490 " <li><div contentEditable>text7</div>"
484 " <li><button>button</button>" 491 " <li><button>button</button>"
485 "</ul>"; 492 "</ul>";
486 493
487 GURL url(url_str); 494 GURL url(url_str);
488 browser()->OpenURL(OpenURLParams( 495 browser()->OpenURL(OpenURLParams(
489 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 496 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
490 const WebAccessibility& tree = GetWebAccessibilityTree( 497 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(
491 AccessibilityModeEditableTextOnly); 498 AccessibilityModeEditableTextOnly);
492 499
493 const WebAccessibility& text0 = tree.children[0]; 500 const AccessibilityNodeData& text0 = tree.children[0];
494 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text0.role); 501 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text0.role);
495 EXPECT_STREQ("text0", UTF16ToUTF8(text0.value).c_str()); 502 EXPECT_STREQ("text0", UTF16ToUTF8(text0.value).c_str());
496 503
497 const WebAccessibility& text1 = tree.children[1]; 504 const AccessibilityNodeData& text1 = tree.children[1];
498 EXPECT_EQ(WebAccessibility::ROLE_TEXTAREA, text1.role); 505 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXTAREA, text1.role);
499 EXPECT_STREQ("text1", UTF16ToUTF8(text1.value).c_str()); 506 EXPECT_STREQ("text1", UTF16ToUTF8(text1.value).c_str());
500 507
501 const WebAccessibility& text2 = tree.children[2]; 508 const AccessibilityNodeData& text2 = tree.children[2];
502 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text2.role); 509 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text2.role);
503 EXPECT_STREQ("text2", UTF16ToUTF8(text2.value).c_str()); 510 EXPECT_STREQ("text2", UTF16ToUTF8(text2.value).c_str());
504 511
505 const WebAccessibility& text3 = tree.children[3]; 512 const AccessibilityNodeData& text3 = tree.children[3];
506 EXPECT_EQ(WebAccessibility::ROLE_GROUP, text3.role); 513 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, text3.role);
507 514
508 const WebAccessibility& text4 = tree.children[4]; 515 const AccessibilityNodeData& text4 = tree.children[4];
509 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text4.role); 516 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text4.role);
510 EXPECT_STREQ("text4", UTF16ToUTF8(text4.value).c_str()); 517 EXPECT_STREQ("text4", UTF16ToUTF8(text4.value).c_str());
511 518
512 const WebAccessibility& text5 = tree.children[5]; 519 const AccessibilityNodeData& text5 = tree.children[5];
513 EXPECT_EQ(WebAccessibility::ROLE_TEXTAREA, text5.role); 520 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXTAREA, text5.role);
514 EXPECT_STREQ("text5", UTF16ToUTF8(text5.value).c_str()); 521 EXPECT_STREQ("text5", UTF16ToUTF8(text5.value).c_str());
515 522
516 const WebAccessibility& text6 = tree.children[6]; 523 const AccessibilityNodeData& text6 = tree.children[6];
517 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text6.role); 524 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text6.role);
518 EXPECT_STREQ("text6", UTF16ToUTF8(text6.value).c_str()); 525 EXPECT_STREQ("text6", UTF16ToUTF8(text6.value).c_str());
519 526
520 const WebAccessibility& text7 = tree.children[7]; 527 const AccessibilityNodeData& text7 = tree.children[7];
521 EXPECT_EQ(WebAccessibility::ROLE_GROUP, text7.role); 528 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, text7.role);
522 } 529 }
523 530
524 } // namespace 531 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698