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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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/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/renderer_host/render_widget_host_view_win.h" 12 #include "chrome/browser/renderer_host/render_widget_host_view_win.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "chrome/test/in_process_browser_test.h" 16 #include "chrome/test/in_process_browser_test.h"
17 #include "chrome/test/ui_test_utils.h" 17 #include "chrome/test/ui_test_utils.h"
18 #include "content/browser/renderer_host/render_view_host.h" 18 #include "content/browser/renderer_host/render_view_host.h"
19 #include "content/browser/tab_contents/tab_contents.h" 19 #include "content/browser/tab_contents/tab_contents.h"
20 #include "content/common/notification_type.h" 20 #include "content/common/content_notification_types.h"
21 #include "ia2_api_all.h" // Generated NOLINT 21 #include "ia2_api_all.h" // Generated NOLINT
22 #include "ISimpleDOMNode.h" // Generated NOLINT 22 #include "ISimpleDOMNode.h" // Generated NOLINT
23 23
24 using std::auto_ptr; 24 using std::auto_ptr;
25 using std::vector; 25 using std::vector;
26 using std::wstring; 26 using std::wstring;
27 27
28 namespace { 28 namespace {
29 29
30 class AccessibilityWinBrowserTest : public InProcessBrowserTest { 30 class AccessibilityWinBrowserTest : public InProcessBrowserTest {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // The initial accessible returned should have state STATE_SYSTEM_BUSY while 330 // The initial accessible returned should have state STATE_SYSTEM_BUSY while
331 // the accessibility tree is being requested from the renderer. 331 // the accessibility tree is being requested from the renderer.
332 AccessibleChecker document1_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 332 AccessibleChecker document1_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
333 document1_checker.SetExpectedState( 333 document1_checker.SetExpectedState(
334 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED | 334 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED |
335 STATE_SYSTEM_BUSY); 335 STATE_SYSTEM_BUSY);
336 document1_checker.CheckAccessible(GetRendererAccessible()); 336 document1_checker.CheckAccessible(GetRendererAccessible());
337 337
338 // Wait for the initial accessibility tree to load. Busy state should clear. 338 // Wait for the initial accessibility tree to load. Busy state should clear.
339 ui_test_utils::WaitForNotification( 339 ui_test_utils::WaitForNotification(
340 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 340 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
341 document1_checker.SetExpectedState( 341 document1_checker.SetExpectedState(
342 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); 342 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
343 document1_checker.CheckAccessible(GetRendererAccessible()); 343 document1_checker.CheckAccessible(GetRendererAccessible());
344 344
345 GURL tree_url( 345 GURL tree_url(
346 "data:text/html,<html><head><title>Accessibility Win Test</title></head>" 346 "data:text/html,<html><head><title>Accessibility Win Test</title></head>"
347 "<body><input type='button' value='push' /><input type='checkbox' />" 347 "<body><input type='button' value='push' /><input type='checkbox' />"
348 "</body></html>"); 348 "</body></html>");
349 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 349 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
350 ui_test_utils::WaitForNotification( 350 ui_test_utils::WaitForNotification(
351 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 351 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
352 352
353 // Check the browser's copy of the renderer accessibility tree. 353 // Check the browser's copy of the renderer accessibility tree.
354 AccessibleChecker button_checker(L"push", ROLE_SYSTEM_PUSHBUTTON, L"push"); 354 AccessibleChecker button_checker(L"push", ROLE_SYSTEM_PUSHBUTTON, L"push");
355 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L""); 355 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L"");
356 AccessibleChecker body_checker(L"", L"body", L""); 356 AccessibleChecker body_checker(L"", L"body", L"");
357 AccessibleChecker document2_checker( 357 AccessibleChecker document2_checker(
358 L"Accessibility Win Test", ROLE_SYSTEM_DOCUMENT, L""); 358 L"Accessibility Win Test", ROLE_SYSTEM_DOCUMENT, L"");
359 body_checker.AppendExpectedChild(&button_checker); 359 body_checker.AppendExpectedChild(&button_checker);
360 body_checker.AppendExpectedChild(&checkbox_checker); 360 body_checker.AppendExpectedChild(&checkbox_checker);
361 document2_checker.AppendExpectedChild(&body_checker); 361 document2_checker.AppendExpectedChild(&body_checker);
(...skipping 19 matching lines...) Expand all
381 ASSERT_EQ(E_FAIL, hr); 381 ASSERT_EQ(E_FAIL, hr);
382 } 382 }
383 383
384 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 384 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
385 TestNotificationActiveDescendantChanged) { 385 TestNotificationActiveDescendantChanged) {
386 GURL tree_url("data:text/html,<ul tabindex='-1' role='radiogroup'><li id='li'" 386 GURL tree_url("data:text/html,<ul tabindex='-1' role='radiogroup'><li id='li'"
387 ">li</li></ul>"); 387 ">li</li></ul>");
388 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 388 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
389 GetRendererAccessible(); 389 GetRendererAccessible();
390 ui_test_utils::WaitForNotification( 390 ui_test_utils::WaitForNotification(
391 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 391 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
392 392
393 // Check the browser's copy of the renderer accessibility tree. 393 // Check the browser's copy of the renderer accessibility tree.
394 AccessibleChecker list_marker_checker(L"", ROLE_SYSTEM_LISTITEM, L"\x2022"); 394 AccessibleChecker list_marker_checker(L"", ROLE_SYSTEM_LISTITEM, L"\x2022");
395 AccessibleChecker static_text_checker(L"li", ROLE_SYSTEM_TEXT, L""); 395 AccessibleChecker static_text_checker(L"li", ROLE_SYSTEM_TEXT, L"");
396 AccessibleChecker list_item_checker(L"", ROLE_SYSTEM_LISTITEM, L""); 396 AccessibleChecker list_item_checker(L"", ROLE_SYSTEM_LISTITEM, L"");
397 list_item_checker.SetExpectedState( 397 list_item_checker.SetExpectedState(
398 STATE_SYSTEM_READONLY); 398 STATE_SYSTEM_READONLY);
399 AccessibleChecker radio_group_checker(L"", ROLE_SYSTEM_GROUPING, L""); 399 AccessibleChecker radio_group_checker(L"", ROLE_SYSTEM_GROUPING, L"");
400 radio_group_checker.SetExpectedState( 400 radio_group_checker.SetExpectedState(
401 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY); 401 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
402 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 402 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
403 list_item_checker.AppendExpectedChild(&list_marker_checker); 403 list_item_checker.AppendExpectedChild(&list_marker_checker);
404 list_item_checker.AppendExpectedChild(&static_text_checker); 404 list_item_checker.AppendExpectedChild(&static_text_checker);
405 radio_group_checker.AppendExpectedChild(&list_item_checker); 405 radio_group_checker.AppendExpectedChild(&list_item_checker);
406 document_checker.AppendExpectedChild(&radio_group_checker); 406 document_checker.AppendExpectedChild(&radio_group_checker);
407 document_checker.CheckAccessible(GetRendererAccessible()); 407 document_checker.CheckAccessible(GetRendererAccessible());
408 408
409 // Set focus to the radio group. 409 // Set focus to the radio group.
410 ExecuteScript(L"document.body.children[0].focus()"); 410 ExecuteScript(L"document.body.children[0].focus()");
411 ui_test_utils::WaitForNotification( 411 ui_test_utils::WaitForNotification(
412 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 412 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
413 413
414 // Check that the accessibility tree of the browser has been updated. 414 // Check that the accessibility tree of the browser has been updated.
415 radio_group_checker.SetExpectedState( 415 radio_group_checker.SetExpectedState(
416 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 416 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
417 document_checker.CheckAccessible(GetRendererAccessible()); 417 document_checker.CheckAccessible(GetRendererAccessible());
418 418
419 // Set the active descendant of the radio group 419 // Set the active descendant of the radio group
420 ExecuteScript( 420 ExecuteScript(
421 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); 421 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')");
422 ui_test_utils::WaitForNotification( 422 ui_test_utils::WaitForNotification(
423 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 423 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
424 424
425 // Check that the accessibility tree of the browser has been updated. 425 // Check that the accessibility tree of the browser has been updated.
426 list_item_checker.SetExpectedState( 426 list_item_checker.SetExpectedState(
427 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 427 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
428 radio_group_checker.SetExpectedState( 428 radio_group_checker.SetExpectedState(
429 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY); 429 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
430 document_checker.CheckAccessible(GetRendererAccessible()); 430 document_checker.CheckAccessible(GetRendererAccessible());
431 } 431 }
432 432
433 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 433 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
434 TestNotificationCheckedStateChanged) { 434 TestNotificationCheckedStateChanged) {
435 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>"); 435 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
436 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 436 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
437 GetRendererAccessible(); 437 GetRendererAccessible();
438 ui_test_utils::WaitForNotification( 438 ui_test_utils::WaitForNotification(
439 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 439 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
440 440
441 // Check the browser's copy of the renderer accessibility tree. 441 // Check the browser's copy of the renderer accessibility tree.
442 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L""); 442 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L"");
443 checkbox_checker.SetExpectedState( 443 checkbox_checker.SetExpectedState(
444 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY); 444 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
445 AccessibleChecker body_checker(L"", L"body", L""); 445 AccessibleChecker body_checker(L"", L"body", L"");
446 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 446 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
447 body_checker.AppendExpectedChild(&checkbox_checker); 447 body_checker.AppendExpectedChild(&checkbox_checker);
448 document_checker.AppendExpectedChild(&body_checker); 448 document_checker.AppendExpectedChild(&body_checker);
449 document_checker.CheckAccessible(GetRendererAccessible()); 449 document_checker.CheckAccessible(GetRendererAccessible());
450 450
451 // Check the checkbox. 451 // Check the checkbox.
452 ExecuteScript(L"document.body.children[0].checked=true"); 452 ExecuteScript(L"document.body.children[0].checked=true");
453 ui_test_utils::WaitForNotification( 453 ui_test_utils::WaitForNotification(
454 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 454 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
455 455
456 // Check that the accessibility tree of the browser has been updated. 456 // Check that the accessibility tree of the browser has been updated.
457 checkbox_checker.SetExpectedState( 457 checkbox_checker.SetExpectedState(
458 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY); 458 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
459 document_checker.CheckAccessible(GetRendererAccessible()); 459 document_checker.CheckAccessible(GetRendererAccessible());
460 } 460 }
461 461
462 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 462 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
463 TestNotificationChildrenChanged) { 463 TestNotificationChildrenChanged) {
464 // The role attribute causes the node to be in the accessibility tree. 464 // The role attribute causes the node to be in the accessibility tree.
465 GURL tree_url( 465 GURL tree_url(
466 "data:text/html,<body role=group></body>"); 466 "data:text/html,<body role=group></body>");
467 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 467 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
468 GetRendererAccessible(); 468 GetRendererAccessible();
469 ui_test_utils::WaitForNotification( 469 ui_test_utils::WaitForNotification(
470 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 470 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
471 471
472 // Check the browser's copy of the renderer accessibility tree. 472 // Check the browser's copy of the renderer accessibility tree.
473 AccessibleChecker body_checker(L"", L"body", L""); 473 AccessibleChecker body_checker(L"", L"body", L"");
474 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 474 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
475 document_checker.AppendExpectedChild(&body_checker); 475 document_checker.AppendExpectedChild(&body_checker);
476 document_checker.CheckAccessible(GetRendererAccessible()); 476 document_checker.CheckAccessible(GetRendererAccessible());
477 477
478 // Change the children of the document body. 478 // Change the children of the document body.
479 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); 479 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'");
480 ui_test_utils::WaitForNotification( 480 ui_test_utils::WaitForNotification(
481 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 481 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
482 482
483 // Check that the accessibility tree of the browser has been updated. 483 // Check that the accessibility tree of the browser has been updated.
484 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L""); 484 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L"");
485 body_checker.AppendExpectedChild(&text_checker); 485 body_checker.AppendExpectedChild(&text_checker);
486 document_checker.CheckAccessible(GetRendererAccessible()); 486 document_checker.CheckAccessible(GetRendererAccessible());
487 } 487 }
488 488
489 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 489 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
490 TestNotificationChildrenChanged2) { 490 TestNotificationChildrenChanged2) {
491 // The role attribute causes the node to be in the accessibility tree. 491 // The role attribute causes the node to be in the accessibility tree.
492 GURL tree_url( 492 GURL tree_url(
493 "data:text/html,<div role=group style='visibility: hidden'>text" 493 "data:text/html,<div role=group style='visibility: hidden'>text"
494 "</div>"); 494 "</div>");
495 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 495 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
496 GetRendererAccessible(); 496 GetRendererAccessible();
497 ui_test_utils::WaitForNotification( 497 ui_test_utils::WaitForNotification(
498 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 498 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
499 499
500 // Check the accessible tree of the browser. 500 // Check the accessible tree of the browser.
501 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 501 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
502 document_checker.CheckAccessible(GetRendererAccessible()); 502 document_checker.CheckAccessible(GetRendererAccessible());
503 503
504 // Change the children of the document body. 504 // Change the children of the document body.
505 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); 505 ExecuteScript(L"document.body.children[0].style.visibility='visible'");
506 ui_test_utils::WaitForNotification( 506 ui_test_utils::WaitForNotification(
507 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 507 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
508 508
509 // Check that the accessibility tree of the browser has been updated. 509 // Check that the accessibility tree of the browser has been updated.
510 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L""); 510 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L"");
511 AccessibleChecker div_checker(L"", L"div", L""); 511 AccessibleChecker div_checker(L"", L"div", L"");
512 document_checker.AppendExpectedChild(&div_checker); 512 document_checker.AppendExpectedChild(&div_checker);
513 div_checker.AppendExpectedChild(&static_text_checker); 513 div_checker.AppendExpectedChild(&static_text_checker);
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 TestNotificationFocusChanged) { 518 TestNotificationFocusChanged) {
519 // The role attribute causes the node to be in the accessibility tree. 519 // The role attribute causes the node to be in the accessibility tree.
520 GURL tree_url( 520 GURL tree_url(
521 "data:text/html,<div role=group tabindex='-1'></div>"); 521 "data:text/html,<div role=group tabindex='-1'></div>");
522 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 522 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
523 GetRendererAccessible(); 523 GetRendererAccessible();
524 ui_test_utils::WaitForNotification( 524 ui_test_utils::WaitForNotification(
525 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 525 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
526 526
527 // Check the browser's copy of the renderer accessibility tree. 527 // Check the browser's copy of the renderer accessibility tree.
528 AccessibleChecker div_checker(L"", L"div", L""); 528 AccessibleChecker div_checker(L"", L"div", L"");
529 div_checker.SetExpectedState( 529 div_checker.SetExpectedState(
530 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_READONLY); 530 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_READONLY);
531 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 531 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
532 document_checker.AppendExpectedChild(&div_checker); 532 document_checker.AppendExpectedChild(&div_checker);
533 document_checker.CheckAccessible(GetRendererAccessible()); 533 document_checker.CheckAccessible(GetRendererAccessible());
534 534
535 // Focus the div in the document 535 // Focus the div in the document
536 ExecuteScript(L"document.body.children[0].focus()"); 536 ExecuteScript(L"document.body.children[0].focus()");
537 ui_test_utils::WaitForNotification( 537 ui_test_utils::WaitForNotification(
538 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 538 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
539 539
540 // Check that the accessibility tree of the browser has been updated. 540 // Check that the accessibility tree of the browser has been updated.
541 div_checker.SetExpectedState( 541 div_checker.SetExpectedState(
542 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 542 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
543 document_checker.CheckAccessible(GetRendererAccessible()); 543 document_checker.CheckAccessible(GetRendererAccessible());
544 544
545 // Focus the document accessible. This will un-focus the current node. 545 // Focus the document accessible. This will un-focus the current node.
546 base::win::ScopedComPtr<IAccessible> document_accessible( 546 base::win::ScopedComPtr<IAccessible> document_accessible(
547 GetRendererAccessible()); 547 GetRendererAccessible());
548 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 548 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
549 HRESULT hr = document_accessible->accSelect( 549 HRESULT hr = document_accessible->accSelect(
550 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF)); 550 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF));
551 ASSERT_EQ(S_OK, hr); 551 ASSERT_EQ(S_OK, hr);
552 ui_test_utils::WaitForNotification( 552 ui_test_utils::WaitForNotification(
553 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 553 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
554 554
555 // Check that the accessibility tree of the browser has been updated. 555 // Check that the accessibility tree of the browser has been updated.
556 div_checker.SetExpectedState( 556 div_checker.SetExpectedState(
557 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY); 557 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
558 document_checker.CheckAccessible(GetRendererAccessible()); 558 document_checker.CheckAccessible(GetRendererAccessible());
559 } 559 }
560 560
561 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 561 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
562 TestNotificationValueChanged) { 562 TestNotificationValueChanged) {
563 GURL tree_url("data:text/html,<body><input type='text' value='old value'/>" 563 GURL tree_url("data:text/html,<body><input type='text' value='old value'/>"
564 "</body>"); 564 "</body>");
565 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 565 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
566 GetRendererAccessible(); 566 GetRendererAccessible();
567 ui_test_utils::WaitForNotification( 567 ui_test_utils::WaitForNotification(
568 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 568 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
569 569
570 // Check the browser's copy of the renderer accessibility tree. 570 // Check the browser's copy of the renderer accessibility tree.
571 571
572 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value"); 572 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value");
573 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 573 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
574 AccessibleChecker body_checker(L"", L"body", L""); 574 AccessibleChecker body_checker(L"", L"body", L"");
575 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 575 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
576 body_checker.AppendExpectedChild(&text_field_checker); 576 body_checker.AppendExpectedChild(&text_field_checker);
577 document_checker.AppendExpectedChild(&body_checker); 577 document_checker.AppendExpectedChild(&body_checker);
578 document_checker.CheckAccessible(GetRendererAccessible()); 578 document_checker.CheckAccessible(GetRendererAccessible());
579 579
580 // Set the value of the text control 580 // Set the value of the text control
581 ExecuteScript(L"document.body.children[0].value='new value'"); 581 ExecuteScript(L"document.body.children[0].value='new value'");
582 ui_test_utils::WaitForNotification( 582 ui_test_utils::WaitForNotification(
583 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 583 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
584 584
585 // Check that the accessibility tree of the browser has been updated. 585 // Check that the accessibility tree of the browser has been updated.
586 text_field_checker.SetExpectedValue(L"new value"); 586 text_field_checker.SetExpectedValue(L"new value");
587 document_checker.CheckAccessible(GetRendererAccessible()); 587 document_checker.CheckAccessible(GetRendererAccessible());
588 } 588 }
589 589
590 // This test verifies that the web content's accessibility tree is a 590 // This test verifies that the web content's accessibility tree is a
591 // descendant of the main browser window's accessibility tree, so that 591 // descendant of the main browser window's accessibility tree, so that
592 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's 592 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's
593 // accessibility support. 593 // accessibility support.
594 // 594 //
595 // If you made a change and this test now fails, check that the NativeViewHost 595 // If you made a change and this test now fails, check that the NativeViewHost
596 // that wraps the tab contents returns the IAccessible implementation 596 // that wraps the tab contents returns the IAccessible implementation
597 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible(). 597 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible().
598 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 598 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
599 ContainsRendererAccessibilityTree) { 599 ContainsRendererAccessibilityTree) {
600 GURL tree_url("data:text/html,<html><head><title>MyDocument</title></head>" 600 GURL tree_url("data:text/html,<html><head><title>MyDocument</title></head>"
601 "<body>Content</body></html>"); 601 "<body>Content</body></html>");
602 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 602 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
603 GetRendererAccessible(); 603 GetRendererAccessible();
604 ui_test_utils::WaitForNotification( 604 ui_test_utils::WaitForNotification(
605 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 605 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
606 606
607 // Get the accessibility object for the browser window. 607 // Get the accessibility object for the browser window.
608 HWND browser_hwnd = browser()->window()->GetNativeHandle(); 608 HWND browser_hwnd = browser()->window()->GetNativeHandle();
609 base::win::ScopedComPtr<IAccessible> browser_accessible; 609 base::win::ScopedComPtr<IAccessible> browser_accessible;
610 HRESULT hr = AccessibleObjectFromWindow( 610 HRESULT hr = AccessibleObjectFromWindow(
611 browser_hwnd, 611 browser_hwnd,
612 OBJID_WINDOW, 612 OBJID_WINDOW,
613 IID_IAccessible, 613 IID_IAccessible,
614 reinterpret_cast<void**>(browser_accessible.Receive())); 614 reinterpret_cast<void**>(browser_accessible.Receive()));
615 ASSERT_EQ(S_OK, hr); 615 ASSERT_EQ(S_OK, hr);
616 616
617 bool found = false; 617 bool found = false;
618 RecursiveFindNodeInAccessibilityTree( 618 RecursiveFindNodeInAccessibilityTree(
619 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found); 619 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found);
620 ASSERT_EQ(found, true); 620 ASSERT_EQ(found, true);
621 } 621 }
622 622
623 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 623 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
624 SupportsISimpleDOM) { 624 SupportsISimpleDOM) {
625 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>"); 625 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
626 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 626 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
627 GetRendererAccessible(); 627 GetRendererAccessible();
628 ui_test_utils::WaitForNotification( 628 ui_test_utils::WaitForNotification(
629 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 629 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
630 630
631 // Get the IAccessible object for the document. 631 // Get the IAccessible object for the document.
632 base::win::ScopedComPtr<IAccessible> document_accessible( 632 base::win::ScopedComPtr<IAccessible> document_accessible(
633 GetRendererAccessible()); 633 GetRendererAccessible());
634 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 634 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
635 635
636 // Get the ISimpleDOM object for the document. 636 // Get the ISimpleDOM object for the document.
637 base::win::ScopedComPtr<IServiceProvider> service_provider; 637 base::win::ScopedComPtr<IServiceProvider> service_provider;
638 HRESULT hr = static_cast<IAccessible*>(document_accessible)->QueryInterface( 638 HRESULT hr = static_cast<IAccessible*>(document_accessible)->QueryInterface(
639 service_provider.Receive()); 639 service_provider.Receive());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 ASSERT_EQ(S_OK, hr); 677 ASSERT_EQ(S_OK, hr);
678 hr = checkbox_isimpledomnode->get_nodeInfo( 678 hr = checkbox_isimpledomnode->get_nodeInfo(
679 &node_name, &name_space_id, &node_value, &num_children, &unique_id, 679 &node_name, &name_space_id, &node_value, &num_children, &unique_id,
680 &node_type); 680 &node_type);
681 ASSERT_EQ(S_OK, hr); 681 ASSERT_EQ(S_OK, hr);
682 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str()); 682 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str());
683 EXPECT_EQ(NODETYPE_ELEMENT, node_type); 683 EXPECT_EQ(NODETYPE_ELEMENT, node_type);
684 EXPECT_EQ(0, num_children); 684 EXPECT_EQ(0, num_children);
685 } 685 }
686 } // namespace. 686 } // 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