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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // Test that BrowserAccessibilityManager correctly releases the tree of | 109 // Test that BrowserAccessibilityManager correctly releases the tree of |
110 // BrowserAccessibility instances upon delete. | 110 // BrowserAccessibility instances upon delete. |
111 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { | 111 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { |
112 // Create AccessibilityNodeData objects for a simple document tree, | 112 // Create AccessibilityNodeData objects for a simple document tree, |
113 // representing the accessibility information used to initialize | 113 // representing the accessibility information used to initialize |
114 // BrowserAccessibilityManager. | 114 // BrowserAccessibilityManager. |
115 AccessibilityNodeData button; | 115 AccessibilityNodeData button; |
116 button.id = 2; | 116 button.id = 2; |
117 button.SetName("Button"); | 117 button.SetName("Button"); |
118 button.role = WebKit::WebAXRoleButton; | 118 button.role = blink::WebAXRoleButton; |
119 button.state = 0; | 119 button.state = 0; |
120 | 120 |
121 AccessibilityNodeData checkbox; | 121 AccessibilityNodeData checkbox; |
122 checkbox.id = 3; | 122 checkbox.id = 3; |
123 checkbox.SetName("Checkbox"); | 123 checkbox.SetName("Checkbox"); |
124 checkbox.role = WebKit::WebAXRoleCheckBox; | 124 checkbox.role = blink::WebAXRoleCheckBox; |
125 checkbox.state = 0; | 125 checkbox.state = 0; |
126 | 126 |
127 AccessibilityNodeData root; | 127 AccessibilityNodeData root; |
128 root.id = 1; | 128 root.id = 1; |
129 root.SetName("Document"); | 129 root.SetName("Document"); |
130 root.role = WebKit::WebAXRoleRootWebArea; | 130 root.role = blink::WebAXRoleRootWebArea; |
131 root.state = 0; | 131 root.state = 0; |
132 root.child_ids.push_back(2); | 132 root.child_ids.push_back(2); |
133 root.child_ids.push_back(3); | 133 root.child_ids.push_back(3); |
134 | 134 |
135 // Construct a BrowserAccessibilityManager with this | 135 // Construct a BrowserAccessibilityManager with this |
136 // AccessibilityNodeData tree and a factory for an instance-counting | 136 // AccessibilityNodeData tree and a factory for an instance-counting |
137 // BrowserAccessibility, and ensure that exactly 3 instances were | 137 // BrowserAccessibility, and ensure that exactly 3 instances were |
138 // created. Note that the manager takes ownership of the factory. | 138 // created. Note that the manager takes ownership of the factory. |
139 CountedBrowserAccessibility::reset(); | 139 CountedBrowserAccessibility::reset(); |
140 scoped_ptr<BrowserAccessibilityManager> manager( | 140 scoped_ptr<BrowserAccessibilityManager> manager( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 child1_iaccessible->Release(); | 176 child1_iaccessible->Release(); |
177 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 177 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
178 } | 178 } |
179 | 179 |
180 TEST_F(BrowserAccessibilityTest, TestChildrenChange) { | 180 TEST_F(BrowserAccessibilityTest, TestChildrenChange) { |
181 // Create AccessibilityNodeData objects for a simple document tree, | 181 // Create AccessibilityNodeData objects for a simple document tree, |
182 // representing the accessibility information used to initialize | 182 // representing the accessibility information used to initialize |
183 // BrowserAccessibilityManager. | 183 // BrowserAccessibilityManager. |
184 AccessibilityNodeData text; | 184 AccessibilityNodeData text; |
185 text.id = 2; | 185 text.id = 2; |
186 text.role = WebKit::WebAXRoleStaticText; | 186 text.role = blink::WebAXRoleStaticText; |
187 text.SetName("old text"); | 187 text.SetName("old text"); |
188 text.state = 0; | 188 text.state = 0; |
189 | 189 |
190 AccessibilityNodeData root; | 190 AccessibilityNodeData root; |
191 root.id = 1; | 191 root.id = 1; |
192 root.SetName("Document"); | 192 root.SetName("Document"); |
193 root.role = WebKit::WebAXRoleRootWebArea; | 193 root.role = blink::WebAXRoleRootWebArea; |
194 root.state = 0; | 194 root.state = 0; |
195 root.child_ids.push_back(2); | 195 root.child_ids.push_back(2); |
196 | 196 |
197 // Construct a BrowserAccessibilityManager with this | 197 // Construct a BrowserAccessibilityManager with this |
198 // AccessibilityNodeData tree and a factory for an instance-counting | 198 // AccessibilityNodeData tree and a factory for an instance-counting |
199 // BrowserAccessibility. | 199 // BrowserAccessibility. |
200 CountedBrowserAccessibility::reset(); | 200 CountedBrowserAccessibility::reset(); |
201 scoped_ptr<BrowserAccessibilityManager> manager( | 201 scoped_ptr<BrowserAccessibilityManager> manager( |
202 BrowserAccessibilityManager::Create( | 202 BrowserAccessibilityManager::Create( |
203 root, NULL, new CountedBrowserAccessibilityFactory())); | 203 root, NULL, new CountedBrowserAccessibilityFactory())); |
(...skipping 17 matching lines...) Expand all Loading... |
221 ASSERT_EQ(S_OK, hr); | 221 ASSERT_EQ(S_OK, hr); |
222 EXPECT_EQ(L"old text", string16(name)); | 222 EXPECT_EQ(L"old text", string16(name)); |
223 name.Reset(); | 223 name.Reset(); |
224 | 224 |
225 text_dispatch.Release(); | 225 text_dispatch.Release(); |
226 text_accessible.Release(); | 226 text_accessible.Release(); |
227 | 227 |
228 // Notify the BrowserAccessibilityManager that the text child has changed. | 228 // Notify the BrowserAccessibilityManager that the text child has changed. |
229 AccessibilityNodeData text2; | 229 AccessibilityNodeData text2; |
230 text2.id = 2; | 230 text2.id = 2; |
231 text2.role = WebKit::WebAXRoleStaticText; | 231 text2.role = blink::WebAXRoleStaticText; |
232 text2.SetName("new text"); | 232 text2.SetName("new text"); |
233 text2.SetName("old text"); | 233 text2.SetName("old text"); |
234 AccessibilityHostMsg_EventParams param; | 234 AccessibilityHostMsg_EventParams param; |
235 param.event_type = WebKit::WebAXEventChildrenChanged; | 235 param.event_type = blink::WebAXEventChildrenChanged; |
236 param.nodes.push_back(text2); | 236 param.nodes.push_back(text2); |
237 param.id = text2.id; | 237 param.id = text2.id; |
238 std::vector<AccessibilityHostMsg_EventParams> events; | 238 std::vector<AccessibilityHostMsg_EventParams> events; |
239 events.push_back(param); | 239 events.push_back(param); |
240 manager->OnAccessibilityEvents(events); | 240 manager->OnAccessibilityEvents(events); |
241 | 241 |
242 // Query for the text IAccessible and verify that it now returns "new text" | 242 // Query for the text IAccessible and verify that it now returns "new text" |
243 // as its value. | 243 // as its value. |
244 hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( | 244 hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( |
245 one, text_dispatch.Receive()); | 245 one, text_dispatch.Receive()); |
(...skipping 14 matching lines...) Expand all Loading... |
260 manager.reset(); | 260 manager.reset(); |
261 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 261 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
262 } | 262 } |
263 | 263 |
264 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { | 264 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { |
265 // Create AccessibilityNodeData objects for a simple document tree, | 265 // Create AccessibilityNodeData objects for a simple document tree, |
266 // representing the accessibility information used to initialize | 266 // representing the accessibility information used to initialize |
267 // BrowserAccessibilityManager. | 267 // BrowserAccessibilityManager. |
268 AccessibilityNodeData div; | 268 AccessibilityNodeData div; |
269 div.id = 2; | 269 div.id = 2; |
270 div.role = WebKit::WebAXRoleGroup; | 270 div.role = blink::WebAXRoleGroup; |
271 div.state = 0; | 271 div.state = 0; |
272 | 272 |
273 AccessibilityNodeData text3; | 273 AccessibilityNodeData text3; |
274 text3.id = 3; | 274 text3.id = 3; |
275 text3.role = WebKit::WebAXRoleStaticText; | 275 text3.role = blink::WebAXRoleStaticText; |
276 text3.state = 0; | 276 text3.state = 0; |
277 | 277 |
278 AccessibilityNodeData text4; | 278 AccessibilityNodeData text4; |
279 text4.id = 4; | 279 text4.id = 4; |
280 text4.role = WebKit::WebAXRoleStaticText; | 280 text4.role = blink::WebAXRoleStaticText; |
281 text4.state = 0; | 281 text4.state = 0; |
282 | 282 |
283 div.child_ids.push_back(3); | 283 div.child_ids.push_back(3); |
284 div.child_ids.push_back(4); | 284 div.child_ids.push_back(4); |
285 | 285 |
286 AccessibilityNodeData root; | 286 AccessibilityNodeData root; |
287 root.id = 1; | 287 root.id = 1; |
288 root.role = WebKit::WebAXRoleRootWebArea; | 288 root.role = blink::WebAXRoleRootWebArea; |
289 root.state = 0; | 289 root.state = 0; |
290 root.child_ids.push_back(2); | 290 root.child_ids.push_back(2); |
291 | 291 |
292 // Construct a BrowserAccessibilityManager with this | 292 // Construct a BrowserAccessibilityManager with this |
293 // AccessibilityNodeData tree and a factory for an instance-counting | 293 // AccessibilityNodeData tree and a factory for an instance-counting |
294 // BrowserAccessibility and ensure that exactly 4 instances were | 294 // BrowserAccessibility and ensure that exactly 4 instances were |
295 // created. Note that the manager takes ownership of the factory. | 295 // created. Note that the manager takes ownership of the factory. |
296 CountedBrowserAccessibility::reset(); | 296 CountedBrowserAccessibility::reset(); |
297 scoped_ptr<BrowserAccessibilityManager> manager( | 297 scoped_ptr<BrowserAccessibilityManager> manager( |
298 BrowserAccessibilityManager::Create( | 298 BrowserAccessibilityManager::Create( |
299 root, NULL, new CountedBrowserAccessibilityFactory())); | 299 root, NULL, new CountedBrowserAccessibilityFactory())); |
300 manager->UpdateNodesForTesting(div, text3, text4); | 300 manager->UpdateNodesForTesting(div, text3, text4); |
301 ASSERT_EQ(4, CountedBrowserAccessibility::num_instances()); | 301 ASSERT_EQ(4, CountedBrowserAccessibility::num_instances()); |
302 | 302 |
303 // Notify the BrowserAccessibilityManager that the div node and its children | 303 // Notify the BrowserAccessibilityManager that the div node and its children |
304 // were removed and ensure that only one BrowserAccessibility instance exists. | 304 // were removed and ensure that only one BrowserAccessibility instance exists. |
305 root.child_ids.clear(); | 305 root.child_ids.clear(); |
306 AccessibilityHostMsg_EventParams param; | 306 AccessibilityHostMsg_EventParams param; |
307 param.event_type = WebKit::WebAXEventChildrenChanged; | 307 param.event_type = blink::WebAXEventChildrenChanged; |
308 param.nodes.push_back(root); | 308 param.nodes.push_back(root); |
309 param.id = root.id; | 309 param.id = root.id; |
310 std::vector<AccessibilityHostMsg_EventParams> events; | 310 std::vector<AccessibilityHostMsg_EventParams> events; |
311 events.push_back(param); | 311 events.push_back(param); |
312 manager->OnAccessibilityEvents(events); | 312 manager->OnAccessibilityEvents(events); |
313 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); | 313 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); |
314 | 314 |
315 // Delete the manager and test that all BrowserAccessibility instances are | 315 // Delete the manager and test that all BrowserAccessibility instances are |
316 // deleted. | 316 // deleted. |
317 manager.reset(); | 317 manager.reset(); |
318 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 318 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
319 } | 319 } |
320 | 320 |
321 TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { | 321 TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { |
322 std::string text1_value = "One two three.\nFour five six."; | 322 std::string text1_value = "One two three.\nFour five six."; |
323 | 323 |
324 AccessibilityNodeData text1; | 324 AccessibilityNodeData text1; |
325 text1.id = 11; | 325 text1.id = 11; |
326 text1.role = WebKit::WebAXRoleTextField; | 326 text1.role = blink::WebAXRoleTextField; |
327 text1.state = 0; | 327 text1.state = 0; |
328 text1.AddStringAttribute(AccessibilityNodeData::ATTR_VALUE, text1_value); | 328 text1.AddStringAttribute(AccessibilityNodeData::ATTR_VALUE, text1_value); |
329 std::vector<int32> line_breaks; | 329 std::vector<int32> line_breaks; |
330 line_breaks.push_back(15); | 330 line_breaks.push_back(15); |
331 text1.AddIntListAttribute( | 331 text1.AddIntListAttribute( |
332 AccessibilityNodeData::ATTR_LINE_BREAKS, line_breaks); | 332 AccessibilityNodeData::ATTR_LINE_BREAKS, line_breaks); |
333 | 333 |
334 AccessibilityNodeData root; | 334 AccessibilityNodeData root; |
335 root.id = 1; | 335 root.id = 1; |
336 root.role = WebKit::WebAXRoleRootWebArea; | 336 root.role = blink::WebAXRoleRootWebArea; |
337 root.state = 0; | 337 root.state = 0; |
338 root.child_ids.push_back(11); | 338 root.child_ids.push_back(11); |
339 | 339 |
340 CountedBrowserAccessibility::reset(); | 340 CountedBrowserAccessibility::reset(); |
341 scoped_ptr<BrowserAccessibilityManager> manager( | 341 scoped_ptr<BrowserAccessibilityManager> manager( |
342 BrowserAccessibilityManager::Create( | 342 BrowserAccessibilityManager::Create( |
343 root, NULL, new CountedBrowserAccessibilityFactory())); | 343 root, NULL, new CountedBrowserAccessibilityFactory())); |
344 manager->UpdateNodesForTesting(text1); | 344 manager->UpdateNodesForTesting(text1); |
345 ASSERT_EQ(2, CountedBrowserAccessibility::num_instances()); | 345 ASSERT_EQ(2, CountedBrowserAccessibility::num_instances()); |
346 | 346 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 manager.reset(); | 413 manager.reset(); |
414 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 414 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
415 } | 415 } |
416 | 416 |
417 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { | 417 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { |
418 const std::string text1_name = "One two three."; | 418 const std::string text1_name = "One two three."; |
419 const std::string text2_name = " Four five six."; | 419 const std::string text2_name = " Four five six."; |
420 | 420 |
421 AccessibilityNodeData text1; | 421 AccessibilityNodeData text1; |
422 text1.id = 11; | 422 text1.id = 11; |
423 text1.role = WebKit::WebAXRoleStaticText; | 423 text1.role = blink::WebAXRoleStaticText; |
424 text1.state = 1 << WebKit::WebAXStateReadonly; | 424 text1.state = 1 << blink::WebAXStateReadonly; |
425 text1.SetName(text1_name); | 425 text1.SetName(text1_name); |
426 | 426 |
427 AccessibilityNodeData text2; | 427 AccessibilityNodeData text2; |
428 text2.id = 12; | 428 text2.id = 12; |
429 text2.role = WebKit::WebAXRoleStaticText; | 429 text2.role = blink::WebAXRoleStaticText; |
430 text2.state = 1 << WebKit::WebAXStateReadonly; | 430 text2.state = 1 << blink::WebAXStateReadonly; |
431 text2.SetName(text2_name); | 431 text2.SetName(text2_name); |
432 | 432 |
433 AccessibilityNodeData root; | 433 AccessibilityNodeData root; |
434 root.id = 1; | 434 root.id = 1; |
435 root.role = WebKit::WebAXRoleRootWebArea; | 435 root.role = blink::WebAXRoleRootWebArea; |
436 root.state = 1 << WebKit::WebAXStateReadonly; | 436 root.state = 1 << blink::WebAXStateReadonly; |
437 root.child_ids.push_back(11); | 437 root.child_ids.push_back(11); |
438 root.child_ids.push_back(12); | 438 root.child_ids.push_back(12); |
439 | 439 |
440 CountedBrowserAccessibility::reset(); | 440 CountedBrowserAccessibility::reset(); |
441 scoped_ptr<BrowserAccessibilityManager> manager( | 441 scoped_ptr<BrowserAccessibilityManager> manager( |
442 BrowserAccessibilityManager::Create( | 442 BrowserAccessibilityManager::Create( |
443 root, NULL, new CountedBrowserAccessibilityFactory())); | 443 root, NULL, new CountedBrowserAccessibilityFactory())); |
444 manager->UpdateNodesForTesting(root, text1, text2); | 444 manager->UpdateNodesForTesting(root, text1, text2); |
445 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); | 445 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
446 | 446 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 } | 481 } |
482 | 482 |
483 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { | 483 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { |
484 const std::string text1_name = "One two three."; | 484 const std::string text1_name = "One two three."; |
485 const std::string text2_name = " Four five six."; | 485 const std::string text2_name = " Four five six."; |
486 const std::string button1_text_name = "red"; | 486 const std::string button1_text_name = "red"; |
487 const std::string link1_text_name = "blue"; | 487 const std::string link1_text_name = "blue"; |
488 | 488 |
489 AccessibilityNodeData text1; | 489 AccessibilityNodeData text1; |
490 text1.id = 11; | 490 text1.id = 11; |
491 text1.role = WebKit::WebAXRoleStaticText; | 491 text1.role = blink::WebAXRoleStaticText; |
492 text1.state = 1 << WebKit::WebAXStateReadonly; | 492 text1.state = 1 << blink::WebAXStateReadonly; |
493 text1.SetName(text1_name); | 493 text1.SetName(text1_name); |
494 | 494 |
495 AccessibilityNodeData text2; | 495 AccessibilityNodeData text2; |
496 text2.id = 12; | 496 text2.id = 12; |
497 text2.role = WebKit::WebAXRoleStaticText; | 497 text2.role = blink::WebAXRoleStaticText; |
498 text2.state = 1 << WebKit::WebAXStateReadonly; | 498 text2.state = 1 << blink::WebAXStateReadonly; |
499 text2.SetName(text2_name); | 499 text2.SetName(text2_name); |
500 | 500 |
501 AccessibilityNodeData button1, button1_text; | 501 AccessibilityNodeData button1, button1_text; |
502 button1.id = 13; | 502 button1.id = 13; |
503 button1_text.id = 15; | 503 button1_text.id = 15; |
504 button1_text.SetName(button1_text_name); | 504 button1_text.SetName(button1_text_name); |
505 button1.role = WebKit::WebAXRoleButton; | 505 button1.role = blink::WebAXRoleButton; |
506 button1_text.role = WebKit::WebAXRoleStaticText; | 506 button1_text.role = blink::WebAXRoleStaticText; |
507 button1.state = 1 << WebKit::WebAXStateReadonly; | 507 button1.state = 1 << blink::WebAXStateReadonly; |
508 button1_text.state = 1 << WebKit::WebAXStateReadonly; | 508 button1_text.state = 1 << blink::WebAXStateReadonly; |
509 button1.child_ids.push_back(15); | 509 button1.child_ids.push_back(15); |
510 | 510 |
511 AccessibilityNodeData link1, link1_text; | 511 AccessibilityNodeData link1, link1_text; |
512 link1.id = 14; | 512 link1.id = 14; |
513 link1_text.id = 16; | 513 link1_text.id = 16; |
514 link1_text.SetName(link1_text_name); | 514 link1_text.SetName(link1_text_name); |
515 link1.role = WebKit::WebAXRoleLink; | 515 link1.role = blink::WebAXRoleLink; |
516 link1_text.role = WebKit::WebAXRoleStaticText; | 516 link1_text.role = blink::WebAXRoleStaticText; |
517 link1.state = 1 << WebKit::WebAXStateReadonly; | 517 link1.state = 1 << blink::WebAXStateReadonly; |
518 link1_text.state = 1 << WebKit::WebAXStateReadonly; | 518 link1_text.state = 1 << blink::WebAXStateReadonly; |
519 link1.child_ids.push_back(16); | 519 link1.child_ids.push_back(16); |
520 | 520 |
521 AccessibilityNodeData root; | 521 AccessibilityNodeData root; |
522 root.id = 1; | 522 root.id = 1; |
523 root.role = WebKit::WebAXRoleRootWebArea; | 523 root.role = blink::WebAXRoleRootWebArea; |
524 root.state = 1 << WebKit::WebAXStateReadonly; | 524 root.state = 1 << blink::WebAXStateReadonly; |
525 root.child_ids.push_back(11); | 525 root.child_ids.push_back(11); |
526 root.child_ids.push_back(13); | 526 root.child_ids.push_back(13); |
527 root.child_ids.push_back(12); | 527 root.child_ids.push_back(12); |
528 root.child_ids.push_back(14); | 528 root.child_ids.push_back(14); |
529 | 529 |
530 CountedBrowserAccessibility::reset(); | 530 CountedBrowserAccessibility::reset(); |
531 scoped_ptr<BrowserAccessibilityManager> manager( | 531 scoped_ptr<BrowserAccessibilityManager> manager( |
532 BrowserAccessibilityManager::Create( | 532 BrowserAccessibilityManager::Create( |
533 root, NULL, new CountedBrowserAccessibilityFactory())); | 533 root, NULL, new CountedBrowserAccessibilityFactory())); |
534 manager->UpdateNodesForTesting(root, | 534 manager->UpdateNodesForTesting(root, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // Delete the manager and test that all BrowserAccessibility instances are | 594 // Delete the manager and test that all BrowserAccessibility instances are |
595 // deleted. | 595 // deleted. |
596 manager.reset(); | 596 manager.reset(); |
597 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 597 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
598 } | 598 } |
599 | 599 |
600 TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { | 600 TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { |
601 // Try creating an empty document with busy state. Readonly is | 601 // Try creating an empty document with busy state. Readonly is |
602 // set automatically. | 602 // set automatically. |
603 CountedBrowserAccessibility::reset(); | 603 CountedBrowserAccessibility::reset(); |
604 const int32 busy_state = 1 << WebKit::WebAXStateBusy; | 604 const int32 busy_state = 1 << blink::WebAXStateBusy; |
605 const int32 readonly_state = 1 << WebKit::WebAXStateReadonly; | 605 const int32 readonly_state = 1 << blink::WebAXStateReadonly; |
606 const int32 enabled_state = 1 << WebKit::WebAXStateEnabled; | 606 const int32 enabled_state = 1 << blink::WebAXStateEnabled; |
607 scoped_ptr<BrowserAccessibilityManager> manager( | 607 scoped_ptr<BrowserAccessibilityManager> manager( |
608 new BrowserAccessibilityManagerWin( | 608 new BrowserAccessibilityManagerWin( |
609 GetDesktopWindow(), | 609 GetDesktopWindow(), |
610 NULL, | 610 NULL, |
611 BrowserAccessibilityManagerWin::GetEmptyDocument(), | 611 BrowserAccessibilityManagerWin::GetEmptyDocument(), |
612 NULL, | 612 NULL, |
613 new CountedBrowserAccessibilityFactory())); | 613 new CountedBrowserAccessibilityFactory())); |
614 | 614 |
615 // Verify the root is as we expect by default. | 615 // Verify the root is as we expect by default. |
616 BrowserAccessibility* root = manager->GetRoot(); | 616 BrowserAccessibility* root = manager->GetRoot(); |
617 EXPECT_EQ(0, root->renderer_id()); | 617 EXPECT_EQ(0, root->renderer_id()); |
618 EXPECT_EQ(WebKit::WebAXRoleRootWebArea, root->role()); | 618 EXPECT_EQ(blink::WebAXRoleRootWebArea, root->role()); |
619 EXPECT_EQ(busy_state | readonly_state | enabled_state, root->state()); | 619 EXPECT_EQ(busy_state | readonly_state | enabled_state, root->state()); |
620 | 620 |
621 // Tree with a child textfield. | 621 // Tree with a child textfield. |
622 AccessibilityNodeData tree1_1; | 622 AccessibilityNodeData tree1_1; |
623 tree1_1.id = 1; | 623 tree1_1.id = 1; |
624 tree1_1.role = WebKit::WebAXRoleRootWebArea; | 624 tree1_1.role = blink::WebAXRoleRootWebArea; |
625 tree1_1.child_ids.push_back(2); | 625 tree1_1.child_ids.push_back(2); |
626 | 626 |
627 AccessibilityNodeData tree1_2; | 627 AccessibilityNodeData tree1_2; |
628 tree1_2.id = 2; | 628 tree1_2.id = 2; |
629 tree1_2.role = WebKit::WebAXRoleTextField; | 629 tree1_2.role = blink::WebAXRoleTextField; |
630 | 630 |
631 // Process a load complete. | 631 // Process a load complete. |
632 std::vector<AccessibilityHostMsg_EventParams> params; | 632 std::vector<AccessibilityHostMsg_EventParams> params; |
633 params.push_back(AccessibilityHostMsg_EventParams()); | 633 params.push_back(AccessibilityHostMsg_EventParams()); |
634 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 634 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
635 msg->event_type = WebKit::WebAXEventLoadComplete; | 635 msg->event_type = blink::WebAXEventLoadComplete; |
636 msg->nodes.push_back(tree1_1); | 636 msg->nodes.push_back(tree1_1); |
637 msg->nodes.push_back(tree1_2); | 637 msg->nodes.push_back(tree1_2); |
638 msg->id = tree1_1.id; | 638 msg->id = tree1_1.id; |
639 manager->OnAccessibilityEvents(params); | 639 manager->OnAccessibilityEvents(params); |
640 | 640 |
641 // Save for later comparison. | 641 // Save for later comparison. |
642 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(2); | 642 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(2); |
643 | 643 |
644 // Verify the root has changed. | 644 // Verify the root has changed. |
645 EXPECT_NE(root, manager->GetRoot()); | 645 EXPECT_NE(root, manager->GetRoot()); |
646 | 646 |
647 // And the proper child remains. | 647 // And the proper child remains. |
648 EXPECT_EQ(WebKit::WebAXRoleTextField, acc1_2->role()); | 648 EXPECT_EQ(blink::WebAXRoleTextField, acc1_2->role()); |
649 EXPECT_EQ(2, acc1_2->renderer_id()); | 649 EXPECT_EQ(2, acc1_2->renderer_id()); |
650 | 650 |
651 // Tree with a child button. | 651 // Tree with a child button. |
652 AccessibilityNodeData tree2_1; | 652 AccessibilityNodeData tree2_1; |
653 tree2_1.id = 1; | 653 tree2_1.id = 1; |
654 tree2_1.role = WebKit::WebAXRoleRootWebArea; | 654 tree2_1.role = blink::WebAXRoleRootWebArea; |
655 tree2_1.child_ids.push_back(3); | 655 tree2_1.child_ids.push_back(3); |
656 | 656 |
657 AccessibilityNodeData tree2_2; | 657 AccessibilityNodeData tree2_2; |
658 tree2_2.id = 3; | 658 tree2_2.id = 3; |
659 tree2_2.role = WebKit::WebAXRoleButton; | 659 tree2_2.role = blink::WebAXRoleButton; |
660 | 660 |
661 msg->nodes.clear(); | 661 msg->nodes.clear(); |
662 msg->nodes.push_back(tree2_1); | 662 msg->nodes.push_back(tree2_1); |
663 msg->nodes.push_back(tree2_2); | 663 msg->nodes.push_back(tree2_2); |
664 msg->id = tree2_1.id; | 664 msg->id = tree2_1.id; |
665 | 665 |
666 // Fire another load complete. | 666 // Fire another load complete. |
667 manager->OnAccessibilityEvents(params); | 667 manager->OnAccessibilityEvents(params); |
668 | 668 |
669 BrowserAccessibility* acc2_2 = manager->GetFromRendererID(3); | 669 BrowserAccessibility* acc2_2 = manager->GetFromRendererID(3); |
670 | 670 |
671 // Verify the root has changed. | 671 // Verify the root has changed. |
672 EXPECT_NE(root, manager->GetRoot()); | 672 EXPECT_NE(root, manager->GetRoot()); |
673 | 673 |
674 // And the new child exists. | 674 // And the new child exists. |
675 EXPECT_EQ(WebKit::WebAXRoleButton, acc2_2->role()); | 675 EXPECT_EQ(blink::WebAXRoleButton, acc2_2->role()); |
676 EXPECT_EQ(3, acc2_2->renderer_id()); | 676 EXPECT_EQ(3, acc2_2->renderer_id()); |
677 | 677 |
678 // Ensure we properly cleaned up. | 678 // Ensure we properly cleaned up. |
679 manager.reset(); | 679 manager.reset(); |
680 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 680 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
681 } | 681 } |
682 | 682 |
683 } // namespace content | 683 } // namespace content |
OLD | NEW |