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

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

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/autocomplete/autocomplete_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) 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 <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/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 string16 AccessibleChecker::RoleVariantToString(VARIANT* role_variant) { 391 string16 AccessibleChecker::RoleVariantToString(VARIANT* role_variant) {
392 if (V_VT(role_variant) == VT_I4) 392 if (V_VT(role_variant) == VT_I4)
393 return IAccessibleRoleToString(V_I4(role_variant)); 393 return IAccessibleRoleToString(V_I4(role_variant));
394 else if (V_VT(role_variant) == VT_BSTR) 394 else if (V_VT(role_variant) == VT_BSTR)
395 return string16(V_BSTR(role_variant), SysStringLen(V_BSTR(role_variant))); 395 return string16(V_BSTR(role_variant), SysStringLen(V_BSTR(role_variant)));
396 return string16(); 396 return string16();
397 } 397 }
398 398
399 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 399 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
400 TestRendererAccessibilityTree) { 400 TestRendererAccessibilityTree) {
401 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 401 content::WindowedNotificationObserver tree_updated_observer1(
402 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 402 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
403 content::NotificationService::AllSources()); 403 content::NotificationService::AllSources());
404 404
405 // The initial accessible returned should have state STATE_SYSTEM_BUSY while 405 // The initial accessible returned should have state STATE_SYSTEM_BUSY while
406 // the accessibility tree is being requested from the renderer. 406 // the accessibility tree is being requested from the renderer.
407 AccessibleChecker document1_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 407 AccessibleChecker document1_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
408 document1_checker.SetExpectedState( 408 document1_checker.SetExpectedState(
409 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED | 409 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED |
410 STATE_SYSTEM_BUSY); 410 STATE_SYSTEM_BUSY);
411 document1_checker.CheckAccessible(GetRendererAccessible()); 411 document1_checker.CheckAccessible(GetRendererAccessible());
412 412
413 // Wait for the initial accessibility tree to load. Busy state should clear. 413 // Wait for the initial accessibility tree to load. Busy state should clear.
414 tree_updated_observer1.Wait(); 414 tree_updated_observer1.Wait();
415 document1_checker.SetExpectedState( 415 document1_checker.SetExpectedState(
416 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 416 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
417 document1_checker.CheckAccessible(GetRendererAccessible()); 417 document1_checker.CheckAccessible(GetRendererAccessible());
418 418
419 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 419 content::WindowedNotificationObserver tree_updated_observer2(
420 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 420 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
421 content::NotificationService::AllSources()); 421 content::NotificationService::AllSources());
422 GURL tree_url( 422 GURL tree_url(
423 "data:text/html,<html><head><title>Accessibility Win Test</title></head>" 423 "data:text/html,<html><head><title>Accessibility Win Test</title></head>"
424 "<body><input type='button' value='push' /><input type='checkbox' />" 424 "<body><input type='button' value='push' /><input type='checkbox' />"
425 "</body></html>"); 425 "</body></html>");
426 browser()->OpenURL(OpenURLParams( 426 browser()->OpenURL(OpenURLParams(
427 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)) ; 427 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)) ;
428 tree_updated_observer2.Wait(); 428 tree_updated_observer2.Wait();
429 429
(...skipping 23 matching lines...) Expand all
453 // Verify that the IAccessible reference still points to a valid object and 453 // Verify that the IAccessible reference still points to a valid object and
454 // that calls to its methods fail since the tree is no longer valid after 454 // that calls to its methods fail since the tree is no longer valid after
455 // the page navagation. 455 // the page navagation.
456 CComBSTR name; 456 CComBSTR name;
457 hr = document_accessible->get_accName(CreateI4Variant(CHILDID_SELF), &name); 457 hr = document_accessible->get_accName(CreateI4Variant(CHILDID_SELF), &name);
458 ASSERT_EQ(E_FAIL, hr); 458 ASSERT_EQ(E_FAIL, hr);
459 } 459 }
460 460
461 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 461 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
462 TestNotificationActiveDescendantChanged) { 462 TestNotificationActiveDescendantChanged) {
463 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 463 content::WindowedNotificationObserver tree_updated_observer1(
464 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 464 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
465 content::NotificationService::AllSources()); 465 content::NotificationService::AllSources());
466 GURL tree_url("data:text/html,<ul tabindex='-1' role='radiogroup'><li id='li'" 466 GURL tree_url("data:text/html,<ul tabindex='-1' role='radiogroup'><li id='li'"
467 ">li</li></ul>"); 467 ">li</li></ul>");
468 browser()->OpenURL(OpenURLParams( 468 browser()->OpenURL(OpenURLParams(
469 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 469 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
470 false)); 470 false));
471 GetRendererAccessible(); 471 GetRendererAccessible();
472 tree_updated_observer1.Wait(); 472 tree_updated_observer1.Wait();
473 473
474 // Check the browser's copy of the renderer accessibility tree. 474 // Check the browser's copy of the renderer accessibility tree.
475 AccessibleChecker list_marker_checker(L"\x2022", ROLE_SYSTEM_TEXT, L""); 475 AccessibleChecker list_marker_checker(L"\x2022", ROLE_SYSTEM_TEXT, L"");
476 AccessibleChecker static_text_checker(L"li", ROLE_SYSTEM_TEXT, L""); 476 AccessibleChecker static_text_checker(L"li", ROLE_SYSTEM_TEXT, L"");
477 AccessibleChecker list_item_checker(L"", ROLE_SYSTEM_LISTITEM, L""); 477 AccessibleChecker list_item_checker(L"", ROLE_SYSTEM_LISTITEM, L"");
478 list_item_checker.SetExpectedState( 478 list_item_checker.SetExpectedState(
479 STATE_SYSTEM_READONLY); 479 STATE_SYSTEM_READONLY);
480 AccessibleChecker radio_group_checker(L"", ROLE_SYSTEM_GROUPING, 480 AccessibleChecker radio_group_checker(L"", ROLE_SYSTEM_GROUPING,
481 IA2_ROLE_SECTION, L""); 481 IA2_ROLE_SECTION, L"");
482 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 482 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
483 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 483 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
484 list_item_checker.AppendExpectedChild(&list_marker_checker); 484 list_item_checker.AppendExpectedChild(&list_marker_checker);
485 list_item_checker.AppendExpectedChild(&static_text_checker); 485 list_item_checker.AppendExpectedChild(&static_text_checker);
486 radio_group_checker.AppendExpectedChild(&list_item_checker); 486 radio_group_checker.AppendExpectedChild(&list_item_checker);
487 document_checker.AppendExpectedChild(&radio_group_checker); 487 document_checker.AppendExpectedChild(&radio_group_checker);
488 document_checker.CheckAccessible(GetRendererAccessible()); 488 document_checker.CheckAccessible(GetRendererAccessible());
489 489
490 // Set focus to the radio group. 490 // Set focus to the radio group.
491 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 491 content::WindowedNotificationObserver tree_updated_observer2(
492 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 492 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
493 content::NotificationService::AllSources()); 493 content::NotificationService::AllSources());
494 ExecuteScript(L"document.body.children[0].focus()"); 494 ExecuteScript(L"document.body.children[0].focus()");
495 tree_updated_observer2.Wait(); 495 tree_updated_observer2.Wait();
496 496
497 // Check that the accessibility tree of the browser has been updated. 497 // Check that the accessibility tree of the browser has been updated.
498 radio_group_checker.SetExpectedState( 498 radio_group_checker.SetExpectedState(
499 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 499 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
500 document_checker.CheckAccessible(GetRendererAccessible()); 500 document_checker.CheckAccessible(GetRendererAccessible());
501 501
502 // Set the active descendant of the radio group 502 // Set the active descendant of the radio group
503 ui_test_utils::WindowedNotificationObserver tree_updated_observer3( 503 content::WindowedNotificationObserver tree_updated_observer3(
504 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 504 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
505 content::NotificationService::AllSources()); 505 content::NotificationService::AllSources());
506 ExecuteScript( 506 ExecuteScript(
507 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); 507 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')");
508 tree_updated_observer3.Wait(); 508 tree_updated_observer3.Wait();
509 509
510 // Check that the accessibility tree of the browser has been updated. 510 // Check that the accessibility tree of the browser has been updated.
511 list_item_checker.SetExpectedState( 511 list_item_checker.SetExpectedState(
512 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 512 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
513 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 513 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
514 document_checker.CheckAccessible(GetRendererAccessible()); 514 document_checker.CheckAccessible(GetRendererAccessible());
515 } 515 }
516 516
517 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 517 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
518 TestNotificationCheckedStateChanged) { 518 TestNotificationCheckedStateChanged) {
519 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 519 content::WindowedNotificationObserver tree_updated_observer1(
520 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 520 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
521 content::NotificationService::AllSources()); 521 content::NotificationService::AllSources());
522 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>"); 522 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
523 browser()->OpenURL(OpenURLParams( 523 browser()->OpenURL(OpenURLParams(
524 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 524 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
525 false)); 525 false));
526 GetRendererAccessible(); 526 GetRendererAccessible();
527 tree_updated_observer1.Wait(); 527 tree_updated_observer1.Wait();
528 528
529 // Check the browser's copy of the renderer accessibility tree. 529 // Check the browser's copy of the renderer accessibility tree.
530 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L""); 530 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L"");
531 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 531 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
532 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L""); 532 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L"");
533 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 533 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
534 body_checker.AppendExpectedChild(&checkbox_checker); 534 body_checker.AppendExpectedChild(&checkbox_checker);
535 document_checker.AppendExpectedChild(&body_checker); 535 document_checker.AppendExpectedChild(&body_checker);
536 document_checker.CheckAccessible(GetRendererAccessible()); 536 document_checker.CheckAccessible(GetRendererAccessible());
537 537
538 // Check the checkbox. 538 // Check the checkbox.
539 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 539 content::WindowedNotificationObserver tree_updated_observer2(
540 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 540 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
541 content::NotificationService::AllSources()); 541 content::NotificationService::AllSources());
542 ExecuteScript(L"document.body.children[0].checked=true"); 542 ExecuteScript(L"document.body.children[0].checked=true");
543 tree_updated_observer2.Wait(); 543 tree_updated_observer2.Wait();
544 544
545 // Check that the accessibility tree of the browser has been updated. 545 // Check that the accessibility tree of the browser has been updated.
546 checkbox_checker.SetExpectedState( 546 checkbox_checker.SetExpectedState(
547 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); 547 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE);
548 document_checker.CheckAccessible(GetRendererAccessible()); 548 document_checker.CheckAccessible(GetRendererAccessible());
549 } 549 }
550 550
551 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 551 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
552 TestNotificationChildrenChanged) { 552 TestNotificationChildrenChanged) {
553 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 553 content::WindowedNotificationObserver tree_updated_observer1(
554 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 554 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
555 content::NotificationService::AllSources()); 555 content::NotificationService::AllSources());
556 // The role attribute causes the node to be in the accessibility tree. 556 // The role attribute causes the node to be in the accessibility tree.
557 GURL tree_url( 557 GURL tree_url(
558 "data:text/html,<body role=group></body>"); 558 "data:text/html,<body role=group></body>");
559 browser()->OpenURL(OpenURLParams( 559 browser()->OpenURL(OpenURLParams(
560 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 560 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
561 false)); 561 false));
562 GetRendererAccessible(); 562 GetRendererAccessible();
563 tree_updated_observer1.Wait(); 563 tree_updated_observer1.Wait();
564 564
565 // Check the browser's copy of the renderer accessibility tree. 565 // Check the browser's copy of the renderer accessibility tree.
566 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); 566 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L"");
567 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 567 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
568 document_checker.AppendExpectedChild(&group_checker); 568 document_checker.AppendExpectedChild(&group_checker);
569 document_checker.CheckAccessible(GetRendererAccessible()); 569 document_checker.CheckAccessible(GetRendererAccessible());
570 570
571 // Change the children of the document body. 571 // Change the children of the document body.
572 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 572 content::WindowedNotificationObserver tree_updated_observer2(
573 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 573 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
574 content::NotificationService::AllSources()); 574 content::NotificationService::AllSources());
575 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); 575 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'");
576 tree_updated_observer2.Wait(); 576 tree_updated_observer2.Wait();
577 577
578 // Check that the accessibility tree of the browser has been updated. 578 // Check that the accessibility tree of the browser has been updated.
579 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L""); 579 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L"");
580 group_checker.AppendExpectedChild(&text_checker); 580 group_checker.AppendExpectedChild(&text_checker);
581 document_checker.CheckAccessible(GetRendererAccessible()); 581 document_checker.CheckAccessible(GetRendererAccessible());
582 } 582 }
583 583
584 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 584 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
585 TestNotificationChildrenChanged2) { 585 TestNotificationChildrenChanged2) {
586 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 586 content::WindowedNotificationObserver tree_updated_observer1(
587 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 587 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
588 content::NotificationService::AllSources()); 588 content::NotificationService::AllSources());
589 // The role attribute causes the node to be in the accessibility tree. 589 // The role attribute causes the node to be in the accessibility tree.
590 GURL tree_url( 590 GURL tree_url(
591 "data:text/html,<div role=group style='visibility: hidden'>text" 591 "data:text/html,<div role=group style='visibility: hidden'>text"
592 "</div>"); 592 "</div>");
593 browser()->OpenURL(OpenURLParams( 593 browser()->OpenURL(OpenURLParams(
594 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 594 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
595 false)); 595 false));
596 GetRendererAccessible(); 596 GetRendererAccessible();
597 tree_updated_observer1.Wait(); 597 tree_updated_observer1.Wait();
598 598
599 // Check the accessible tree of the browser. 599 // Check the accessible tree of the browser.
600 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 600 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
601 document_checker.CheckAccessible(GetRendererAccessible()); 601 document_checker.CheckAccessible(GetRendererAccessible());
602 602
603 // Change the children of the document body. 603 // Change the children of the document body.
604 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 604 content::WindowedNotificationObserver tree_updated_observer2(
605 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 605 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
606 content::NotificationService::AllSources()); 606 content::NotificationService::AllSources());
607 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); 607 ExecuteScript(L"document.body.children[0].style.visibility='visible'");
608 tree_updated_observer2.Wait(); 608 tree_updated_observer2.Wait();
609 609
610 // Check that the accessibility tree of the browser has been updated. 610 // Check that the accessibility tree of the browser has been updated.
611 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L""); 611 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L"");
612 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); 612 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L"");
613 document_checker.AppendExpectedChild(&group_checker); 613 document_checker.AppendExpectedChild(&group_checker);
614 group_checker.AppendExpectedChild(&static_text_checker); 614 group_checker.AppendExpectedChild(&static_text_checker);
615 document_checker.CheckAccessible(GetRendererAccessible()); 615 document_checker.CheckAccessible(GetRendererAccessible());
616 } 616 }
617 617
618 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 618 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
619 TestNotificationFocusChanged) { 619 TestNotificationFocusChanged) {
620 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 620 content::WindowedNotificationObserver tree_updated_observer1(
621 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 621 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
622 content::NotificationService::AllSources()); 622 content::NotificationService::AllSources());
623 // The role attribute causes the node to be in the accessibility tree. 623 // The role attribute causes the node to be in the accessibility tree.
624 GURL tree_url( 624 GURL tree_url(
625 "data:text/html,<div role=group tabindex='-1'></div>"); 625 "data:text/html,<div role=group tabindex='-1'></div>");
626 browser()->OpenURL(OpenURLParams( 626 browser()->OpenURL(OpenURLParams(
627 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 627 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
628 false)); 628 false));
629 GetRendererAccessible(); 629 GetRendererAccessible();
630 tree_updated_observer1.Wait(); 630 tree_updated_observer1.Wait();
631 631
632 // Check the browser's copy of the renderer accessibility tree. 632 // Check the browser's copy of the renderer accessibility tree.
633 SCOPED_TRACE("Check initial tree"); 633 SCOPED_TRACE("Check initial tree");
634 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); 634 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L"");
635 group_checker.SetExpectedState( 635 group_checker.SetExpectedState(
636 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN); 636 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN);
637 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 637 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
638 document_checker.AppendExpectedChild(&group_checker); 638 document_checker.AppendExpectedChild(&group_checker);
639 document_checker.CheckAccessible(GetRendererAccessible()); 639 document_checker.CheckAccessible(GetRendererAccessible());
640 640
641 // Focus the div in the document 641 // Focus the div in the document
642 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 642 content::WindowedNotificationObserver tree_updated_observer2(
643 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 643 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
644 content::NotificationService::AllSources()); 644 content::NotificationService::AllSources());
645 ExecuteScript(L"document.body.children[0].focus()"); 645 ExecuteScript(L"document.body.children[0].focus()");
646 tree_updated_observer2.Wait(); 646 tree_updated_observer2.Wait();
647 647
648 // Check that the accessibility tree of the browser has been updated. 648 // Check that the accessibility tree of the browser has been updated.
649 SCOPED_TRACE("Check updated tree after focusing div"); 649 SCOPED_TRACE("Check updated tree after focusing div");
650 group_checker.SetExpectedState( 650 group_checker.SetExpectedState(
651 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 651 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
652 document_checker.CheckAccessible(GetRendererAccessible()); 652 document_checker.CheckAccessible(GetRendererAccessible());
653 653
654 // Focus the document accessible. This will un-focus the current node. 654 // Focus the document accessible. This will un-focus the current node.
655 ui_test_utils::WindowedNotificationObserver tree_updated_observer3( 655 content::WindowedNotificationObserver tree_updated_observer3(
656 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 656 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
657 content::NotificationService::AllSources()); 657 content::NotificationService::AllSources());
658 base::win::ScopedComPtr<IAccessible> document_accessible( 658 base::win::ScopedComPtr<IAccessible> document_accessible(
659 GetRendererAccessible()); 659 GetRendererAccessible());
660 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 660 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
661 HRESULT hr = document_accessible->accSelect( 661 HRESULT hr = document_accessible->accSelect(
662 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF)); 662 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF));
663 ASSERT_EQ(S_OK, hr); 663 ASSERT_EQ(S_OK, hr);
664 tree_updated_observer3.Wait(); 664 tree_updated_observer3.Wait();
665 665
666 // Check that the accessibility tree of the browser has been updated. 666 // Check that the accessibility tree of the browser has been updated.
667 SCOPED_TRACE("Check updated tree after focusing document again"); 667 SCOPED_TRACE("Check updated tree after focusing document again");
668 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 668 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
669 document_checker.CheckAccessible(GetRendererAccessible()); 669 document_checker.CheckAccessible(GetRendererAccessible());
670 } 670 }
671 671
672 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 672 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
673 TestNotificationValueChanged) { 673 TestNotificationValueChanged) {
674 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 674 content::WindowedNotificationObserver tree_updated_observer1(
675 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 675 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
676 content::NotificationService::AllSources()); 676 content::NotificationService::AllSources());
677 GURL tree_url("data:text/html,<body><input type='text' value='old value'/>" 677 GURL tree_url("data:text/html,<body><input type='text' value='old value'/>"
678 "</body>"); 678 "</body>");
679 browser()->OpenURL(OpenURLParams( 679 browser()->OpenURL(OpenURLParams(
680 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 680 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
681 false)); 681 false));
682 GetRendererAccessible(); 682 GetRendererAccessible();
683 tree_updated_observer1.Wait(); 683 tree_updated_observer1.Wait();
684 684
685 // Check the browser's copy of the renderer accessibility tree. 685 // Check the browser's copy of the renderer accessibility tree.
686 686
687 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value"); 687 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value");
688 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 688 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
689 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L""); 689 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L"");
690 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 690 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
691 body_checker.AppendExpectedChild(&text_field_checker); 691 body_checker.AppendExpectedChild(&text_field_checker);
692 document_checker.AppendExpectedChild(&body_checker); 692 document_checker.AppendExpectedChild(&body_checker);
693 document_checker.CheckAccessible(GetRendererAccessible()); 693 document_checker.CheckAccessible(GetRendererAccessible());
694 694
695 // Set the value of the text control 695 // Set the value of the text control
696 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( 696 content::WindowedNotificationObserver tree_updated_observer2(
697 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 697 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
698 content::NotificationService::AllSources()); 698 content::NotificationService::AllSources());
699 ExecuteScript(L"document.body.children[0].value='new value'"); 699 ExecuteScript(L"document.body.children[0].value='new value'");
700 tree_updated_observer2.Wait(); 700 tree_updated_observer2.Wait();
701 701
702 // Check that the accessibility tree of the browser has been updated. 702 // Check that the accessibility tree of the browser has been updated.
703 text_field_checker.SetExpectedValue(L"new value"); 703 text_field_checker.SetExpectedValue(L"new value");
704 document_checker.CheckAccessible(GetRendererAccessible()); 704 document_checker.CheckAccessible(GetRendererAccessible());
705 } 705 }
706 706
707 // This test verifies that the web content's accessibility tree is a 707 // This test verifies that the web content's accessibility tree is a
708 // descendant of the main browser window's accessibility tree, so that 708 // descendant of the main browser window's accessibility tree, so that
709 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's 709 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's
710 // accessibility support. 710 // accessibility support.
711 // 711 //
712 // If you made a change and this test now fails, check that the NativeViewHost 712 // If you made a change and this test now fails, check that the NativeViewHost
713 // that wraps the tab contents returns the IAccessible implementation 713 // that wraps the tab contents returns the IAccessible implementation
714 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible(). 714 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible().
715 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 715 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
716 ContainsRendererAccessibilityTree) { 716 ContainsRendererAccessibilityTree) {
717 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 717 content::WindowedNotificationObserver tree_updated_observer1(
718 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 718 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
719 content::NotificationService::AllSources()); 719 content::NotificationService::AllSources());
720 GURL tree_url("data:text/html,<html><head><title>MyDocument</title></head>" 720 GURL tree_url("data:text/html,<html><head><title>MyDocument</title></head>"
721 "<body>Content</body></html>"); 721 "<body>Content</body></html>");
722 browser()->OpenURL(OpenURLParams( 722 browser()->OpenURL(OpenURLParams(
723 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 723 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
724 false)); 724 false));
725 GetRendererAccessible(); 725 GetRendererAccessible();
726 tree_updated_observer1.Wait(); 726 tree_updated_observer1.Wait();
727 727
728 // Get the accessibility object for the browser window. 728 // Get the accessibility object for the browser window.
729 HWND browser_hwnd = browser()->window()->GetNativeWindow(); 729 HWND browser_hwnd = browser()->window()->GetNativeWindow();
730 base::win::ScopedComPtr<IAccessible> browser_accessible; 730 base::win::ScopedComPtr<IAccessible> browser_accessible;
731 HRESULT hr = AccessibleObjectFromWindow( 731 HRESULT hr = AccessibleObjectFromWindow(
732 browser_hwnd, 732 browser_hwnd,
733 OBJID_WINDOW, 733 OBJID_WINDOW,
734 IID_IAccessible, 734 IID_IAccessible,
735 reinterpret_cast<void**>(browser_accessible.Receive())); 735 reinterpret_cast<void**>(browser_accessible.Receive()));
736 ASSERT_EQ(S_OK, hr); 736 ASSERT_EQ(S_OK, hr);
737 737
738 bool found = false; 738 bool found = false;
739 RecursiveFindNodeInAccessibilityTree( 739 RecursiveFindNodeInAccessibilityTree(
740 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found); 740 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found);
741 ASSERT_EQ(found, true); 741 ASSERT_EQ(found, true);
742 } 742 }
743 743
744 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 744 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
745 TestToggleButtonRoleAndStates) { 745 TestToggleButtonRoleAndStates) {
746 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 746 content::WindowedNotificationObserver tree_updated_observer1(
747 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 747 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
748 content::NotificationService::AllSources()); 748 content::NotificationService::AllSources());
749 AccessibleChecker* button_checker; 749 AccessibleChecker* button_checker;
750 std::string button_html("data:text/html,"); 750 std::string button_html("data:text/html,");
751 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 751 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
752 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L""); 752 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L"");
753 document_checker.AppendExpectedChild(&body_checker); 753 document_checker.AppendExpectedChild(&body_checker);
754 754
755 // Temporary macro 755 // Temporary macro
756 #define ADD_BUTTON(html, ia2_role, state) \ 756 #define ADD_BUTTON(html, ia2_role, state) \
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 browser()->OpenURL(OpenURLParams(tree_url, Referrer(), CURRENT_TAB, 816 browser()->OpenURL(OpenURLParams(tree_url, Referrer(), CURRENT_TAB,
817 content::PAGE_TRANSITION_TYPED, false)); 817 content::PAGE_TRANSITION_TYPED, false));
818 GetRendererAccessible(); 818 GetRendererAccessible();
819 tree_updated_observer1.Wait(); 819 tree_updated_observer1.Wait();
820 820
821 document_checker.CheckAccessible(GetRendererAccessible()); 821 document_checker.CheckAccessible(GetRendererAccessible());
822 } 822 }
823 823
824 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 824 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
825 SupportsISimpleDOM) { 825 SupportsISimpleDOM) {
826 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 826 content::WindowedNotificationObserver tree_updated_observer1(
827 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 827 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
828 content::NotificationService::AllSources()); 828 content::NotificationService::AllSources());
829 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>"); 829 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
830 browser()->OpenURL(OpenURLParams( 830 browser()->OpenURL(OpenURLParams(
831 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 831 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
832 false)); 832 false));
833 GetRendererAccessible(); 833 GetRendererAccessible();
834 tree_updated_observer1.Wait(); 834 tree_updated_observer1.Wait();
835 835
836 // Get the IAccessible object for the document. 836 // Get the IAccessible object for the document.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 hr = checkbox_isimpledomnode->get_nodeInfo( 883 hr = checkbox_isimpledomnode->get_nodeInfo(
884 &node_name, &name_space_id, &node_value, &num_children, &unique_id, 884 &node_name, &name_space_id, &node_value, &num_children, &unique_id,
885 &node_type); 885 &node_type);
886 ASSERT_EQ(S_OK, hr); 886 ASSERT_EQ(S_OK, hr);
887 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str()); 887 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str());
888 EXPECT_EQ(NODETYPE_ELEMENT, node_type); 888 EXPECT_EQ(NODETYPE_ELEMENT, node_type);
889 EXPECT_EQ(0, num_children); 889 EXPECT_EQ(0, num_children);
890 } 890 }
891 891
892 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestRoleGroup) { 892 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestRoleGroup) {
893 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( 893 content::WindowedNotificationObserver tree_updated_observer1(
894 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 894 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
895 content::NotificationService::AllSources()); 895 content::NotificationService::AllSources());
896 GURL tree_url("data:text/html,<fieldset></fieldset><div role=group></div>"); 896 GURL tree_url("data:text/html,<fieldset></fieldset><div role=group></div>");
897 897
898 browser()->OpenURL(OpenURLParams( 898 browser()->OpenURL(OpenURLParams(
899 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 899 tree_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
900 false)); 900 false));
901 GetRendererAccessible(); 901 GetRendererAccessible();
902 tree_updated_observer1.Wait(); 902 tree_updated_observer1.Wait();
903 903
904 // Check the browser's copy of the renderer accessibility tree. 904 // Check the browser's copy of the renderer accessibility tree.
905 AccessibleChecker grouping1_checker(L"", ROLE_SYSTEM_GROUPING, L""); 905 AccessibleChecker grouping1_checker(L"", ROLE_SYSTEM_GROUPING, L"");
906 AccessibleChecker grouping2_checker(L"", ROLE_SYSTEM_GROUPING, L""); 906 AccessibleChecker grouping2_checker(L"", ROLE_SYSTEM_GROUPING, L"");
907 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 907 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
908 document_checker.AppendExpectedChild(&grouping1_checker); 908 document_checker.AppendExpectedChild(&grouping1_checker);
909 document_checker.AppendExpectedChild(&grouping2_checker); 909 document_checker.AppendExpectedChild(&grouping2_checker);
910 document_checker.CheckAccessible(GetRendererAccessible()); 910 document_checker.CheckAccessible(GetRendererAccessible());
911 } 911 }
912 } // namespace. 912 } // namespace.
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698