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

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

Issue 1231603009: Re-land: Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug 502311 and add test Created 5 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 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 d30c2582b6a71e277bd356d68ef4acb20824e689..c872ad55a875cd278168f2b4938435c1c1108298 100644
--- a/content/browser/accessibility/browser_accessibility_manager_unittest.cc
+++ b/content/browser/accessibility/browser_accessibility_manager_unittest.cc
@@ -989,4 +989,55 @@ TEST(BrowserAccessibilityManagerTest, NextPreviousInTreeOrder) {
ASSERT_EQ(root_accessible, manager->PreviousInTreeOrder(node2_accessible));
}
+TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash) {
+ // Create a really simple tree with one root node and one focused child.
+ ui::AXNodeData root;
+ root.id = 1;
+ root.role = ui::AX_ROLE_ROOT_WEB_AREA;
+ root.state = 0;
+ root.child_ids.push_back(2);
+
+ ui::AXNodeData node2;
+ node2.id = 2;
+ node2.state = 1 << ui::AX_STATE_FOCUSED;
+
+ scoped_ptr<BrowserAccessibilityManager> manager(
+ BrowserAccessibilityManager::Create(
+ MakeAXTreeUpdate(root, node2),
+ NULL,
dcheng 2015/07/15 00:58:10 Nit: nullptr
dmazzoni 2015/07/22 18:44:26 Done throughout this file.
+ 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<AccessibilityHostMsg_EventParams> events;
+ events.push_back(AccessibilityHostMsg_EventParams());
+ 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());
+
+ // Now replace the tree with a new tree consisting of a single root.
+ ui::AXNodeData root2;
+ root2.id = 3;
+ root2.role = ui::AX_ROLE_ROOT_WEB_AREA;
+ root2.state = 0;
+
+ std::vector<AccessibilityHostMsg_EventParams> events2;
+ events2.push_back(AccessibilityHostMsg_EventParams());
+ events2[0].update = MakeAXTreeUpdate(root2);
+ events2[0].id = -1;
+ events2[0].event_type = ui::AX_EVENT_NONE;
+ manager->OnAccessibilityEvents(events2);
+
+ // 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());
+}
+
} // namespace content
« no previous file with comments | « chrome/test/data/extensions/api_test/automation/tests/unit/unit.html ('k') | extensions/renderer/logging_native_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698