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

Side by Side Diff: chrome/browser/accessibility/accessibility_win_browsertest.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/accessibility/renderer_accessibility_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/win/scoped_comptr.h" 10 #include "base/win/scoped_comptr.h"
11 #include "chrome/browser/automation/ui_controls.h" 11 #include "chrome/browser/automation/ui_controls.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/renderer_host/render_widget_host_view_win.h" 18 #include "content/browser/renderer_host/render_widget_host_view_win.h"
19 #include "content/browser/tab_contents/tab_contents.h" 19 #include "content/browser/tab_contents/tab_contents.h"
20 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
21 #include "third_party/iaccessible2/ia2_api_all.h" 22 #include "third_party/iaccessible2/ia2_api_all.h"
22 #include "third_party/isimpledom/ISimpleDOMNode.h" 23 #include "third_party/isimpledom/ISimpleDOMNode.h"
23 24
24 using std::auto_ptr; 25 using std::auto_ptr;
25 using std::vector; 26 using std::vector;
26 using std::wstring; 27 using std::wstring;
27 28
28 namespace { 29 namespace {
29 30
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 child_accessible.Attach(GetAccessibleFromResultVariant(parent, child)); 323 child_accessible.Attach(GetAccessibleFromResultVariant(parent, child));
323 ASSERT_TRUE(child_accessible.get()); 324 ASSERT_TRUE(child_accessible.get());
324 (*child_checker)->CheckAccessible(child_accessible); 325 (*child_checker)->CheckAccessible(child_accessible);
325 } 326 }
326 } 327 }
327 328
328 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 329 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
329 TestRendererAccessibilityTree) { 330 TestRendererAccessibilityTree) {
330 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 331 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
331 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 332 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
332 NotificationService::AllSources()); 333 content::NotificationService::AllSources());
333 334
334 // The initial accessible returned should have state STATE_SYSTEM_BUSY while 335 // The initial accessible returned should have state STATE_SYSTEM_BUSY while
335 // the accessibility tree is being requested from the renderer. 336 // the accessibility tree is being requested from the renderer.
336 AccessibleChecker document1_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 337 AccessibleChecker document1_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
337 document1_checker.SetExpectedState( 338 document1_checker.SetExpectedState(
338 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED | 339 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED |
339 STATE_SYSTEM_BUSY); 340 STATE_SYSTEM_BUSY);
340 document1_checker.CheckAccessible(GetRendererAccessible()); 341 document1_checker.CheckAccessible(GetRendererAccessible());
341 342
342 // Wait for the initial accessibility tree to load. Busy state should clear. 343 // Wait for the initial accessibility tree to load. Busy state should clear.
343 tree_updated_observer1.Wait(); 344 tree_updated_observer1.Wait();
344 document1_checker.SetExpectedState( 345 document1_checker.SetExpectedState(
345 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 346 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
346 document1_checker.CheckAccessible(GetRendererAccessible()); 347 document1_checker.CheckAccessible(GetRendererAccessible());
347 348
348 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 349 ui_test_utils::WindowedNotificationObserver tree_updated_observer2(
349 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 350 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
350 NotificationService::AllSources()); 351 content::NotificationService::AllSources());
351 GURL tree_url( 352 GURL tree_url(
352 "data:text/html,<html><head><title>Accessibility Win Test</title></head>" 353 "data:text/html,<html><head><title>Accessibility Win Test</title></head>"
353 "<body><input type='button' value='push' /><input type='checkbox' />" 354 "<body><input type='button' value='push' /><input type='checkbox' />"
354 "</body></html>"); 355 "</body></html>");
355 browser()->OpenURL( 356 browser()->OpenURL(
356 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 357 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
357 tree_updated_observer2.Wait(); 358 tree_updated_observer2.Wait();
358 359
359 // Check the browser's copy of the renderer accessibility tree. 360 // Check the browser's copy of the renderer accessibility tree.
360 AccessibleChecker button_checker(L"push", ROLE_SYSTEM_PUSHBUTTON, L"push"); 361 AccessibleChecker button_checker(L"push", ROLE_SYSTEM_PUSHBUTTON, L"push");
(...skipping 23 matching lines...) Expand all
384 // the page navagation. 385 // the page navagation.
385 CComBSTR name; 386 CComBSTR name;
386 hr = document_accessible->get_accName(CreateI4Variant(CHILDID_SELF), &name); 387 hr = document_accessible->get_accName(CreateI4Variant(CHILDID_SELF), &name);
387 ASSERT_EQ(E_FAIL, hr); 388 ASSERT_EQ(E_FAIL, hr);
388 } 389 }
389 390
390 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 391 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
391 TestNotificationActiveDescendantChanged) { 392 TestNotificationActiveDescendantChanged) {
392 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 393 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
393 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 394 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
394 NotificationService::AllSources()); 395 content::NotificationService::AllSources());
395 GURL tree_url("data:text/html,<ul tabindex='-1' role='radiogroup'><li id='li'" 396 GURL tree_url("data:text/html,<ul tabindex='-1' role='radiogroup'><li id='li'"
396 ">li</li></ul>"); 397 ">li</li></ul>");
397 browser()->OpenURL( 398 browser()->OpenURL(
398 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 399 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
399 GetRendererAccessible(); 400 GetRendererAccessible();
400 tree_updated_observer1.Wait(); 401 tree_updated_observer1.Wait();
401 402
402 // Check the browser's copy of the renderer accessibility tree. 403 // Check the browser's copy of the renderer accessibility tree.
403 AccessibleChecker list_marker_checker(L"", ROLE_SYSTEM_TEXT, L"\x2022"); 404 AccessibleChecker list_marker_checker(L"", ROLE_SYSTEM_TEXT, L"\x2022");
404 AccessibleChecker static_text_checker(L"li", ROLE_SYSTEM_TEXT, L""); 405 AccessibleChecker static_text_checker(L"li", ROLE_SYSTEM_TEXT, L"");
405 AccessibleChecker list_item_checker(L"", ROLE_SYSTEM_LISTITEM, L""); 406 AccessibleChecker list_item_checker(L"", ROLE_SYSTEM_LISTITEM, L"");
406 list_item_checker.SetExpectedState( 407 list_item_checker.SetExpectedState(
407 STATE_SYSTEM_READONLY); 408 STATE_SYSTEM_READONLY);
408 AccessibleChecker radio_group_checker(L"", ROLE_SYSTEM_GROUPING, L""); 409 AccessibleChecker radio_group_checker(L"", ROLE_SYSTEM_GROUPING, L"");
409 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 410 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
410 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 411 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
411 list_item_checker.AppendExpectedChild(&list_marker_checker); 412 list_item_checker.AppendExpectedChild(&list_marker_checker);
412 list_item_checker.AppendExpectedChild(&static_text_checker); 413 list_item_checker.AppendExpectedChild(&static_text_checker);
413 radio_group_checker.AppendExpectedChild(&list_item_checker); 414 radio_group_checker.AppendExpectedChild(&list_item_checker);
414 document_checker.AppendExpectedChild(&radio_group_checker); 415 document_checker.AppendExpectedChild(&radio_group_checker);
415 document_checker.CheckAccessible(GetRendererAccessible()); 416 document_checker.CheckAccessible(GetRendererAccessible());
416 417
417 // Set focus to the radio group. 418 // Set focus to the radio group.
418 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 419 ui_test_utils::WindowedNotificationObserver tree_updated_observer2(
419 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 420 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
420 NotificationService::AllSources()); 421 content::NotificationService::AllSources());
421 ExecuteScript(L"document.body.children[0].focus()"); 422 ExecuteScript(L"document.body.children[0].focus()");
422 tree_updated_observer2.Wait(); 423 tree_updated_observer2.Wait();
423 424
424 // Check that the accessibility tree of the browser has been updated. 425 // Check that the accessibility tree of the browser has been updated.
425 radio_group_checker.SetExpectedState( 426 radio_group_checker.SetExpectedState(
426 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 427 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
427 document_checker.CheckAccessible(GetRendererAccessible()); 428 document_checker.CheckAccessible(GetRendererAccessible());
428 429
429 // Set the active descendant of the radio group 430 // Set the active descendant of the radio group
430 ui_test_utils::WindowedNotificationObserver tree_updated_observer3( 431 ui_test_utils::WindowedNotificationObserver tree_updated_observer3(
431 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 432 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
432 NotificationService::AllSources()); 433 content::NotificationService::AllSources());
433 ExecuteScript( 434 ExecuteScript(
434 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); 435 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')");
435 tree_updated_observer3.Wait(); 436 tree_updated_observer3.Wait();
436 437
437 // Check that the accessibility tree of the browser has been updated. 438 // Check that the accessibility tree of the browser has been updated.
438 list_item_checker.SetExpectedState( 439 list_item_checker.SetExpectedState(
439 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 440 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
440 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 441 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
441 document_checker.CheckAccessible(GetRendererAccessible()); 442 document_checker.CheckAccessible(GetRendererAccessible());
442 } 443 }
443 444
444 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 445 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
445 TestNotificationCheckedStateChanged) { 446 TestNotificationCheckedStateChanged) {
446 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 447 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
447 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 448 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
448 NotificationService::AllSources()); 449 content::NotificationService::AllSources());
449 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>"); 450 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
450 browser()->OpenURL( 451 browser()->OpenURL(
451 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 452 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
452 GetRendererAccessible(); 453 GetRendererAccessible();
453 tree_updated_observer1.Wait(); 454 tree_updated_observer1.Wait();
454 455
455 // Check the browser's copy of the renderer accessibility tree. 456 // Check the browser's copy of the renderer accessibility tree.
456 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L""); 457 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L"");
457 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 458 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
458 AccessibleChecker body_checker(L"", L"body", L""); 459 AccessibleChecker body_checker(L"", L"body", L"");
459 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 460 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
460 body_checker.AppendExpectedChild(&checkbox_checker); 461 body_checker.AppendExpectedChild(&checkbox_checker);
461 document_checker.AppendExpectedChild(&body_checker); 462 document_checker.AppendExpectedChild(&body_checker);
462 document_checker.CheckAccessible(GetRendererAccessible()); 463 document_checker.CheckAccessible(GetRendererAccessible());
463 464
464 // Check the checkbox. 465 // Check the checkbox.
465 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 466 ui_test_utils::WindowedNotificationObserver tree_updated_observer2(
466 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 467 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
467 NotificationService::AllSources()); 468 content::NotificationService::AllSources());
468 ExecuteScript(L"document.body.children[0].checked=true"); 469 ExecuteScript(L"document.body.children[0].checked=true");
469 tree_updated_observer2.Wait(); 470 tree_updated_observer2.Wait();
470 471
471 // Check that the accessibility tree of the browser has been updated. 472 // Check that the accessibility tree of the browser has been updated.
472 checkbox_checker.SetExpectedState( 473 checkbox_checker.SetExpectedState(
473 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); 474 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE);
474 document_checker.CheckAccessible(GetRendererAccessible()); 475 document_checker.CheckAccessible(GetRendererAccessible());
475 } 476 }
476 477
477 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 478 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
478 TestNotificationChildrenChanged) { 479 TestNotificationChildrenChanged) {
479 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 480 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
480 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 481 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
481 NotificationService::AllSources()); 482 content::NotificationService::AllSources());
482 // The role attribute causes the node to be in the accessibility tree. 483 // The role attribute causes the node to be in the accessibility tree.
483 GURL tree_url( 484 GURL tree_url(
484 "data:text/html,<body role=group></body>"); 485 "data:text/html,<body role=group></body>");
485 browser()->OpenURL( 486 browser()->OpenURL(
486 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 487 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
487 GetRendererAccessible(); 488 GetRendererAccessible();
488 tree_updated_observer1.Wait(); 489 tree_updated_observer1.Wait();
489 490
490 // Check the browser's copy of the renderer accessibility tree. 491 // Check the browser's copy of the renderer accessibility tree.
491 AccessibleChecker body_checker(L"", L"body", L""); 492 AccessibleChecker body_checker(L"", L"body", L"");
492 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 493 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
493 document_checker.AppendExpectedChild(&body_checker); 494 document_checker.AppendExpectedChild(&body_checker);
494 document_checker.CheckAccessible(GetRendererAccessible()); 495 document_checker.CheckAccessible(GetRendererAccessible());
495 496
496 // Change the children of the document body. 497 // Change the children of the document body.
497 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 498 ui_test_utils::WindowedNotificationObserver tree_updated_observer2(
498 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 499 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
499 NotificationService::AllSources()); 500 content::NotificationService::AllSources());
500 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); 501 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'");
501 tree_updated_observer2.Wait(); 502 tree_updated_observer2.Wait();
502 503
503 // Check that the accessibility tree of the browser has been updated. 504 // Check that the accessibility tree of the browser has been updated.
504 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L""); 505 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L"");
505 body_checker.AppendExpectedChild(&text_checker); 506 body_checker.AppendExpectedChild(&text_checker);
506 document_checker.CheckAccessible(GetRendererAccessible()); 507 document_checker.CheckAccessible(GetRendererAccessible());
507 } 508 }
508 509
509 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 510 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
510 TestNotificationChildrenChanged2) { 511 TestNotificationChildrenChanged2) {
511 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 512 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
512 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 513 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
513 NotificationService::AllSources()); 514 content::NotificationService::AllSources());
514 // The role attribute causes the node to be in the accessibility tree. 515 // The role attribute causes the node to be in the accessibility tree.
515 GURL tree_url( 516 GURL tree_url(
516 "data:text/html,<div role=group style='visibility: hidden'>text" 517 "data:text/html,<div role=group style='visibility: hidden'>text"
517 "</div>"); 518 "</div>");
518 browser()->OpenURL( 519 browser()->OpenURL(
519 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 520 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
520 GetRendererAccessible(); 521 GetRendererAccessible();
521 tree_updated_observer1.Wait(); 522 tree_updated_observer1.Wait();
522 523
523 // Check the accessible tree of the browser. 524 // Check the accessible tree of the browser.
524 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 525 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
525 document_checker.CheckAccessible(GetRendererAccessible()); 526 document_checker.CheckAccessible(GetRendererAccessible());
526 527
527 // Change the children of the document body. 528 // Change the children of the document body.
528 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 529 ui_test_utils::WindowedNotificationObserver tree_updated_observer2(
529 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 530 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
530 NotificationService::AllSources()); 531 content::NotificationService::AllSources());
531 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); 532 ExecuteScript(L"document.body.children[0].style.visibility='visible'");
532 tree_updated_observer2.Wait(); 533 tree_updated_observer2.Wait();
533 534
534 // Check that the accessibility tree of the browser has been updated. 535 // Check that the accessibility tree of the browser has been updated.
535 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L""); 536 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L"");
536 AccessibleChecker div_checker(L"", L"div", L""); 537 AccessibleChecker div_checker(L"", L"div", L"");
537 document_checker.AppendExpectedChild(&div_checker); 538 document_checker.AppendExpectedChild(&div_checker);
538 div_checker.AppendExpectedChild(&static_text_checker); 539 div_checker.AppendExpectedChild(&static_text_checker);
539 document_checker.CheckAccessible(GetRendererAccessible()); 540 document_checker.CheckAccessible(GetRendererAccessible());
540 } 541 }
541 542
542 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 543 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
543 TestNotificationFocusChanged) { 544 TestNotificationFocusChanged) {
544 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 545 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
545 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 546 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
546 NotificationService::AllSources()); 547 content::NotificationService::AllSources());
547 // The role attribute causes the node to be in the accessibility tree. 548 // The role attribute causes the node to be in the accessibility tree.
548 GURL tree_url( 549 GURL tree_url(
549 "data:text/html,<div role=group tabindex='-1'></div>"); 550 "data:text/html,<div role=group tabindex='-1'></div>");
550 browser()->OpenURL( 551 browser()->OpenURL(
551 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 552 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
552 GetRendererAccessible(); 553 GetRendererAccessible();
553 tree_updated_observer1.Wait(); 554 tree_updated_observer1.Wait();
554 555
555 // Check the browser's copy of the renderer accessibility tree. 556 // Check the browser's copy of the renderer accessibility tree.
556 AccessibleChecker div_checker(L"", L"div", L""); 557 AccessibleChecker div_checker(L"", L"div", L"");
557 div_checker.SetExpectedState( 558 div_checker.SetExpectedState(
558 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_READONLY); 559 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_READONLY);
559 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 560 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
560 document_checker.AppendExpectedChild(&div_checker); 561 document_checker.AppendExpectedChild(&div_checker);
561 document_checker.CheckAccessible(GetRendererAccessible()); 562 document_checker.CheckAccessible(GetRendererAccessible());
562 563
563 // Focus the div in the document 564 // Focus the div in the document
564 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 565 ui_test_utils::WindowedNotificationObserver tree_updated_observer2(
565 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 566 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
566 NotificationService::AllSources()); 567 content::NotificationService::AllSources());
567 ExecuteScript(L"document.body.children[0].focus()"); 568 ExecuteScript(L"document.body.children[0].focus()");
568 tree_updated_observer2.Wait(); 569 tree_updated_observer2.Wait();
569 570
570 // Check that the accessibility tree of the browser has been updated. 571 // Check that the accessibility tree of the browser has been updated.
571 div_checker.SetExpectedState( 572 div_checker.SetExpectedState(
572 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 573 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
573 document_checker.CheckAccessible(GetRendererAccessible()); 574 document_checker.CheckAccessible(GetRendererAccessible());
574 575
575 // Focus the document accessible. This will un-focus the current node. 576 // Focus the document accessible. This will un-focus the current node.
576 ui_test_utils::WindowedNotificationObserver tree_updated_observer3( 577 ui_test_utils::WindowedNotificationObserver tree_updated_observer3(
577 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 578 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
578 NotificationService::AllSources()); 579 content::NotificationService::AllSources());
579 base::win::ScopedComPtr<IAccessible> document_accessible( 580 base::win::ScopedComPtr<IAccessible> document_accessible(
580 GetRendererAccessible()); 581 GetRendererAccessible());
581 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 582 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
582 HRESULT hr = document_accessible->accSelect( 583 HRESULT hr = document_accessible->accSelect(
583 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF)); 584 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF));
584 ASSERT_EQ(S_OK, hr); 585 ASSERT_EQ(S_OK, hr);
585 tree_updated_observer3.Wait(); 586 tree_updated_observer3.Wait();
586 587
587 // Check that the accessibility tree of the browser has been updated. 588 // Check that the accessibility tree of the browser has been updated.
588 div_checker.SetExpectedState( 589 div_checker.SetExpectedState(
589 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY); 590 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
590 document_checker.CheckAccessible(GetRendererAccessible()); 591 document_checker.CheckAccessible(GetRendererAccessible());
591 } 592 }
592 593
593 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 594 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
594 TestNotificationValueChanged) { 595 TestNotificationValueChanged) {
595 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 596 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
596 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 597 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
597 NotificationService::AllSources()); 598 content::NotificationService::AllSources());
598 GURL tree_url("data:text/html,<body><input type='text' value='old value'/>" 599 GURL tree_url("data:text/html,<body><input type='text' value='old value'/>"
599 "</body>"); 600 "</body>");
600 browser()->OpenURL( 601 browser()->OpenURL(
601 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 602 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
602 GetRendererAccessible(); 603 GetRendererAccessible();
603 tree_updated_observer1.Wait(); 604 tree_updated_observer1.Wait();
604 605
605 // Check the browser's copy of the renderer accessibility tree. 606 // Check the browser's copy of the renderer accessibility tree.
606 607
607 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value"); 608 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value");
608 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 609 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
609 AccessibleChecker body_checker(L"", L"body", L""); 610 AccessibleChecker body_checker(L"", L"body", L"");
610 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 611 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
611 body_checker.AppendExpectedChild(&text_field_checker); 612 body_checker.AppendExpectedChild(&text_field_checker);
612 document_checker.AppendExpectedChild(&body_checker); 613 document_checker.AppendExpectedChild(&body_checker);
613 document_checker.CheckAccessible(GetRendererAccessible()); 614 document_checker.CheckAccessible(GetRendererAccessible());
614 615
615 // Set the value of the text control 616 // Set the value of the text control
616 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 617 ui_test_utils::WindowedNotificationObserver tree_updated_observer2(
617 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 618 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
618 NotificationService::AllSources()); 619 content::NotificationService::AllSources());
619 ExecuteScript(L"document.body.children[0].value='new value'"); 620 ExecuteScript(L"document.body.children[0].value='new value'");
620 tree_updated_observer2.Wait(); 621 tree_updated_observer2.Wait();
621 622
622 // Check that the accessibility tree of the browser has been updated. 623 // Check that the accessibility tree of the browser has been updated.
623 text_field_checker.SetExpectedValue(L"new value"); 624 text_field_checker.SetExpectedValue(L"new value");
624 document_checker.CheckAccessible(GetRendererAccessible()); 625 document_checker.CheckAccessible(GetRendererAccessible());
625 } 626 }
626 627
627 // This test verifies that the web content's accessibility tree is a 628 // This test verifies that the web content's accessibility tree is a
628 // descendant of the main browser window's accessibility tree, so that 629 // descendant of the main browser window's accessibility tree, so that
629 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's 630 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's
630 // accessibility support. 631 // accessibility support.
631 // 632 //
632 // If you made a change and this test now fails, check that the NativeViewHost 633 // If you made a change and this test now fails, check that the NativeViewHost
633 // that wraps the tab contents returns the IAccessible implementation 634 // that wraps the tab contents returns the IAccessible implementation
634 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible(). 635 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible().
635 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 636 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
636 ContainsRendererAccessibilityTree) { 637 ContainsRendererAccessibilityTree) {
637 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 638 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
638 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 639 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
639 NotificationService::AllSources()); 640 content::NotificationService::AllSources());
640 GURL tree_url("data:text/html,<html><head><title>MyDocument</title></head>" 641 GURL tree_url("data:text/html,<html><head><title>MyDocument</title></head>"
641 "<body>Content</body></html>"); 642 "<body>Content</body></html>");
642 browser()->OpenURL( 643 browser()->OpenURL(
643 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 644 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
644 GetRendererAccessible(); 645 GetRendererAccessible();
645 tree_updated_observer1.Wait(); 646 tree_updated_observer1.Wait();
646 647
647 // Get the accessibility object for the browser window. 648 // Get the accessibility object for the browser window.
648 HWND browser_hwnd = browser()->window()->GetNativeHandle(); 649 HWND browser_hwnd = browser()->window()->GetNativeHandle();
649 base::win::ScopedComPtr<IAccessible> browser_accessible; 650 base::win::ScopedComPtr<IAccessible> browser_accessible;
650 HRESULT hr = AccessibleObjectFromWindow( 651 HRESULT hr = AccessibleObjectFromWindow(
651 browser_hwnd, 652 browser_hwnd,
652 OBJID_WINDOW, 653 OBJID_WINDOW,
653 IID_IAccessible, 654 IID_IAccessible,
654 reinterpret_cast<void**>(browser_accessible.Receive())); 655 reinterpret_cast<void**>(browser_accessible.Receive()));
655 ASSERT_EQ(S_OK, hr); 656 ASSERT_EQ(S_OK, hr);
656 657
657 bool found = false; 658 bool found = false;
658 RecursiveFindNodeInAccessibilityTree( 659 RecursiveFindNodeInAccessibilityTree(
659 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found); 660 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found);
660 ASSERT_EQ(found, true); 661 ASSERT_EQ(found, true);
661 } 662 }
662 663
663 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 664 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
664 SupportsISimpleDOM) { 665 SupportsISimpleDOM) {
665 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 666 ui_test_utils::WindowedNotificationObserver tree_updated_observer1(
666 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 667 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
667 NotificationService::AllSources()); 668 content::NotificationService::AllSources());
668 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>"); 669 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
669 browser()->OpenURL( 670 browser()->OpenURL(
670 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); 671 tree_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
671 GetRendererAccessible(); 672 GetRendererAccessible();
672 tree_updated_observer1.Wait(); 673 tree_updated_observer1.Wait();
673 674
674 // Get the IAccessible object for the document. 675 // Get the IAccessible object for the document.
675 base::win::ScopedComPtr<IAccessible> document_accessible( 676 base::win::ScopedComPtr<IAccessible> document_accessible(
676 GetRendererAccessible()); 677 GetRendererAccessible());
677 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 678 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 ASSERT_EQ(S_OK, hr); 721 ASSERT_EQ(S_OK, hr);
721 hr = checkbox_isimpledomnode->get_nodeInfo( 722 hr = checkbox_isimpledomnode->get_nodeInfo(
722 &node_name, &name_space_id, &node_value, &num_children, &unique_id, 723 &node_name, &name_space_id, &node_value, &num_children, &unique_id,
723 &node_type); 724 &node_type);
724 ASSERT_EQ(S_OK, hr); 725 ASSERT_EQ(S_OK, hr);
725 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str()); 726 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str());
726 EXPECT_EQ(NODETYPE_ELEMENT, node_type); 727 EXPECT_EQ(NODETYPE_ELEMENT, node_type);
727 EXPECT_EQ(0, num_children); 728 EXPECT_EQ(0, num_children);
728 } 729 }
729 } // namespace. 730 } // namespace.
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/accessibility/renderer_accessibility_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698