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

Unified Diff: content/browser/accessibility/browser_accessibility_manager_unittest.cc

Issue 1589623002: Keep track of accessibility focus across windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/browser_accessibility_manager_unittest.cc
diff --git a/content/browser/accessibility/browser_accessibility_manager_unittest.cc b/content/browser/accessibility/browser_accessibility_manager_unittest.cc
index c3a059652df282a2152bdb3883f5a9727e0d14b3..b051e923b2c2f9d3021e44b1049f16f6966d4df8 100644
--- a/content/browser/accessibility/browser_accessibility_manager_unittest.cc
+++ b/content/browser/accessibility/browser_accessibility_manager_unittest.cc
@@ -1102,27 +1102,18 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash) {
ui::AXNodeData node2;
node2.id = 2;
- node2.state = 1 << ui::AX_STATE_FOCUSED;
+ ui::AXTreeUpdate initial_state = MakeAXTreeUpdate(root, node2);
+ initial_state.has_tree_data = true;
+ initial_state.tree_data.focus_id = 2;
scoped_ptr<BrowserAccessibilityManager> manager(
BrowserAccessibilityManager::Create(
- MakeAXTreeUpdate(root, node2),
+ initial_state,
nullptr,
new CountedBrowserAccessibilityFactory()));
ASSERT_EQ(1, manager->GetRoot()->GetId());
- ASSERT_EQ(1, manager->GetFocus(manager->GetRoot())->GetId());
-
- // Send the focus event for node 2.
- std::vector<AXEventNotificationDetails> events;
- events.push_back(AXEventNotificationDetails());
- events[0].update = MakeAXTreeUpdate(node2);
- events[0].id = 2;
- events[0].event_type = ui::AX_EVENT_FOCUS;
- manager->OnAccessibilityEvents(events);
-
- ASSERT_EQ(1, manager->GetRoot()->GetId());
- ASSERT_EQ(2, manager->GetFocus(manager->GetRoot())->GetId());
+ ASSERT_EQ(2, manager->GetFocus()->GetId());
// Now replace the tree with a new tree consisting of a single root.
ui::AXNodeData root2;
@@ -1140,7 +1131,7 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash) {
// Make sure that the focused node was updated to the new root and
// that this doesn't crash.
ASSERT_EQ(3, manager->GetRoot()->GetId());
- ASSERT_EQ(3, manager->GetFocus(manager->GetRoot())->GetId());
+ ASSERT_EQ(3, manager->GetFocus()->GetId());
}
TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash2) {
@@ -1155,7 +1146,6 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash2) {
ui::AXNodeData node2;
node2.id = 2;
- node2.state = 1 << ui::AX_STATE_FOCUSED;
ui::AXNodeData node3;
node3.id = 3;
@@ -1165,25 +1155,17 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash2) {
node4.id = 4;
node4.state = 0;
+ ui::AXTreeUpdate initial_state = MakeAXTreeUpdate(root, node2, node3, node4);
+ initial_state.has_tree_data = true;
+ initial_state.tree_data.focus_id = 2;
scoped_ptr<BrowserAccessibilityManager> manager(
BrowserAccessibilityManager::Create(
- MakeAXTreeUpdate(root, node2, node3, node4),
+ initial_state,
nullptr,
new CountedBrowserAccessibilityFactory()));
ASSERT_EQ(1, manager->GetRoot()->GetId());
- ASSERT_EQ(1, manager->GetFocus(manager->GetRoot())->GetId());
-
- // Send the focus event for node 2.
- std::vector<AXEventNotificationDetails> events;
- events.push_back(AXEventNotificationDetails());
- events[0].update = MakeAXTreeUpdate(node2);
- events[0].id = 2;
- events[0].event_type = ui::AX_EVENT_FOCUS;
- manager->OnAccessibilityEvents(events);
-
- ASSERT_EQ(1, manager->GetRoot()->GetId());
- ASSERT_EQ(2, manager->GetFocus(manager->GetRoot())->GetId());
+ ASSERT_EQ(2, manager->GetFocus()->GetId());
// Now replace the tree with a new tree consisting of a single root.
ui::AXNodeData root2;
@@ -1203,7 +1185,7 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash2) {
// Make sure that the focused node was updated to the new root and
// that this doesn't crash.
ASSERT_EQ(3, manager->GetRoot()->GetId());
- ASSERT_EQ(3, manager->GetFocus(manager->GetRoot())->GetId());
+ ASSERT_EQ(3, manager->GetFocus()->GetId());
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698