Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 window->GetRootView()->NotifyAccessibilityEvent( | 417 window->GetRootView()->NotifyAccessibilityEvent( |
| 418 ui::AX_EVENT_ALERT, true); | 418 ui::AX_EVENT_ALERT, true); |
| 419 base::MessageLoop::current()->RunUntilIdle(); | 419 base::MessageLoop::current()->RunUntilIdle(); |
| 420 | 420 |
| 421 EXPECT_EQ(1, control_event_count_); | 421 EXPECT_EQ(1, control_event_count_); |
| 422 EXPECT_EQ(kTypeWindow, last_control_type_); | 422 EXPECT_EQ(kTypeWindow, last_control_type_); |
| 423 | 423 |
| 424 window->CloseNow(); | 424 window->CloseNow(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 TEST_F(AccessibilityEventRouterViewsTest, AccessibilityFocusableView) { | |
| 428 // Create a view with a child view. | |
| 429 views::View* parent = new views::View(); | |
| 430 views::View* child = new views::View(); | |
| 431 parent->AddChildView(child); | |
| 432 | |
| 433 // Put the view in a window. | |
| 434 views::Widget* window = CreateWindowWithContents(parent); | |
| 435 | |
| 436 // This view should be either the current view or the next accessibility | |
| 437 // focusable view. | |
| 438 views::View* accessible_view; | |
| 439 | |
| 440 // Since the child view has no accessiblity focusable ancestors, this | |
| 441 // should still be the child view. | |
| 442 accessible_view = | |
|
sky
2014/07/25 21:12:31
nit: inline assignment so I don't have to worry ab
| |
| 443 AccessibilityEventRouterViews::FindFirstAccessibleAncestor(child); | |
| 444 EXPECT_EQ(accessible_view, child); | |
| 445 | |
| 446 // Now make the parent view accessiblity focusable. Calling | |
| 447 // FindFirstAccessibleAncestor() again on child shoudl return the parent | |
| 448 // view. | |
| 449 parent->SetAccessibilityFocusable(true); | |
| 450 accessible_view = | |
| 451 AccessibilityEventRouterViews::FindFirstAccessibleAncestor(child); | |
| 452 EXPECT_EQ(accessible_view, parent); | |
| 453 | |
| 454 window->CloseNow(); | |
| 455 } | |
| 456 | |
| 427 namespace { | 457 namespace { |
| 428 | 458 |
| 429 class SimpleMenuDelegate : public ui::SimpleMenuModel::Delegate { | 459 class SimpleMenuDelegate : public ui::SimpleMenuModel::Delegate { |
| 430 public: | 460 public: |
| 431 enum { | 461 enum { |
| 432 IDC_MENU_ITEM_1, | 462 IDC_MENU_ITEM_1, |
| 433 IDC_MENU_ITEM_2, | 463 IDC_MENU_ITEM_2, |
| 434 IDC_MENU_INVISIBLE, | 464 IDC_MENU_INVISIBLE, |
| 435 IDC_MENU_ITEM_3, | 465 IDC_MENU_ITEM_3, |
| 436 }; | 466 }; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 | 536 |
| 507 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( | 537 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( |
| 508 menu_container, | 538 menu_container, |
| 509 menu->GetMenuItemByID(kTestCases[i].command_id), | 539 menu->GetMenuItemByID(kTestCases[i].command_id), |
| 510 &index, | 540 &index, |
| 511 &count); | 541 &count); |
| 512 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; | 542 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; |
| 513 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; | 543 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; |
| 514 } | 544 } |
| 515 } | 545 } |
| OLD | NEW |