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

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

Issue 116293005: Refactor content/ to use ui::AXNodeData instead of blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update content/DEPS instead of subdirs Created 6 years, 11 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 "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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 void BrowserAccessibilityTest::SetUp() { 103 void BrowserAccessibilityTest::SetUp() {
104 ui::win::CreateATLModuleIfNeeded(); 104 ui::win::CreateATLModuleIfNeeded();
105 } 105 }
106 106
107 107
108 // Actual tests --------------------------------------------------------------- 108 // Actual tests ---------------------------------------------------------------
109 109
110 // Test that BrowserAccessibilityManager correctly releases the tree of 110 // Test that BrowserAccessibilityManager correctly releases the tree of
111 // BrowserAccessibility instances upon delete. 111 // BrowserAccessibility instances upon delete.
112 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { 112 TEST_F(BrowserAccessibilityTest, TestNoLeaks) {
113 // Create AccessibilityNodeData objects for a simple document tree, 113 // Create ui::AXNodeData objects for a simple document tree,
114 // representing the accessibility information used to initialize 114 // representing the accessibility information used to initialize
115 // BrowserAccessibilityManager. 115 // BrowserAccessibilityManager.
116 AccessibilityNodeData button; 116 ui::AXNodeData button;
117 button.id = 2; 117 button.id = 2;
118 button.SetName("Button"); 118 button.SetName("Button");
119 button.role = blink::WebAXRoleButton; 119 button.role = ui::AX_ROLE_BUTTON;
120 button.state = 0; 120 button.state = 0;
121 121
122 AccessibilityNodeData checkbox; 122 ui::AXNodeData checkbox;
123 checkbox.id = 3; 123 checkbox.id = 3;
124 checkbox.SetName("Checkbox"); 124 checkbox.SetName("Checkbox");
125 checkbox.role = blink::WebAXRoleCheckBox; 125 checkbox.role = ui::AX_ROLE_CHECK_BOX;
126 checkbox.state = 0; 126 checkbox.state = 0;
127 127
128 AccessibilityNodeData root; 128 ui::AXNodeData root;
129 root.id = 1; 129 root.id = 1;
130 root.SetName("Document"); 130 root.SetName("Document");
131 root.role = blink::WebAXRoleRootWebArea; 131 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
132 root.state = 0; 132 root.state = 0;
133 root.child_ids.push_back(2); 133 root.child_ids.push_back(2);
134 root.child_ids.push_back(3); 134 root.child_ids.push_back(3);
135 135
136 // Construct a BrowserAccessibilityManager with this 136 // Construct a BrowserAccessibilityManager with this
137 // AccessibilityNodeData tree and a factory for an instance-counting 137 // ui::AXNodeData tree and a factory for an instance-counting
138 // BrowserAccessibility, and ensure that exactly 3 instances were 138 // BrowserAccessibility, and ensure that exactly 3 instances were
139 // created. Note that the manager takes ownership of the factory. 139 // created. Note that the manager takes ownership of the factory.
140 CountedBrowserAccessibility::reset(); 140 CountedBrowserAccessibility::reset();
141 scoped_ptr<BrowserAccessibilityManager> manager( 141 scoped_ptr<BrowserAccessibilityManager> manager(
142 BrowserAccessibilityManager::Create( 142 BrowserAccessibilityManager::Create(
143 root, NULL, new CountedBrowserAccessibilityFactory())); 143 root, NULL, new CountedBrowserAccessibilityFactory()));
144 manager->UpdateNodesForTesting(button, checkbox); 144 manager->UpdateNodesForTesting(button, checkbox);
145 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); 145 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances());
146 146
147 // Delete the manager and test that all 3 instances are deleted. 147 // Delete the manager and test that all 3 instances are deleted.
(...skipping 24 matching lines...) Expand all
172 172
173 // Release each of our references and make sure that each one results in 173 // Release each of our references and make sure that each one results in
174 // the instance being deleted as its reference count hits zero. 174 // the instance being deleted as its reference count hits zero.
175 root_iaccessible->Release(); 175 root_iaccessible->Release();
176 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); 176 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances());
177 child1_iaccessible->Release(); 177 child1_iaccessible->Release();
178 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 178 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
179 } 179 }
180 180
181 TEST_F(BrowserAccessibilityTest, TestChildrenChange) { 181 TEST_F(BrowserAccessibilityTest, TestChildrenChange) {
182 // Create AccessibilityNodeData objects for a simple document tree, 182 // Create ui::AXNodeData objects for a simple document tree,
183 // representing the accessibility information used to initialize 183 // representing the accessibility information used to initialize
184 // BrowserAccessibilityManager. 184 // BrowserAccessibilityManager.
185 AccessibilityNodeData text; 185 ui::AXNodeData text;
186 text.id = 2; 186 text.id = 2;
187 text.role = blink::WebAXRoleStaticText; 187 text.role = ui::AX_ROLE_STATIC_TEXT;
188 text.SetName("old text"); 188 text.SetName("old text");
189 text.state = 0; 189 text.state = 0;
190 190
191 AccessibilityNodeData root; 191 ui::AXNodeData root;
192 root.id = 1; 192 root.id = 1;
193 root.SetName("Document"); 193 root.SetName("Document");
194 root.role = blink::WebAXRoleRootWebArea; 194 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
195 root.state = 0; 195 root.state = 0;
196 root.child_ids.push_back(2); 196 root.child_ids.push_back(2);
197 197
198 // Construct a BrowserAccessibilityManager with this 198 // Construct a BrowserAccessibilityManager with this
199 // AccessibilityNodeData tree and a factory for an instance-counting 199 // ui::AXNodeData tree and a factory for an instance-counting
200 // BrowserAccessibility. 200 // BrowserAccessibility.
201 CountedBrowserAccessibility::reset(); 201 CountedBrowserAccessibility::reset();
202 scoped_ptr<BrowserAccessibilityManager> manager( 202 scoped_ptr<BrowserAccessibilityManager> manager(
203 BrowserAccessibilityManager::Create( 203 BrowserAccessibilityManager::Create(
204 root, NULL, new CountedBrowserAccessibilityFactory())); 204 root, NULL, new CountedBrowserAccessibilityFactory()));
205 manager->UpdateNodesForTesting(text); 205 manager->UpdateNodesForTesting(text);
206 206
207 // Query for the text IAccessible and verify that it returns "old text" as its 207 // Query for the text IAccessible and verify that it returns "old text" as its
208 // value. 208 // value.
209 base::win::ScopedVariant one(1); 209 base::win::ScopedVariant one(1);
(...skipping 10 matching lines...) Expand all
220 base::win::ScopedBstr name; 220 base::win::ScopedBstr name;
221 hr = text_accessible->get_accName(childid_self, name.Receive()); 221 hr = text_accessible->get_accName(childid_self, name.Receive());
222 ASSERT_EQ(S_OK, hr); 222 ASSERT_EQ(S_OK, hr);
223 EXPECT_EQ(L"old text", base::string16(name)); 223 EXPECT_EQ(L"old text", base::string16(name));
224 name.Reset(); 224 name.Reset();
225 225
226 text_dispatch.Release(); 226 text_dispatch.Release();
227 text_accessible.Release(); 227 text_accessible.Release();
228 228
229 // Notify the BrowserAccessibilityManager that the text child has changed. 229 // Notify the BrowserAccessibilityManager that the text child has changed.
230 AccessibilityNodeData text2; 230 ui::AXNodeData text2;
231 text2.id = 2; 231 text2.id = 2;
232 text2.role = blink::WebAXRoleStaticText; 232 text2.role = ui::AX_ROLE_STATIC_TEXT;
233 text2.SetName("new text"); 233 text2.SetName("new text");
234 text2.SetName("old text"); 234 text2.SetName("old text");
235 AccessibilityHostMsg_EventParams param; 235 AccessibilityHostMsg_EventParams param;
236 param.event_type = blink::WebAXEventChildrenChanged; 236 param.event_type = ui::AX_EVENT_CHILDREN_CHANGED;
237 param.nodes.push_back(text2); 237 param.nodes.push_back(text2);
238 param.id = text2.id; 238 param.id = text2.id;
239 std::vector<AccessibilityHostMsg_EventParams> events; 239 std::vector<AccessibilityHostMsg_EventParams> events;
240 events.push_back(param); 240 events.push_back(param);
241 manager->OnAccessibilityEvents(events); 241 manager->OnAccessibilityEvents(events);
242 242
243 // Query for the text IAccessible and verify that it now returns "new text" 243 // Query for the text IAccessible and verify that it now returns "new text"
244 // as its value. 244 // as its value.
245 hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( 245 hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild(
246 one, text_dispatch.Receive()); 246 one, text_dispatch.Receive());
247 ASSERT_EQ(S_OK, hr); 247 ASSERT_EQ(S_OK, hr);
248 248
249 hr = text_dispatch.QueryInterface(text_accessible.Receive()); 249 hr = text_dispatch.QueryInterface(text_accessible.Receive());
250 ASSERT_EQ(S_OK, hr); 250 ASSERT_EQ(S_OK, hr);
251 251
252 hr = text_accessible->get_accName(childid_self, name.Receive()); 252 hr = text_accessible->get_accName(childid_self, name.Receive());
253 ASSERT_EQ(S_OK, hr); 253 ASSERT_EQ(S_OK, hr);
254 EXPECT_EQ(L"new text", base::string16(name)); 254 EXPECT_EQ(L"new text", base::string16(name));
255 255
256 text_dispatch.Release(); 256 text_dispatch.Release();
257 text_accessible.Release(); 257 text_accessible.Release();
258 258
259 // Delete the manager and test that all BrowserAccessibility instances are 259 // Delete the manager and test that all BrowserAccessibility instances are
260 // deleted. 260 // deleted.
261 manager.reset(); 261 manager.reset();
262 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 262 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
263 } 263 }
264 264
265 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { 265 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) {
266 // Create AccessibilityNodeData objects for a simple document tree, 266 // Create ui::AXNodeData objects for a simple document tree,
267 // representing the accessibility information used to initialize 267 // representing the accessibility information used to initialize
268 // BrowserAccessibilityManager. 268 // BrowserAccessibilityManager.
269 AccessibilityNodeData div; 269 ui::AXNodeData div;
270 div.id = 2; 270 div.id = 2;
271 div.role = blink::WebAXRoleGroup; 271 div.role = ui::AX_ROLE_GROUP;
272 div.state = 0; 272 div.state = 0;
273 273
274 AccessibilityNodeData text3; 274 ui::AXNodeData text3;
275 text3.id = 3; 275 text3.id = 3;
276 text3.role = blink::WebAXRoleStaticText; 276 text3.role = ui::AX_ROLE_STATIC_TEXT;
277 text3.state = 0; 277 text3.state = 0;
278 278
279 AccessibilityNodeData text4; 279 ui::AXNodeData text4;
280 text4.id = 4; 280 text4.id = 4;
281 text4.role = blink::WebAXRoleStaticText; 281 text4.role = ui::AX_ROLE_STATIC_TEXT;
282 text4.state = 0; 282 text4.state = 0;
283 283
284 div.child_ids.push_back(3); 284 div.child_ids.push_back(3);
285 div.child_ids.push_back(4); 285 div.child_ids.push_back(4);
286 286
287 AccessibilityNodeData root; 287 ui::AXNodeData root;
288 root.id = 1; 288 root.id = 1;
289 root.role = blink::WebAXRoleRootWebArea; 289 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
290 root.state = 0; 290 root.state = 0;
291 root.child_ids.push_back(2); 291 root.child_ids.push_back(2);
292 292
293 // Construct a BrowserAccessibilityManager with this 293 // Construct a BrowserAccessibilityManager with this
294 // AccessibilityNodeData tree and a factory for an instance-counting 294 // ui::AXNodeData tree and a factory for an instance-counting
295 // BrowserAccessibility and ensure that exactly 4 instances were 295 // BrowserAccessibility and ensure that exactly 4 instances were
296 // created. Note that the manager takes ownership of the factory. 296 // created. Note that the manager takes ownership of the factory.
297 CountedBrowserAccessibility::reset(); 297 CountedBrowserAccessibility::reset();
298 scoped_ptr<BrowserAccessibilityManager> manager( 298 scoped_ptr<BrowserAccessibilityManager> manager(
299 BrowserAccessibilityManager::Create( 299 BrowserAccessibilityManager::Create(
300 root, NULL, new CountedBrowserAccessibilityFactory())); 300 root, NULL, new CountedBrowserAccessibilityFactory()));
301 manager->UpdateNodesForTesting(div, text3, text4); 301 manager->UpdateNodesForTesting(div, text3, text4);
302 ASSERT_EQ(4, CountedBrowserAccessibility::num_instances()); 302 ASSERT_EQ(4, CountedBrowserAccessibility::num_instances());
303 303
304 // Notify the BrowserAccessibilityManager that the div node and its children 304 // Notify the BrowserAccessibilityManager that the div node and its children
305 // were removed and ensure that only one BrowserAccessibility instance exists. 305 // were removed and ensure that only one BrowserAccessibility instance exists.
306 root.child_ids.clear(); 306 root.child_ids.clear();
307 AccessibilityHostMsg_EventParams param; 307 AccessibilityHostMsg_EventParams param;
308 param.event_type = blink::WebAXEventChildrenChanged; 308 param.event_type = ui::AX_EVENT_CHILDREN_CHANGED;
309 param.nodes.push_back(root); 309 param.nodes.push_back(root);
310 param.id = root.id; 310 param.id = root.id;
311 std::vector<AccessibilityHostMsg_EventParams> events; 311 std::vector<AccessibilityHostMsg_EventParams> events;
312 events.push_back(param); 312 events.push_back(param);
313 manager->OnAccessibilityEvents(events); 313 manager->OnAccessibilityEvents(events);
314 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); 314 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances());
315 315
316 // Delete the manager and test that all BrowserAccessibility instances are 316 // Delete the manager and test that all BrowserAccessibility instances are
317 // deleted. 317 // deleted.
318 manager.reset(); 318 manager.reset();
319 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 319 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
320 } 320 }
321 321
322 TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { 322 TEST_F(BrowserAccessibilityTest, TestTextBoundaries) {
323 std::string text1_value = "One two three.\nFour five six."; 323 std::string text1_value = "One two three.\nFour five six.";
324 324
325 AccessibilityNodeData text1; 325 ui::AXNodeData text1;
326 text1.id = 11; 326 text1.id = 11;
327 text1.role = blink::WebAXRoleTextField; 327 text1.role = ui::AX_ROLE_TEXT_FIELD;
328 text1.state = 0; 328 text1.state = 0;
329 text1.AddStringAttribute(AccessibilityNodeData::ATTR_VALUE, text1_value); 329 text1.AddStringAttribute(ui::AX_ATTR_VALUE, text1_value);
330 std::vector<int32> line_breaks; 330 std::vector<int32> line_breaks;
331 line_breaks.push_back(15); 331 line_breaks.push_back(15);
332 text1.AddIntListAttribute( 332 text1.AddIntListAttribute(
333 AccessibilityNodeData::ATTR_LINE_BREAKS, line_breaks); 333 ui::AX_ATTR_LINE_BREAKS, line_breaks);
334 334
335 AccessibilityNodeData root; 335 ui::AXNodeData root;
336 root.id = 1; 336 root.id = 1;
337 root.role = blink::WebAXRoleRootWebArea; 337 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
338 root.state = 0; 338 root.state = 0;
339 root.child_ids.push_back(11); 339 root.child_ids.push_back(11);
340 340
341 CountedBrowserAccessibility::reset(); 341 CountedBrowserAccessibility::reset();
342 scoped_ptr<BrowserAccessibilityManager> manager( 342 scoped_ptr<BrowserAccessibilityManager> manager(
343 BrowserAccessibilityManager::Create( 343 BrowserAccessibilityManager::Create(
344 root, NULL, new CountedBrowserAccessibilityFactory())); 344 root, NULL, new CountedBrowserAccessibilityFactory()));
345 manager->UpdateNodesForTesting(text1); 345 manager->UpdateNodesForTesting(text1);
346 ASSERT_EQ(2, CountedBrowserAccessibility::num_instances()); 346 ASSERT_EQ(2, CountedBrowserAccessibility::num_instances());
347 347
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // Delete the manager and test that all BrowserAccessibility instances are 412 // Delete the manager and test that all BrowserAccessibility instances are
413 // deleted. 413 // deleted.
414 manager.reset(); 414 manager.reset();
415 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 415 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
416 } 416 }
417 417
418 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { 418 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) {
419 const std::string text1_name = "One two three."; 419 const std::string text1_name = "One two three.";
420 const std::string text2_name = " Four five six."; 420 const std::string text2_name = " Four five six.";
421 421
422 AccessibilityNodeData text1; 422 ui::AXNodeData text1;
423 text1.id = 11; 423 text1.id = 11;
424 text1.role = blink::WebAXRoleStaticText; 424 text1.role = ui::AX_ROLE_STATIC_TEXT;
425 text1.state = 1 << blink::WebAXStateReadonly; 425 text1.state = 1 << ui::AX_STATE_READONLY;
426 text1.SetName(text1_name); 426 text1.SetName(text1_name);
427 427
428 AccessibilityNodeData text2; 428 ui::AXNodeData text2;
429 text2.id = 12; 429 text2.id = 12;
430 text2.role = blink::WebAXRoleStaticText; 430 text2.role = ui::AX_ROLE_STATIC_TEXT;
431 text2.state = 1 << blink::WebAXStateReadonly; 431 text2.state = 1 << ui::AX_STATE_READONLY;
432 text2.SetName(text2_name); 432 text2.SetName(text2_name);
433 433
434 AccessibilityNodeData root; 434 ui::AXNodeData root;
435 root.id = 1; 435 root.id = 1;
436 root.role = blink::WebAXRoleRootWebArea; 436 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
437 root.state = 1 << blink::WebAXStateReadonly; 437 root.state = 1 << ui::AX_STATE_READONLY;
438 root.child_ids.push_back(11); 438 root.child_ids.push_back(11);
439 root.child_ids.push_back(12); 439 root.child_ids.push_back(12);
440 440
441 CountedBrowserAccessibility::reset(); 441 CountedBrowserAccessibility::reset();
442 scoped_ptr<BrowserAccessibilityManager> manager( 442 scoped_ptr<BrowserAccessibilityManager> manager(
443 BrowserAccessibilityManager::Create( 443 BrowserAccessibilityManager::Create(
444 root, NULL, new CountedBrowserAccessibilityFactory())); 444 root, NULL, new CountedBrowserAccessibilityFactory()));
445 manager->UpdateNodesForTesting(root, text1, text2); 445 manager->UpdateNodesForTesting(root, text1, text2);
446 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); 446 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances());
447 447
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 manager.reset(); 480 manager.reset();
481 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 481 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
482 } 482 }
483 483
484 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { 484 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
485 const std::string text1_name = "One two three."; 485 const std::string text1_name = "One two three.";
486 const std::string text2_name = " Four five six."; 486 const std::string text2_name = " Four five six.";
487 const std::string button1_text_name = "red"; 487 const std::string button1_text_name = "red";
488 const std::string link1_text_name = "blue"; 488 const std::string link1_text_name = "blue";
489 489
490 AccessibilityNodeData text1; 490 ui::AXNodeData text1;
491 text1.id = 11; 491 text1.id = 11;
492 text1.role = blink::WebAXRoleStaticText; 492 text1.role = ui::AX_ROLE_STATIC_TEXT;
493 text1.state = 1 << blink::WebAXStateReadonly; 493 text1.state = 1 << ui::AX_STATE_READONLY;
494 text1.SetName(text1_name); 494 text1.SetName(text1_name);
495 495
496 AccessibilityNodeData text2; 496 ui::AXNodeData text2;
497 text2.id = 12; 497 text2.id = 12;
498 text2.role = blink::WebAXRoleStaticText; 498 text2.role = ui::AX_ROLE_STATIC_TEXT;
499 text2.state = 1 << blink::WebAXStateReadonly; 499 text2.state = 1 << ui::AX_STATE_READONLY;
500 text2.SetName(text2_name); 500 text2.SetName(text2_name);
501 501
502 AccessibilityNodeData button1, button1_text; 502 ui::AXNodeData button1, button1_text;
503 button1.id = 13; 503 button1.id = 13;
504 button1_text.id = 15; 504 button1_text.id = 15;
505 button1_text.SetName(button1_text_name); 505 button1_text.SetName(button1_text_name);
506 button1.role = blink::WebAXRoleButton; 506 button1.role = ui::AX_ROLE_BUTTON;
507 button1_text.role = blink::WebAXRoleStaticText; 507 button1_text.role = ui::AX_ROLE_STATIC_TEXT;
508 button1.state = 1 << blink::WebAXStateReadonly; 508 button1.state = 1 << ui::AX_STATE_READONLY;
509 button1_text.state = 1 << blink::WebAXStateReadonly; 509 button1_text.state = 1 << ui::AX_STATE_READONLY;
510 button1.child_ids.push_back(15); 510 button1.child_ids.push_back(15);
511 511
512 AccessibilityNodeData link1, link1_text; 512 ui::AXNodeData link1, link1_text;
513 link1.id = 14; 513 link1.id = 14;
514 link1_text.id = 16; 514 link1_text.id = 16;
515 link1_text.SetName(link1_text_name); 515 link1_text.SetName(link1_text_name);
516 link1.role = blink::WebAXRoleLink; 516 link1.role = ui::AX_ROLE_LINK;
517 link1_text.role = blink::WebAXRoleStaticText; 517 link1_text.role = ui::AX_ROLE_STATIC_TEXT;
518 link1.state = 1 << blink::WebAXStateReadonly; 518 link1.state = 1 << ui::AX_STATE_READONLY;
519 link1_text.state = 1 << blink::WebAXStateReadonly; 519 link1_text.state = 1 << ui::AX_STATE_READONLY;
520 link1.child_ids.push_back(16); 520 link1.child_ids.push_back(16);
521 521
522 AccessibilityNodeData root; 522 ui::AXNodeData root;
523 root.id = 1; 523 root.id = 1;
524 root.role = blink::WebAXRoleRootWebArea; 524 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
525 root.state = 1 << blink::WebAXStateReadonly; 525 root.state = 1 << ui::AX_STATE_READONLY;
526 root.child_ids.push_back(11); 526 root.child_ids.push_back(11);
527 root.child_ids.push_back(13); 527 root.child_ids.push_back(13);
528 root.child_ids.push_back(12); 528 root.child_ids.push_back(12);
529 root.child_ids.push_back(14); 529 root.child_ids.push_back(14);
530 530
531 CountedBrowserAccessibility::reset(); 531 CountedBrowserAccessibility::reset();
532 scoped_ptr<BrowserAccessibilityManager> manager( 532 scoped_ptr<BrowserAccessibilityManager> manager(
533 BrowserAccessibilityManager::Create( 533 BrowserAccessibilityManager::Create(
534 root, NULL, new CountedBrowserAccessibilityFactory())); 534 root, NULL, new CountedBrowserAccessibilityFactory()));
535 manager->UpdateNodesForTesting(root, 535 manager->UpdateNodesForTesting(root,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // Delete the manager and test that all BrowserAccessibility instances are 595 // Delete the manager and test that all BrowserAccessibility instances are
596 // deleted. 596 // deleted.
597 manager.reset(); 597 manager.reset();
598 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 598 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
599 } 599 }
600 600
601 TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { 601 TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) {
602 // Try creating an empty document with busy state. Readonly is 602 // Try creating an empty document with busy state. Readonly is
603 // set automatically. 603 // set automatically.
604 CountedBrowserAccessibility::reset(); 604 CountedBrowserAccessibility::reset();
605 const int32 busy_state = 1 << blink::WebAXStateBusy; 605 const int32 busy_state = 1 << ui::AX_STATE_BUSY;
606 const int32 readonly_state = 1 << blink::WebAXStateReadonly; 606 const int32 readonly_state = 1 << ui::AX_STATE_READONLY;
607 const int32 enabled_state = 1 << blink::WebAXStateEnabled; 607 const int32 enabled_state = 1 << blink::WebAXStateEnabled;
608 scoped_ptr<BrowserAccessibilityManager> manager( 608 scoped_ptr<BrowserAccessibilityManager> manager(
609 new BrowserAccessibilityManagerWin( 609 new BrowserAccessibilityManagerWin(
610 GetDesktopWindow(), 610 GetDesktopWindow(),
611 NULL, 611 NULL,
612 BrowserAccessibilityManagerWin::GetEmptyDocument(), 612 BrowserAccessibilityManagerWin::GetEmptyDocument(),
613 NULL, 613 NULL,
614 new CountedBrowserAccessibilityFactory())); 614 new CountedBrowserAccessibilityFactory()));
615 615
616 // Verify the root is as we expect by default. 616 // Verify the root is as we expect by default.
617 BrowserAccessibility* root = manager->GetRoot(); 617 BrowserAccessibility* root = manager->GetRoot();
618 EXPECT_EQ(0, root->renderer_id()); 618 EXPECT_EQ(0, root->renderer_id());
619 EXPECT_EQ(blink::WebAXRoleRootWebArea, root->role()); 619 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->role());
620 EXPECT_EQ(busy_state | readonly_state | enabled_state, root->state()); 620 EXPECT_EQ(busy_state | readonly_state | enabled_state, root->state());
621 621
622 // Tree with a child textfield. 622 // Tree with a child textfield.
623 AccessibilityNodeData tree1_1; 623 ui::AXNodeData tree1_1;
624 tree1_1.id = 1; 624 tree1_1.id = 1;
625 tree1_1.role = blink::WebAXRoleRootWebArea; 625 tree1_1.role = ui::AX_ROLE_ROOT_WEB_AREA;
626 tree1_1.child_ids.push_back(2); 626 tree1_1.child_ids.push_back(2);
627 627
628 AccessibilityNodeData tree1_2; 628 ui::AXNodeData tree1_2;
629 tree1_2.id = 2; 629 tree1_2.id = 2;
630 tree1_2.role = blink::WebAXRoleTextField; 630 tree1_2.role = ui::AX_ROLE_TEXT_FIELD;
631 631
632 // Process a load complete. 632 // Process a load complete.
633 std::vector<AccessibilityHostMsg_EventParams> params; 633 std::vector<AccessibilityHostMsg_EventParams> params;
634 params.push_back(AccessibilityHostMsg_EventParams()); 634 params.push_back(AccessibilityHostMsg_EventParams());
635 AccessibilityHostMsg_EventParams* msg = &params[0]; 635 AccessibilityHostMsg_EventParams* msg = &params[0];
636 msg->event_type = blink::WebAXEventLoadComplete; 636 msg->event_type = ui::AX_EVENT_LOAD_COMPLETE;
637 msg->nodes.push_back(tree1_1); 637 msg->nodes.push_back(tree1_1);
638 msg->nodes.push_back(tree1_2); 638 msg->nodes.push_back(tree1_2);
639 msg->id = tree1_1.id; 639 msg->id = tree1_1.id;
640 manager->OnAccessibilityEvents(params); 640 manager->OnAccessibilityEvents(params);
641 641
642 // Save for later comparison. 642 // Save for later comparison.
643 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(2); 643 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(2);
644 644
645 // Verify the root has changed. 645 // Verify the root has changed.
646 EXPECT_NE(root, manager->GetRoot()); 646 EXPECT_NE(root, manager->GetRoot());
647 647
648 // And the proper child remains. 648 // And the proper child remains.
649 EXPECT_EQ(blink::WebAXRoleTextField, acc1_2->role()); 649 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, acc1_2->role());
650 EXPECT_EQ(2, acc1_2->renderer_id()); 650 EXPECT_EQ(2, acc1_2->renderer_id());
651 651
652 // Tree with a child button. 652 // Tree with a child button.
653 AccessibilityNodeData tree2_1; 653 ui::AXNodeData tree2_1;
654 tree2_1.id = 1; 654 tree2_1.id = 1;
655 tree2_1.role = blink::WebAXRoleRootWebArea; 655 tree2_1.role = ui::AX_ROLE_ROOT_WEB_AREA;
656 tree2_1.child_ids.push_back(3); 656 tree2_1.child_ids.push_back(3);
657 657
658 AccessibilityNodeData tree2_2; 658 ui::AXNodeData tree2_2;
659 tree2_2.id = 3; 659 tree2_2.id = 3;
660 tree2_2.role = blink::WebAXRoleButton; 660 tree2_2.role = ui::AX_ROLE_BUTTON;
661 661
662 msg->nodes.clear(); 662 msg->nodes.clear();
663 msg->nodes.push_back(tree2_1); 663 msg->nodes.push_back(tree2_1);
664 msg->nodes.push_back(tree2_2); 664 msg->nodes.push_back(tree2_2);
665 msg->id = tree2_1.id; 665 msg->id = tree2_1.id;
666 666
667 // Fire another load complete. 667 // Fire another load complete.
668 manager->OnAccessibilityEvents(params); 668 manager->OnAccessibilityEvents(params);
669 669
670 BrowserAccessibility* acc2_2 = manager->GetFromRendererID(3); 670 BrowserAccessibility* acc2_2 = manager->GetFromRendererID(3);
671 671
672 // Verify the root has changed. 672 // Verify the root has changed.
673 EXPECT_NE(root, manager->GetRoot()); 673 EXPECT_NE(root, manager->GetRoot());
674 674
675 // And the new child exists. 675 // And the new child exists.
676 EXPECT_EQ(blink::WebAXRoleButton, acc2_2->role()); 676 EXPECT_EQ(ui::AX_ROLE_BUTTON, acc2_2->role());
677 EXPECT_EQ(3, acc2_2->renderer_id()); 677 EXPECT_EQ(3, acc2_2->renderer_id());
678 678
679 // Ensure we properly cleaned up. 679 // Ensure we properly cleaned up.
680 manager.reset(); 680 manager.reset();
681 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 681 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
682 } 682 }
683 683
684 #if defined(USE_AURA) 684 #if defined(USE_AURA)
685 TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) { 685 TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) {
686 HWND desktop_hwnd = GetDesktopWindow(); 686 HWND desktop_hwnd = GetDesktopWindow();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 new_parent_hwnd = manager->parent_hwnd(); 725 new_parent_hwnd = manager->parent_hwnd();
726 ASSERT_FALSE(NULL == new_parent_hwnd); 726 ASSERT_FALSE(NULL == new_parent_hwnd);
727 727
728 // This time, destroy the manager first, make sure the AccessibleHWND doesn't 728 // This time, destroy the manager first, make sure the AccessibleHWND doesn't
729 // crash on destruction (to be caught by SyzyASAN or other tools). 729 // crash on destruction (to be caught by SyzyASAN or other tools).
730 manager.reset(NULL); 730 manager.reset(NULL);
731 } 731 }
732 #endif 732 #endif
733 733
734 } // namespace content 734 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698