Index: content/browser/accessibility/cross_platform_accessibility_browsertest.cc |
diff --git a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc |
index f0aa13ff92108eb65bd6b295f93728d3d35199b0..41851b706dae932a28eebb42b83a9628e4218ee8 100644 |
--- a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc |
+++ b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc |
@@ -14,6 +14,7 @@ |
#include "content/test/accessibility_browser_test_utils.h" |
#include "content/test/content_browser_test.h" |
#include "content/test/content_browser_test_utils.h" |
+#include "ui/accessibility/ax_node.h" |
#if defined(OS_WIN) |
#include <atlbase.h> |
@@ -37,21 +38,21 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { |
// Tell the renderer to send an accessibility tree, then wait for the |
// notification that it's been received. |
- const AccessibilityNodeDataTreeNode& GetAccessibilityNodeDataTree( |
+ const ui::AXTree& GetAXTree( |
AccessibilityMode accessibility_mode = AccessibilityModeComplete) { |
AccessibilityNotificationWaiter waiter( |
- shell(), accessibility_mode, blink::WebAXEventLayoutComplete); |
+ shell(), accessibility_mode, ui::AX_EVENT_LAYOUT_COMPLETE); |
waiter.WaitForNotification(); |
- return waiter.GetAccessibilityNodeDataTree(); |
+ return waiter.GetAXTree(); |
} |
// Make sure each node in the tree has an unique id. |
void RecursiveAssertUniqueIds( |
- const AccessibilityNodeDataTreeNode& node, base::hash_set<int>* ids) { |
- ASSERT_TRUE(ids->find(node.id) == ids->end()); |
- ids->insert(node.id); |
- for (size_t i = 0; i < node.children.size(); i++) |
- RecursiveAssertUniqueIds(node.children[i], ids); |
+ const ui::AXNode* node, base::hash_set<int>* ids) { |
+ ASSERT_TRUE(ids->find(node->id()) == ids->end()); |
+ ids->insert(node->id()); |
+ for (int i = 0; i < node->child_count(); i++) |
+ RecursiveAssertUniqueIds(node->ChildAtIndex(i), ids); |
} |
// ContentBrowserTest |
@@ -59,12 +60,12 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { |
virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; |
protected: |
- std::string GetAttr(const AccessibilityNodeData& node, |
- const AccessibilityNodeData::StringAttribute attr); |
- int GetIntAttr(const AccessibilityNodeData& node, |
- const AccessibilityNodeData::IntAttribute attr); |
- bool GetBoolAttr(const AccessibilityNodeData& node, |
- const AccessibilityNodeData::BoolAttribute attr); |
+ std::string GetAttr(const ui::AXNode* node, |
+ const ui::AXStringAttribute attr); |
+ int GetIntAttr(const ui::AXNode* node, |
+ const ui::AXIntAttribute attr); |
+ bool GetBoolAttr(const ui::AXNode* node, |
+ const ui::AXBoolAttribute attr); |
private: |
#if defined(OS_WIN) |
@@ -88,38 +89,41 @@ CrossPlatformAccessibilityBrowserTest::TearDownInProcessBrowserTestFixture() { |
#endif |
} |
-// Convenience method to get the value of a particular AccessibilityNodeData |
-// node attribute as a UTF-8 string. |
+// Convenience method to get the value of a particular AXNode |
+// attribute as a UTF-8 string. |
std::string CrossPlatformAccessibilityBrowserTest::GetAttr( |
- const AccessibilityNodeData& node, |
- const AccessibilityNodeData::StringAttribute attr) { |
- for (size_t i = 0; i < node.string_attributes.size(); ++i) { |
- if (node.string_attributes[i].first == attr) |
- return node.string_attributes[i].second; |
+ const ui::AXNode* node, |
+ const ui::AXStringAttribute attr) { |
+ const ui::AXNodeData& data = node->data(); |
+ for (size_t i = 0; i < data.string_attributes.size(); ++i) { |
+ if (data.string_attributes[i].first == attr) |
+ return data.string_attributes[i].second; |
} |
return std::string(); |
} |
-// Convenience method to get the value of a particular AccessibilityNodeData |
-// node integer attribute. |
+// Convenience method to get the value of a particular AXNode |
+// integer attribute. |
int CrossPlatformAccessibilityBrowserTest::GetIntAttr( |
- const AccessibilityNodeData& node, |
- const AccessibilityNodeData::IntAttribute attr) { |
- for (size_t i = 0; i < node.int_attributes.size(); ++i) { |
- if (node.int_attributes[i].first == attr) |
- return node.int_attributes[i].second; |
+ const ui::AXNode* node, |
+ const ui::AXIntAttribute attr) { |
+ const ui::AXNodeData& data = node->data(); |
+ for (size_t i = 0; i < data.int_attributes.size(); ++i) { |
+ if (data.int_attributes[i].first == attr) |
+ return data.int_attributes[i].second; |
} |
return -1; |
} |
-// Convenience method to get the value of a particular AccessibilityNodeData |
-// node boolean attribute. |
+// Convenience method to get the value of a particular AXNode |
+// boolean attribute. |
bool CrossPlatformAccessibilityBrowserTest::GetBoolAttr( |
- const AccessibilityNodeData& node, |
- const AccessibilityNodeData::BoolAttribute attr) { |
- for (size_t i = 0; i < node.bool_attributes.size(); ++i) { |
- if (node.bool_attributes[i].first == attr) |
- return node.bool_attributes[i].second; |
+ const ui::AXNode* node, |
+ const ui::AXBoolAttribute attr) { |
+ const ui::AXNodeData& data = node->data(); |
+ for (size_t i = 0; i < data.bool_attributes.size(); ++i) { |
+ if (data.bool_attributes[i].first == attr) |
+ return data.bool_attributes[i].second; |
} |
return false; |
} |
@@ -136,62 +140,63 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
"</body></html>"; |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
// Check properties of the root element of the tree. |
EXPECT_STREQ(url_str, |
- GetAttr(tree, AccessibilityNodeData::ATTR_DOC_URL).c_str()); |
+ GetAttr(root, ui::AX_ATTR_DOC_URL).c_str()); |
EXPECT_STREQ( |
"Accessibility Test", |
- GetAttr(tree, AccessibilityNodeData::ATTR_DOC_TITLE).c_str()); |
+ GetAttr(root, ui::AX_ATTR_DOC_TITLE).c_str()); |
EXPECT_STREQ( |
- "html", GetAttr(tree, AccessibilityNodeData::ATTR_DOC_DOCTYPE).c_str()); |
+ "html", GetAttr(root, ui::AX_ATTR_DOC_DOCTYPE).c_str()); |
EXPECT_STREQ( |
"text/html", |
- GetAttr(tree, AccessibilityNodeData::ATTR_DOC_MIMETYPE).c_str()); |
+ GetAttr(root, ui::AX_ATTR_DOC_MIMETYPE).c_str()); |
EXPECT_STREQ( |
"Accessibility Test", |
- GetAttr(tree, AccessibilityNodeData::ATTR_NAME).c_str()); |
- EXPECT_EQ(blink::WebAXRoleRootWebArea, tree.role); |
+ GetAttr(root, ui::AX_ATTR_NAME).c_str()); |
+ EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->data().role); |
// Check properites of the BODY element. |
- ASSERT_EQ(1U, tree.children.size()); |
- const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
- EXPECT_EQ(blink::WebAXRoleGroup, body.role); |
+ ASSERT_EQ(1, root->child_count()); |
+ const ui::AXNode* body = root->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_GROUP, body->data().role); |
EXPECT_STREQ("body", |
- GetAttr(body, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
+ GetAttr(body, ui::AX_ATTR_HTML_TAG).c_str()); |
EXPECT_STREQ("block", |
- GetAttr(body, AccessibilityNodeData::ATTR_DISPLAY).c_str()); |
+ GetAttr(body, ui::AX_ATTR_DISPLAY).c_str()); |
// Check properties of the two children of the BODY element. |
- ASSERT_EQ(2U, body.children.size()); |
+ ASSERT_EQ(2, body->child_count()); |
- const AccessibilityNodeDataTreeNode& button = body.children[0]; |
- EXPECT_EQ(blink::WebAXRoleButton, button.role); |
+ const ui::AXNode* button = body->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_BUTTON, button->data().role); |
EXPECT_STREQ( |
- "input", GetAttr(button, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
+ "input", GetAttr(button, ui::AX_ATTR_HTML_TAG).c_str()); |
EXPECT_STREQ( |
"push", |
- GetAttr(button, AccessibilityNodeData::ATTR_NAME).c_str()); |
+ GetAttr(button, ui::AX_ATTR_NAME).c_str()); |
EXPECT_STREQ( |
"inline-block", |
- GetAttr(button, AccessibilityNodeData::ATTR_DISPLAY).c_str()); |
- ASSERT_EQ(2U, button.html_attributes.size()); |
- EXPECT_STREQ("type", button.html_attributes[0].first.c_str()); |
- EXPECT_STREQ("button", button.html_attributes[0].second.c_str()); |
- EXPECT_STREQ("value", button.html_attributes[1].first.c_str()); |
- EXPECT_STREQ("push", button.html_attributes[1].second.c_str()); |
- |
- const AccessibilityNodeDataTreeNode& checkbox = body.children[1]; |
- EXPECT_EQ(blink::WebAXRoleCheckBox, checkbox.role); |
+ GetAttr(button, ui::AX_ATTR_DISPLAY).c_str()); |
+ ASSERT_EQ(2U, button->data().html_attributes.size()); |
+ EXPECT_STREQ("type", button->data().html_attributes[0].first.c_str()); |
+ EXPECT_STREQ("button", button->data().html_attributes[0].second.c_str()); |
+ EXPECT_STREQ("value", button->data().html_attributes[1].first.c_str()); |
+ EXPECT_STREQ("push", button->data().html_attributes[1].second.c_str()); |
+ |
+ const ui::AXNode* checkbox = body->ChildAtIndex(1); |
+ EXPECT_EQ(ui::AX_ROLE_CHECK_BOX, checkbox->data().role); |
EXPECT_STREQ( |
- "input", GetAttr(checkbox, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
+ "input", GetAttr(checkbox, ui::AX_ATTR_HTML_TAG).c_str()); |
EXPECT_STREQ( |
"inline-block", |
- GetAttr(checkbox, AccessibilityNodeData::ATTR_DISPLAY).c_str()); |
- ASSERT_EQ(1U, checkbox.html_attributes.size()); |
- EXPECT_STREQ("type", checkbox.html_attributes[0].first.c_str()); |
- EXPECT_STREQ("checkbox", checkbox.html_attributes[0].second.c_str()); |
+ GetAttr(checkbox, ui::AX_ATTR_DISPLAY).c_str()); |
+ ASSERT_EQ(1U, checkbox->data().html_attributes.size()); |
+ EXPECT_STREQ("type", checkbox->data().html_attributes[0].first.c_str()); |
+ EXPECT_STREQ("checkbox", checkbox->data().html_attributes[0].second.c_str()); |
} |
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
@@ -206,19 +211,20 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
- ASSERT_EQ(1U, tree.children.size()); |
- const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
- ASSERT_EQ(1U, body.children.size()); |
- const AccessibilityNodeDataTreeNode& text = body.children[0]; |
- EXPECT_EQ(blink::WebAXRoleTextField, text.role); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
+ ASSERT_EQ(1, root->child_count()); |
+ const ui::AXNode* body = root->ChildAtIndex(0); |
+ ASSERT_EQ(1, body->child_count()); |
+ const ui::AXNode* text = body->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, text->data().role); |
EXPECT_STREQ( |
- "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
- EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); |
- EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); |
+ "input", GetAttr(text, ui::AX_ATTR_HTML_TAG).c_str()); |
+ EXPECT_EQ(0, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_START)); |
+ EXPECT_EQ(0, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_END)); |
EXPECT_STREQ( |
"Hello, world.", |
- GetAttr(text, AccessibilityNodeData::ATTR_VALUE).c_str()); |
+ GetAttr(text, ui::AX_ATTR_VALUE).c_str()); |
// TODO(dmazzoni): as soon as more accessibility code is cross-platform, |
// this code should test that the accessible info is dynamically updated |
@@ -237,26 +243,27 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
- ASSERT_EQ(1U, tree.children.size()); |
- const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
- ASSERT_EQ(1U, body.children.size()); |
- const AccessibilityNodeDataTreeNode& text = body.children[0]; |
- EXPECT_EQ(blink::WebAXRoleTextField, text.role); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
+ ASSERT_EQ(1, root->child_count()); |
+ const ui::AXNode* body = root->ChildAtIndex(0); |
+ ASSERT_EQ(1, body->child_count()); |
+ const ui::AXNode* text = body->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, text->data().role); |
EXPECT_STREQ( |
- "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
- EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); |
- EXPECT_EQ(13, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); |
+ "input", GetAttr(text, ui::AX_ATTR_HTML_TAG).c_str()); |
+ EXPECT_EQ(0, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_START)); |
+ EXPECT_EQ(13, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_END)); |
EXPECT_STREQ( |
"Hello, world.", |
- GetAttr(text, AccessibilityNodeData::ATTR_VALUE).c_str()); |
+ GetAttr(text, ui::AX_ATTR_VALUE).c_str()); |
} |
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
MultipleInheritanceAccessibility) { |
// In a WebKit accessibility render tree for a table, each cell is a |
// child of both a row and a column, so it appears to use multiple |
- // inheritance. Make sure that the AccessibilityNodeDataObject tree only |
+ // inheritance. Make sure that the ui::AXNodeDataObject tree only |
// keeps one copy of each cell, and uses an indirect child id for the |
// additional reference to it. |
const char url_str[] = |
@@ -266,35 +273,36 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
- ASSERT_EQ(1U, tree.children.size()); |
- const AccessibilityNodeDataTreeNode& table = tree.children[0]; |
- EXPECT_EQ(blink::WebAXRoleTable, table.role); |
- const AccessibilityNodeDataTreeNode& row = table.children[0]; |
- EXPECT_EQ(blink::WebAXRoleRow, row.role); |
- const AccessibilityNodeDataTreeNode& cell1 = row.children[0]; |
- EXPECT_EQ(blink::WebAXRoleCell, cell1.role); |
- const AccessibilityNodeDataTreeNode& cell2 = row.children[1]; |
- EXPECT_EQ(blink::WebAXRoleCell, cell2.role); |
- const AccessibilityNodeDataTreeNode& column1 = table.children[1]; |
- EXPECT_EQ(blink::WebAXRoleColumn, column1.role); |
- EXPECT_EQ(0U, column1.children.size()); |
- EXPECT_EQ(1U, column1.intlist_attributes.size()); |
- EXPECT_EQ(AccessibilityNodeData::ATTR_INDIRECT_CHILD_IDS, |
- column1.intlist_attributes[0].first); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
+ ASSERT_EQ(1, root->child_count()); |
+ const ui::AXNode* table = root->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_TABLE, table->data().role); |
+ const ui::AXNode* row = table->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_ROW, row->data().role); |
+ const ui::AXNode* cell1 = row->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_CELL, cell1->data().role); |
+ const ui::AXNode* cell2 = row->ChildAtIndex(1); |
+ EXPECT_EQ(ui::AX_ROLE_CELL, cell2->data().role); |
+ const ui::AXNode* column1 = table->ChildAtIndex(1); |
+ EXPECT_EQ(ui::AX_ROLE_COLUMN, column1->data().role); |
+ EXPECT_EQ(0, column1->child_count()); |
+ EXPECT_EQ(1U, column1->data().intlist_attributes.size()); |
+ EXPECT_EQ(ui::AX_ATTR_INDIRECT_CHILD_IDS, |
+ column1->data().intlist_attributes[0].first); |
const std::vector<int32> column1_indirect_child_ids = |
- column1.intlist_attributes[0].second; |
+ column1->data().intlist_attributes[0].second; |
EXPECT_EQ(1U, column1_indirect_child_ids.size()); |
- EXPECT_EQ(cell1.id, column1_indirect_child_ids[0]); |
- const AccessibilityNodeDataTreeNode& column2 = table.children[2]; |
- EXPECT_EQ(blink::WebAXRoleColumn, column2.role); |
- EXPECT_EQ(0U, column2.children.size()); |
- EXPECT_EQ(AccessibilityNodeData::ATTR_INDIRECT_CHILD_IDS, |
- column2.intlist_attributes[0].first); |
+ EXPECT_EQ(cell1->id(), column1_indirect_child_ids[0]); |
+ const ui::AXNode* column2 = table->ChildAtIndex(2); |
+ EXPECT_EQ(ui::AX_ROLE_COLUMN, column2->data().role); |
+ EXPECT_EQ(0, column2->child_count()); |
+ EXPECT_EQ(ui::AX_ATTR_INDIRECT_CHILD_IDS, |
+ column2->data().intlist_attributes[0].first); |
const std::vector<int32> column2_indirect_child_ids = |
- column2.intlist_attributes[0].second; |
+ column2->data().intlist_attributes[0].second; |
EXPECT_EQ(1U, column2_indirect_child_ids.size()); |
- EXPECT_EQ(cell2.id, column2_indirect_child_ids[0]); |
+ EXPECT_EQ(cell2->id(), column2_indirect_child_ids[0]); |
} |
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
@@ -314,9 +322,10 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
base::hash_set<int> ids; |
- RecursiveAssertUniqueIds(tree, &ids); |
+ RecursiveAssertUniqueIds(root, &ids); |
} |
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
@@ -334,42 +343,43 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
- ASSERT_EQ(1U, tree.children.size()); |
- const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
- ASSERT_EQ(3U, body.children.size()); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
+ ASSERT_EQ(1, root->child_count()); |
+ const ui::AXNode* body = root->ChildAtIndex(0); |
+ ASSERT_EQ(3, body->child_count()); |
- const AccessibilityNodeDataTreeNode& button1 = body.children[0]; |
- EXPECT_EQ(blink::WebAXRoleButton, button1.role); |
+ const ui::AXNode* button1 = body->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_BUTTON, button1->data().role); |
EXPECT_STREQ( |
"Button 1", |
- GetAttr(button1, AccessibilityNodeData::ATTR_NAME).c_str()); |
+ GetAttr(button1, ui::AX_ATTR_NAME).c_str()); |
- const AccessibilityNodeDataTreeNode& iframe = body.children[1]; |
+ const ui::AXNode* iframe = body->ChildAtIndex(1); |
EXPECT_STREQ("iframe", |
- GetAttr(iframe, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
- ASSERT_EQ(1U, iframe.children.size()); |
+ GetAttr(iframe, ui::AX_ATTR_HTML_TAG).c_str()); |
+ ASSERT_EQ(1, iframe->child_count()); |
- const AccessibilityNodeDataTreeNode& scroll_area = iframe.children[0]; |
- EXPECT_EQ(blink::WebAXRoleScrollArea, scroll_area.role); |
- ASSERT_EQ(1U, scroll_area.children.size()); |
+ const ui::AXNode* scroll_area = iframe->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_SCROLL_AREA, scroll_area->data().role); |
+ ASSERT_EQ(1, scroll_area->child_count()); |
- const AccessibilityNodeDataTreeNode& sub_document = scroll_area.children[0]; |
- EXPECT_EQ(blink::WebAXRoleWebArea, sub_document.role); |
- ASSERT_EQ(1U, sub_document.children.size()); |
+ const ui::AXNode* sub_document = scroll_area->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_WEB_AREA, sub_document->data().role); |
+ ASSERT_EQ(1, sub_document->child_count()); |
- const AccessibilityNodeDataTreeNode& sub_body = sub_document.children[0]; |
- ASSERT_EQ(1U, sub_body.children.size()); |
+ const ui::AXNode* sub_body = sub_document->ChildAtIndex(0); |
+ ASSERT_EQ(1, sub_body->child_count()); |
- const AccessibilityNodeDataTreeNode& button2 = sub_body.children[0]; |
- EXPECT_EQ(blink::WebAXRoleButton, button2.role); |
+ const ui::AXNode* button2 = sub_body->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_BUTTON, button2->data().role); |
EXPECT_STREQ("Button 2", |
- GetAttr(button2, AccessibilityNodeData::ATTR_NAME).c_str()); |
+ GetAttr(button2, ui::AX_ATTR_NAME).c_str()); |
- const AccessibilityNodeDataTreeNode& button3 = body.children[2]; |
- EXPECT_EQ(blink::WebAXRoleButton, button3.role); |
+ const ui::AXNode* button3 = body->ChildAtIndex(2); |
+ EXPECT_EQ(ui::AX_ROLE_BUTTON, button3->data().role); |
EXPECT_STREQ("Button 3", |
- GetAttr(button3, AccessibilityNodeData::ATTR_NAME).c_str()); |
+ GetAttr(button3, ui::AX_ATTR_NAME).c_str()); |
} |
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
@@ -384,9 +394,10 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
base::hash_set<int> ids; |
- RecursiveAssertUniqueIds(tree, &ids); |
+ RecursiveAssertUniqueIds(root, &ids); |
} |
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
@@ -411,56 +422,57 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
- const AccessibilityNodeDataTreeNode& table = tree.children[0]; |
- EXPECT_EQ(blink::WebAXRoleTable, table.role); |
- ASSERT_GE(table.children.size(), 5U); |
- EXPECT_EQ(blink::WebAXRoleRow, table.children[0].role); |
- EXPECT_EQ(blink::WebAXRoleRow, table.children[1].role); |
- EXPECT_EQ(blink::WebAXRoleColumn, table.children[2].role); |
- EXPECT_EQ(blink::WebAXRoleColumn, table.children[3].role); |
- EXPECT_EQ(blink::WebAXRoleColumn, table.children[4].role); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
+ const ui::AXNode* table = root->ChildAtIndex(0); |
+ EXPECT_EQ(ui::AX_ROLE_TABLE, table->data().role); |
+ ASSERT_GE(table->child_count(), 5); |
+ EXPECT_EQ(ui::AX_ROLE_ROW, table->ChildAtIndex(0)->data().role); |
+ EXPECT_EQ(ui::AX_ROLE_ROW, table->ChildAtIndex(1)->data().role); |
+ EXPECT_EQ(ui::AX_ROLE_COLUMN, table->ChildAtIndex(2)->data().role); |
+ EXPECT_EQ(ui::AX_ROLE_COLUMN, table->ChildAtIndex(3)->data().role); |
+ EXPECT_EQ(ui::AX_ROLE_COLUMN, table->ChildAtIndex(4)->data().role); |
EXPECT_EQ(3, |
- GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT)); |
- EXPECT_EQ(2, GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_ROW_COUNT)); |
+ GetIntAttr(table, ui::AX_ATTR_TABLE_COLUMN_COUNT)); |
+ EXPECT_EQ(2, GetIntAttr(table, ui::AX_ATTR_TABLE_ROW_COUNT)); |
- const AccessibilityNodeDataTreeNode& cell1 = table.children[0].children[0]; |
- const AccessibilityNodeDataTreeNode& cell2 = table.children[0].children[1]; |
- const AccessibilityNodeDataTreeNode& cell3 = table.children[1].children[0]; |
- const AccessibilityNodeDataTreeNode& cell4 = table.children[1].children[1]; |
+ const ui::AXNode* cell1 = table->ChildAtIndex(0)->ChildAtIndex(0); |
+ const ui::AXNode* cell2 = table->ChildAtIndex(0)->ChildAtIndex(1); |
+ const ui::AXNode* cell3 = table->ChildAtIndex(1)->ChildAtIndex(0); |
+ const ui::AXNode* cell4 = table->ChildAtIndex(1)->ChildAtIndex(1); |
- ASSERT_EQ(AccessibilityNodeData::ATTR_CELL_IDS, |
- table.intlist_attributes[0].first); |
+ ASSERT_EQ(ui::AX_ATTR_CELL_IDS, |
+ table->data().intlist_attributes[0].first); |
const std::vector<int32>& table_cell_ids = |
- table.intlist_attributes[0].second; |
+ table->data().intlist_attributes[0].second; |
ASSERT_EQ(6U, table_cell_ids.size()); |
- EXPECT_EQ(cell1.id, table_cell_ids[0]); |
- EXPECT_EQ(cell1.id, table_cell_ids[1]); |
- EXPECT_EQ(cell2.id, table_cell_ids[2]); |
- EXPECT_EQ(cell3.id, table_cell_ids[3]); |
- EXPECT_EQ(cell4.id, table_cell_ids[4]); |
- EXPECT_EQ(cell4.id, table_cell_ids[5]); |
+ EXPECT_EQ(cell1->id(), table_cell_ids[0]); |
+ EXPECT_EQ(cell1->id(), table_cell_ids[1]); |
+ EXPECT_EQ(cell2->id(), table_cell_ids[2]); |
+ EXPECT_EQ(cell3->id(), table_cell_ids[3]); |
+ EXPECT_EQ(cell4->id(), table_cell_ids[4]); |
+ EXPECT_EQ(cell4->id(), table_cell_ids[5]); |
EXPECT_EQ(0, GetIntAttr(cell1, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); |
EXPECT_EQ(0, GetIntAttr(cell1, |
- AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX)); |
+ ui::AX_ATTR_TABLE_CELL_ROW_INDEX)); |
EXPECT_EQ(2, GetIntAttr(cell1, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); |
EXPECT_EQ(1, GetIntAttr(cell1, |
- AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN)); |
+ ui::AX_ATTR_TABLE_CELL_ROW_SPAN)); |
EXPECT_EQ(2, GetIntAttr(cell2, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); |
EXPECT_EQ(1, GetIntAttr(cell2, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); |
EXPECT_EQ(0, GetIntAttr(cell3, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); |
EXPECT_EQ(1, GetIntAttr(cell3, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); |
EXPECT_EQ(1, GetIntAttr(cell4, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); |
EXPECT_EQ(2, GetIntAttr(cell4, |
- AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); |
+ ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); |
} |
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
@@ -473,13 +485,11 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
"</div>"; |
GURL url(url_str); |
NavigateToURL(shell(), url); |
- const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
- |
- ASSERT_EQ(1U, tree.children.size()); |
- const AccessibilityNodeDataTreeNode& textbox = tree.children[0]; |
- |
- EXPECT_EQ( |
- true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE)); |
+ const ui::AXTree& tree = GetAXTree(); |
+ const ui::AXNode* root = tree.GetRoot(); |
+ ASSERT_EQ(1, root->child_count()); |
+ const ui::AXNode* textbox = root->ChildAtIndex(0); |
+ EXPECT_EQ(true, GetBoolAttr(textbox, ui::AX_ATTR_CAN_SET_VALUE)); |
} |
} // namespace content |