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

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

Issue 7745035: Add a big grab bag of missing web accessibility functionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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/browser_accessibility_manager_unittest.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"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 content::NOTIFICATION_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_TEXT, 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(STATE_SYSTEM_FOCUSABLE);
401 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
402 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 401 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
403 list_item_checker.AppendExpectedChild(&list_marker_checker); 402 list_item_checker.AppendExpectedChild(&list_marker_checker);
404 list_item_checker.AppendExpectedChild(&static_text_checker); 403 list_item_checker.AppendExpectedChild(&static_text_checker);
405 radio_group_checker.AppendExpectedChild(&list_item_checker); 404 radio_group_checker.AppendExpectedChild(&list_item_checker);
406 document_checker.AppendExpectedChild(&radio_group_checker); 405 document_checker.AppendExpectedChild(&radio_group_checker);
407 document_checker.CheckAccessible(GetRendererAccessible()); 406 document_checker.CheckAccessible(GetRendererAccessible());
408 407
409 // Set focus to the radio group. 408 // Set focus to the radio group.
410 ExecuteScript(L"document.body.children[0].focus()"); 409 ExecuteScript(L"document.body.children[0].focus()");
411 ui_test_utils::WaitForNotification( 410 ui_test_utils::WaitForNotification(
412 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 411 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
413 412
414 // Check that the accessibility tree of the browser has been updated. 413 // Check that the accessibility tree of the browser has been updated.
415 radio_group_checker.SetExpectedState( 414 radio_group_checker.SetExpectedState(
416 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 415 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED);
417 document_checker.CheckAccessible(GetRendererAccessible()); 416 document_checker.CheckAccessible(GetRendererAccessible());
418 417
419 // Set the active descendant of the radio group 418 // Set the active descendant of the radio group
420 ExecuteScript( 419 ExecuteScript(
421 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); 420 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')");
422 ui_test_utils::WaitForNotification( 421 ui_test_utils::WaitForNotification(
423 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 422 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
424 423
425 // Check that the accessibility tree of the browser has been updated. 424 // Check that the accessibility tree of the browser has been updated.
426 list_item_checker.SetExpectedState( 425 list_item_checker.SetExpectedState(
427 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 426 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
428 radio_group_checker.SetExpectedState( 427 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
429 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
430 document_checker.CheckAccessible(GetRendererAccessible()); 428 document_checker.CheckAccessible(GetRendererAccessible());
431 } 429 }
432 430
433 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 431 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
434 TestNotificationCheckedStateChanged) { 432 TestNotificationCheckedStateChanged) {
435 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>"); 433 GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
436 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 434 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
437 GetRendererAccessible(); 435 GetRendererAccessible();
438 ui_test_utils::WaitForNotification( 436 ui_test_utils::WaitForNotification(
439 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 437 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
440 438
441 // Check the browser's copy of the renderer accessibility tree. 439 // Check the browser's copy of the renderer accessibility tree.
442 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L""); 440 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L"");
443 checkbox_checker.SetExpectedState( 441 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
444 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
445 AccessibleChecker body_checker(L"", L"body", L""); 442 AccessibleChecker body_checker(L"", L"body", L"");
446 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); 443 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
447 body_checker.AppendExpectedChild(&checkbox_checker); 444 body_checker.AppendExpectedChild(&checkbox_checker);
448 document_checker.AppendExpectedChild(&body_checker); 445 document_checker.AppendExpectedChild(&body_checker);
449 document_checker.CheckAccessible(GetRendererAccessible()); 446 document_checker.CheckAccessible(GetRendererAccessible());
450 447
451 // Check the checkbox. 448 // Check the checkbox.
452 ExecuteScript(L"document.body.children[0].checked=true"); 449 ExecuteScript(L"document.body.children[0].checked=true");
453 ui_test_utils::WaitForNotification( 450 ui_test_utils::WaitForNotification(
454 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); 451 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
455 452
456 // Check that the accessibility tree of the browser has been updated. 453 // Check that the accessibility tree of the browser has been updated.
457 checkbox_checker.SetExpectedState( 454 checkbox_checker.SetExpectedState(
458 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY); 455 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE);
459 document_checker.CheckAccessible(GetRendererAccessible()); 456 document_checker.CheckAccessible(GetRendererAccessible());
460 } 457 }
461 458
462 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 459 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
463 TestNotificationChildrenChanged) { 460 TestNotificationChildrenChanged) {
464 // The role attribute causes the node to be in the accessibility tree. 461 // The role attribute causes the node to be in the accessibility tree.
465 GURL tree_url( 462 GURL tree_url(
466 "data:text/html,<body role=group></body>"); 463 "data:text/html,<body role=group></body>");
467 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 464 browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
468 GetRendererAccessible(); 465 GetRendererAccessible();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 ASSERT_EQ(S_OK, hr); 674 ASSERT_EQ(S_OK, hr);
678 hr = checkbox_isimpledomnode->get_nodeInfo( 675 hr = checkbox_isimpledomnode->get_nodeInfo(
679 &node_name, &name_space_id, &node_value, &num_children, &unique_id, 676 &node_name, &name_space_id, &node_value, &num_children, &unique_id,
680 &node_type); 677 &node_type);
681 ASSERT_EQ(S_OK, hr); 678 ASSERT_EQ(S_OK, hr);
682 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str()); 679 EXPECT_STREQ(L"input", wstring(node_name, SysStringLen(node_name)).c_str());
683 EXPECT_EQ(NODETYPE_ELEMENT, node_type); 680 EXPECT_EQ(NODETYPE_ELEMENT, node_type);
684 EXPECT_EQ(0, num_children); 681 EXPECT_EQ(0, num_children);
685 } 682 }
686 } // namespace. 683 } // namespace.
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/accessibility/browser_accessibility_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698