Index: ui/accessibility/platform/test_ax_node_wrapper.cc |
diff --git a/ui/accessibility/platform/test_ax_node_wrapper.cc b/ui/accessibility/platform/test_ax_node_wrapper.cc |
index d1e33c778fa2ea373d63abbddb9fb5b47708c015..e0b153ef51200e36f36dc6639d43c6e89398ccfc 100644 |
--- a/ui/accessibility/platform/test_ax_node_wrapper.cc |
+++ b/ui/accessibility/platform/test_ax_node_wrapper.cc |
@@ -141,7 +141,28 @@ gfx::NativeViewAccessible TestAXNodeWrapper::GetFocus() { |
return nullptr; |
} |
+// Walk the AXTree and ensure that all wrappers are created |
+void TestAXNodeWrapper::BuildAllWrappers(AXTree* tree, AXNode* node) { |
+ for (int i = 0; i < node->child_count(); i++) { |
+ auto* child = node->children()[i]; |
+ TestAXNodeWrapper::GetOrCreate(tree, child); |
+ |
+ BuildAllWrappers(tree, child); |
+ } |
+} |
+ |
AXPlatformNode* TestAXNodeWrapper::GetFromNodeID(int32_t id) { |
+ // Force creating all of the wrappers for this tree. |
+ BuildAllWrappers(tree_, node_); |
+ |
+ for (auto it = g_node_to_wrapper_map.begin(); |
+ it != g_node_to_wrapper_map.end(); ++it) { |
+ AXNode* node = it->first; |
+ if (node->id() == id) { |
+ TestAXNodeWrapper* wrapper = it->second; |
+ return wrapper->ax_platform_node(); |
+ } |
+ } |
return nullptr; |
} |