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 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 void | 84 void |
| 85 CrossPlatformAccessibilityBrowserTest::TearDownInProcessBrowserTestFixture() { | 85 CrossPlatformAccessibilityBrowserTest::TearDownInProcessBrowserTestFixture() { |
| 86 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 87 com_initializer_.reset(); | 87 com_initializer_.reset(); |
| 88 #endif | 88 #endif |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Convenience method to get the value of a particular AccessibilityNodeData | 91 // Convenience method to get the value of a particular AccessibilityNodeData |
| 92 // node attribute as a UTF-8 const char*. | 92 // node attribute as a UTF-8 string. |
| 93 std::string CrossPlatformAccessibilityBrowserTest::GetAttr( | 93 std::string CrossPlatformAccessibilityBrowserTest::GetAttr( |
| 94 const AccessibilityNodeData& node, | 94 const AccessibilityNodeData& node, |
| 95 const AccessibilityNodeData::StringAttribute attr) { | 95 const AccessibilityNodeData::StringAttribute attr) { |
| 96 std::map<AccessibilityNodeData::StringAttribute, string16>::const_iterator | 96 for (size_t i = 0; i < node.string_attributes.size(); ++i) { |
| 97 iter = node.string_attributes.find(attr); | 97 if (node.string_attributes[i].first == attr) |
| 98 if (iter != node.string_attributes.end()) | 98 return node.string_attributes[i].second; |
| 99 return UTF16ToUTF8(iter->second); | 99 } |
| 100 else | 100 return std::string(); |
| 101 return std::string(); | |
| 102 } | 101 } |
| 103 | 102 |
| 104 // Convenience method to get the value of a particular AccessibilityNodeData | 103 // Convenience method to get the value of a particular AccessibilityNodeData |
| 105 // node integer attribute. | 104 // node integer attribute. |
| 106 int CrossPlatformAccessibilityBrowserTest::GetIntAttr( | 105 int CrossPlatformAccessibilityBrowserTest::GetIntAttr( |
| 107 const AccessibilityNodeData& node, | 106 const AccessibilityNodeData& node, |
| 108 const AccessibilityNodeData::IntAttribute attr) { | 107 const AccessibilityNodeData::IntAttribute attr) { |
| 109 std::map<AccessibilityNodeData::IntAttribute, int32>::const_iterator iter = | 108 for (size_t i = 0; i < node.int_attributes.size(); ++i) { |
| 110 node.int_attributes.find(attr); | 109 if (node.int_attributes[i].first == attr) |
| 111 if (iter != node.int_attributes.end()) | 110 return node.int_attributes[i].second; |
| 112 return iter->second; | 111 } |
| 113 else | 112 return -1; |
| 114 return -1; | |
| 115 } | 113 } |
| 116 | 114 |
| 117 // Convenience method to get the value of a particular AccessibilityNodeData | 115 // Convenience method to get the value of a particular AccessibilityNodeData |
| 118 // node boolean attribute. | 116 // node boolean attribute. |
| 119 bool CrossPlatformAccessibilityBrowserTest::GetBoolAttr( | 117 bool CrossPlatformAccessibilityBrowserTest::GetBoolAttr( |
| 120 const AccessibilityNodeData& node, | 118 const AccessibilityNodeData& node, |
| 121 const AccessibilityNodeData::BoolAttribute attr) { | 119 const AccessibilityNodeData::BoolAttribute attr) { |
| 122 std::map<AccessibilityNodeData::BoolAttribute, bool>::const_iterator iter = | 120 for (size_t i = 0; i < node.bool_attributes.size(); ++i) { |
| 123 node.bool_attributes.find(attr); | 121 if (node.bool_attributes[i].first == attr) |
| 124 if (iter != node.bool_attributes.end()) | 122 return node.bool_attributes[i].second; |
| 125 return iter->second; | 123 } |
| 126 else | 124 return false; |
| 127 return false; | |
| 128 } | 125 } |
| 129 | 126 |
| 130 // Marked flaky per http://crbug.com/101984 | 127 // Marked flaky per http://crbug.com/101984 |
| 131 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, | 128 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
| 132 DISABLED_WebpageAccessibility) { | 129 DISABLED_WebpageAccessibility) { |
| 133 // Create a data url and load it. | 130 // Create a data url and load it. |
| 134 const char url_str[] = | 131 const char url_str[] = |
| 135 "data:text/html," | 132 "data:text/html," |
| 136 "<!doctype html>" | 133 "<!doctype html>" |
| 137 "<html><head><title>Accessibility Test</title></head>" | 134 "<html><head><title>Accessibility Test</title></head>" |
| 138 "<body><input type='button' value='push' /><input type='checkbox' />" | 135 "<body><input type='button' value='push' /><input type='checkbox' />" |
| 139 "</body></html>"; | 136 "</body></html>"; |
| 140 GURL url(url_str); | 137 GURL url(url_str); |
| 141 NavigateToURL(shell(), url); | 138 NavigateToURL(shell(), url); |
| 142 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); | 139 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
| 143 | 140 |
| 144 // Check properties of the root element of the tree. | 141 // Check properties of the root element of the tree. |
| 145 EXPECT_STREQ(url_str, | 142 EXPECT_STREQ(url_str, |
| 146 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_URL).c_str()); | 143 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_URL).c_str()); |
| 147 EXPECT_STREQ( | 144 EXPECT_STREQ( |
| 148 "Accessibility Test", | 145 "Accessibility Test", |
| 149 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_TITLE).c_str()); | 146 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_TITLE).c_str()); |
| 150 EXPECT_STREQ( | 147 EXPECT_STREQ( |
| 151 "html", GetAttr(tree, AccessibilityNodeData::ATTR_DOC_DOCTYPE).c_str()); | 148 "html", GetAttr(tree, AccessibilityNodeData::ATTR_DOC_DOCTYPE).c_str()); |
| 152 EXPECT_STREQ( | 149 EXPECT_STREQ( |
| 153 "text/html", | 150 "text/html", |
| 154 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_MIMETYPE).c_str()); | 151 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_MIMETYPE).c_str()); |
| 155 EXPECT_STREQ("Accessibility Test", UTF16ToUTF8(tree.name).c_str()); | 152 EXPECT_STREQ( |
| 153 "Accessibility Test", | |
| 154 GetAttr(tree, AccessibilityNodeData::ATTR_NAME).c_str()); | |
| 156 EXPECT_EQ(AccessibilityNodeData::ROLE_ROOT_WEB_AREA, tree.role); | 155 EXPECT_EQ(AccessibilityNodeData::ROLE_ROOT_WEB_AREA, tree.role); |
| 157 | 156 |
| 158 // Check properites of the BODY element. | 157 // Check properites of the BODY element. |
| 159 ASSERT_EQ(1U, tree.children.size()); | 158 ASSERT_EQ(1U, tree.children.size()); |
| 160 const AccessibilityNodeDataTreeNode& body = tree.children[0]; | 159 const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
| 161 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, body.role); | 160 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, body.role); |
| 162 EXPECT_STREQ("body", | 161 EXPECT_STREQ("body", |
| 163 GetAttr(body, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | 162 GetAttr(body, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
| 164 EXPECT_STREQ("block", | 163 EXPECT_STREQ("block", |
| 165 GetAttr(body, AccessibilityNodeData::ATTR_DISPLAY).c_str()); | 164 GetAttr(body, AccessibilityNodeData::ATTR_DISPLAY).c_str()); |
| 166 | 165 |
| 167 // Check properties of the two children of the BODY element. | 166 // Check properties of the two children of the BODY element. |
| 168 ASSERT_EQ(2U, body.children.size()); | 167 ASSERT_EQ(2U, body.children.size()); |
| 169 | 168 |
| 170 const AccessibilityNodeDataTreeNode& button = body.children[0]; | 169 const AccessibilityNodeDataTreeNode& button = body.children[0]; |
| 171 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button.role); | 170 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button.role); |
| 172 EXPECT_STREQ( | 171 EXPECT_STREQ( |
| 173 "input", GetAttr(button, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | 172 "input", GetAttr(button, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
| 174 EXPECT_STREQ("push", UTF16ToUTF8(button.name).c_str()); | 173 EXPECT_STREQ( |
| 174 "push", | |
| 175 GetAttr(button, AccessibilityNodeData::ATTR_NAME).c_str()); | |
| 175 EXPECT_STREQ( | 176 EXPECT_STREQ( |
| 176 "inline-block", | 177 "inline-block", |
| 177 GetAttr(button, AccessibilityNodeData::ATTR_DISPLAY).c_str()); | 178 GetAttr(button, AccessibilityNodeData::ATTR_DISPLAY).c_str()); |
| 178 ASSERT_EQ(2U, button.html_attributes.size()); | 179 ASSERT_EQ(2U, button.html_attributes.size()); |
| 179 EXPECT_STREQ("type", UTF16ToUTF8(button.html_attributes[0].first).c_str()); | 180 EXPECT_STREQ("type", button.html_attributes[0].first.c_str()); |
| 180 EXPECT_STREQ("button", UTF16ToUTF8(button.html_attributes[0].second).c_str()); | 181 EXPECT_STREQ("button", button.html_attributes[0].second.c_str()); |
| 181 EXPECT_STREQ("value", UTF16ToUTF8(button.html_attributes[1].first).c_str()); | 182 EXPECT_STREQ("value", button.html_attributes[1].first.c_str()); |
| 182 EXPECT_STREQ("push", UTF16ToUTF8(button.html_attributes[1].second).c_str()); | 183 EXPECT_STREQ("push", button.html_attributes[1].second.c_str()); |
| 183 | 184 |
| 184 const AccessibilityNodeDataTreeNode& checkbox = body.children[1]; | 185 const AccessibilityNodeDataTreeNode& checkbox = body.children[1]; |
| 185 EXPECT_EQ(AccessibilityNodeData::ROLE_CHECKBOX, checkbox.role); | 186 EXPECT_EQ(AccessibilityNodeData::ROLE_CHECKBOX, checkbox.role); |
| 186 EXPECT_STREQ( | 187 EXPECT_STREQ( |
| 187 "input", GetAttr(checkbox, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | 188 "input", GetAttr(checkbox, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
| 188 EXPECT_STREQ( | 189 EXPECT_STREQ( |
| 189 "inline-block", | 190 "inline-block", |
| 190 GetAttr(checkbox, AccessibilityNodeData::ATTR_DISPLAY).c_str()); | 191 GetAttr(checkbox, AccessibilityNodeData::ATTR_DISPLAY).c_str()); |
| 191 ASSERT_EQ(1U, checkbox.html_attributes.size()); | 192 ASSERT_EQ(1U, checkbox.html_attributes.size()); |
| 192 EXPECT_STREQ( | 193 EXPECT_STREQ("type", checkbox.html_attributes[0].first.c_str()); |
| 193 "type", UTF16ToUTF8(checkbox.html_attributes[0].first).c_str()); | 194 EXPECT_STREQ("checkbox", checkbox.html_attributes[0].second.c_str()); |
| 194 EXPECT_STREQ( | |
| 195 "checkbox", UTF16ToUTF8(checkbox.html_attributes[0].second).c_str()); | |
| 196 } | 195 } |
| 197 | 196 |
| 198 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, | 197 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
| 199 UnselectedEditableTextAccessibility) { | 198 UnselectedEditableTextAccessibility) { |
| 200 // Create a data url and load it. | 199 // Create a data url and load it. |
| 201 const char url_str[] = | 200 const char url_str[] = |
| 202 "data:text/html," | 201 "data:text/html," |
| 203 "<!doctype html>" | 202 "<!doctype html>" |
| 204 "<body>" | 203 "<body>" |
| 205 "<input value=\"Hello, world.\"/>" | 204 "<input value=\"Hello, world.\"/>" |
| 206 "</body></html>"; | 205 "</body></html>"; |
| 207 GURL url(url_str); | 206 GURL url(url_str); |
| 208 NavigateToURL(shell(), url); | 207 NavigateToURL(shell(), url); |
| 209 | 208 |
| 210 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); | 209 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
| 211 ASSERT_EQ(1U, tree.children.size()); | 210 ASSERT_EQ(1U, tree.children.size()); |
| 212 const AccessibilityNodeDataTreeNode& body = tree.children[0]; | 211 const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
| 213 ASSERT_EQ(1U, body.children.size()); | 212 ASSERT_EQ(1U, body.children.size()); |
| 214 const AccessibilityNodeDataTreeNode& text = body.children[0]; | 213 const AccessibilityNodeDataTreeNode& text = body.children[0]; |
| 215 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role); | 214 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role); |
| 216 EXPECT_STREQ( | 215 EXPECT_STREQ( |
| 217 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | 216 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
| 218 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); | 217 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); |
| 219 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); | 218 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); |
| 220 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); | 219 EXPECT_STREQ( |
| 220 "Hello, world.", | |
| 221 GetAttr(text, AccessibilityNodeData::ATTR_VALUE).c_str()); | |
| 221 | 222 |
| 222 // TODO(dmazzoni): as soon as more accessibility code is cross-platform, | 223 // TODO(dmazzoni): as soon as more accessibility code is cross-platform, |
| 223 // this code should test that the accessible info is dynamically updated | 224 // this code should test that the accessible info is dynamically updated |
| 224 // if the selection or value changes. | 225 // if the selection or value changes. |
| 225 } | 226 } |
| 226 | 227 |
| 227 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, | 228 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
| 228 SelectedEditableTextAccessibility) { | 229 SelectedEditableTextAccessibility) { |
| 229 // Create a data url and load it. | 230 // Create a data url and load it. |
| 230 const char url_str[] = | 231 const char url_str[] = |
| 231 "data:text/html," | 232 "data:text/html," |
| 232 "<!doctype html>" | 233 "<!doctype html>" |
| 233 "<body onload=\"document.body.children[0].select();\">" | 234 "<body onload=\"document.body.children[0].select();\">" |
| 234 "<input value=\"Hello, world.\"/>" | 235 "<input value=\"Hello, world.\"/>" |
| 235 "</body></html>"; | 236 "</body></html>"; |
| 236 GURL url(url_str); | 237 GURL url(url_str); |
| 237 NavigateToURL(shell(), url); | 238 NavigateToURL(shell(), url); |
| 238 | 239 |
| 239 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); | 240 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
| 240 ASSERT_EQ(1U, tree.children.size()); | 241 ASSERT_EQ(1U, tree.children.size()); |
| 241 const AccessibilityNodeDataTreeNode& body = tree.children[0]; | 242 const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
| 242 ASSERT_EQ(1U, body.children.size()); | 243 ASSERT_EQ(1U, body.children.size()); |
| 243 const AccessibilityNodeDataTreeNode& text = body.children[0]; | 244 const AccessibilityNodeDataTreeNode& text = body.children[0]; |
| 244 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role); | 245 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role); |
| 245 EXPECT_STREQ( | 246 EXPECT_STREQ( |
| 246 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | 247 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
| 247 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); | 248 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); |
| 248 EXPECT_EQ(13, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); | 249 EXPECT_EQ(13, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); |
| 249 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); | 250 EXPECT_STREQ( |
| 251 "Hello, world.", | |
| 252 GetAttr(text, AccessibilityNodeData::ATTR_VALUE).c_str()); | |
| 250 } | 253 } |
| 251 | 254 |
| 252 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, | 255 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
| 253 MultipleInheritanceAccessibility) { | 256 MultipleInheritanceAccessibility) { |
| 254 // In a WebKit accessibility render tree for a table, each cell is a | 257 // In a WebKit accessibility render tree for a table, each cell is a |
| 255 // child of both a row and a column, so it appears to use multiple | 258 // child of both a row and a column, so it appears to use multiple |
| 256 // inheritance. Make sure that the AccessibilityNodeDataObject tree only | 259 // inheritance. Make sure that the AccessibilityNodeDataObject tree only |
| 257 // keeps one copy of each cell, and uses an indirect child id for the | 260 // keeps one copy of each cell, and uses an indirect child id for the |
| 258 // additional reference to it. | 261 // additional reference to it. |
| 259 const char url_str[] = | 262 const char url_str[] = |
| 260 "data:text/html," | 263 "data:text/html," |
| 261 "<!doctype html>" | 264 "<!doctype html>" |
| 262 "<table border=1><tr><td>1</td><td>2</td></tr></table>"; | 265 "<table border=1><tr><td>1</td><td>2</td></tr></table>"; |
| 263 GURL url(url_str); | 266 GURL url(url_str); |
| 264 NavigateToURL(shell(), url); | 267 NavigateToURL(shell(), url); |
| 265 | 268 |
| 266 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); | 269 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
| 267 ASSERT_EQ(1U, tree.children.size()); | 270 ASSERT_EQ(1U, tree.children.size()); |
| 268 const AccessibilityNodeDataTreeNode& table = tree.children[0]; | 271 const AccessibilityNodeDataTreeNode& table = tree.children[0]; |
| 269 EXPECT_EQ(AccessibilityNodeData::ROLE_TABLE, table.role); | 272 EXPECT_EQ(AccessibilityNodeData::ROLE_TABLE, table.role); |
| 270 const AccessibilityNodeDataTreeNode& row = table.children[0]; | 273 const AccessibilityNodeDataTreeNode& row = table.children[0]; |
| 271 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, row.role); | 274 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, row.role); |
| 272 const AccessibilityNodeDataTreeNode& cell1 = row.children[0]; | 275 const AccessibilityNodeDataTreeNode& cell1 = row.children[0]; |
| 273 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell1.role); | 276 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell1.role); |
| 274 const AccessibilityNodeDataTreeNode& cell2 = row.children[1]; | 277 const AccessibilityNodeDataTreeNode& cell2 = row.children[1]; |
| 275 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell2.role); | 278 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell2.role); |
| 276 const AccessibilityNodeDataTreeNode& column1 = table.children[1]; | 279 const AccessibilityNodeDataTreeNode& column1 = table.children[1]; |
| 277 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column1.role); | 280 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column1.role); |
| 278 EXPECT_EQ(0U, column1.children.size()); | 281 EXPECT_EQ(0U, column1.children.size()); |
| 279 EXPECT_EQ(1U, column1.indirect_child_ids.size()); | 282 EXPECT_EQ(1U, column1.intlist_attributes.size()); |
| 280 EXPECT_EQ(cell1.id, column1.indirect_child_ids[0]); | 283 EXPECT_EQ(AccessibilityNodeData::ATTR_INDIRECT_CHILD_IDS, |
| 284 column1.intlist_attributes[0].first); | |
| 285 const std::vector<int32> column1_indirect_child_ids = | |
| 286 column1.intlist_attributes[0].second; | |
| 287 EXPECT_EQ(1U, column1_indirect_child_ids.size()); | |
| 288 EXPECT_EQ(cell1.id, column1_indirect_child_ids[0]); | |
| 281 const AccessibilityNodeDataTreeNode& column2 = table.children[2]; | 289 const AccessibilityNodeDataTreeNode& column2 = table.children[2]; |
| 282 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column2.role); | 290 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column2.role); |
| 283 EXPECT_EQ(0U, column2.children.size()); | 291 EXPECT_EQ(0U, column2.children.size()); |
| 284 EXPECT_EQ(1U, column2.indirect_child_ids.size()); | 292 EXPECT_EQ(AccessibilityNodeData::ATTR_INDIRECT_CHILD_IDS, |
| 285 EXPECT_EQ(cell2.id, column2.indirect_child_ids[0]); | 293 column2.intlist_attributes[0].first); |
| 294 const std::vector<int32> column2_indirect_child_ids = | |
| 295 column2.intlist_attributes[0].second; | |
| 296 EXPECT_EQ(1U, column2_indirect_child_ids.size()); | |
| 297 EXPECT_EQ(cell2.id, column2_indirect_child_ids[0]); | |
| 286 } | 298 } |
| 287 | 299 |
| 288 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, | 300 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
| 289 MultipleInheritanceAccessibility2) { | 301 MultipleInheritanceAccessibility2) { |
| 290 // Here's another html snippet where WebKit puts the same node as a child | 302 // Here's another html snippet where WebKit puts the same node as a child |
| 291 // of two different parents. Instead of checking the exact output, just | 303 // of two different parents. Instead of checking the exact output, just |
| 292 // make sure that no id is reused in the resulting tree. | 304 // make sure that no id is reused in the resulting tree. |
| 293 const char url_str[] = | 305 const char url_str[] = |
| 294 "data:text/html," | 306 "data:text/html," |
| 295 "<!doctype html>" | 307 "<!doctype html>" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 322 GURL url(url_str); | 334 GURL url(url_str); |
| 323 NavigateToURL(shell(), url); | 335 NavigateToURL(shell(), url); |
| 324 | 336 |
| 325 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); | 337 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
| 326 ASSERT_EQ(1U, tree.children.size()); | 338 ASSERT_EQ(1U, tree.children.size()); |
| 327 const AccessibilityNodeDataTreeNode& body = tree.children[0]; | 339 const AccessibilityNodeDataTreeNode& body = tree.children[0]; |
| 328 ASSERT_EQ(3U, body.children.size()); | 340 ASSERT_EQ(3U, body.children.size()); |
| 329 | 341 |
| 330 const AccessibilityNodeDataTreeNode& button1 = body.children[0]; | 342 const AccessibilityNodeDataTreeNode& button1 = body.children[0]; |
| 331 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button1.role); | 343 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button1.role); |
| 332 EXPECT_STREQ("Button 1", UTF16ToUTF8(button1.name).c_str()); | 344 EXPECT_STREQ( |
| 345 "Button 1", | |
| 346 GetAttr(button1, AccessibilityNodeData::ATTR_NAME).c_str()); | |
| 333 | 347 |
| 334 const AccessibilityNodeDataTreeNode& iframe = body.children[1]; | 348 const AccessibilityNodeDataTreeNode& iframe = body.children[1]; |
| 335 EXPECT_STREQ("iframe", | 349 EXPECT_STREQ("iframe", |
| 336 GetAttr(iframe, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | 350 GetAttr(iframe, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); |
| 337 ASSERT_EQ(1U, iframe.children.size()); | 351 ASSERT_EQ(1U, iframe.children.size()); |
| 338 | 352 |
| 339 const AccessibilityNodeDataTreeNode& scroll_area = iframe.children[0]; | 353 const AccessibilityNodeDataTreeNode& scroll_area = iframe.children[0]; |
| 340 EXPECT_EQ(AccessibilityNodeData::ROLE_SCROLLAREA, scroll_area.role); | 354 EXPECT_EQ(AccessibilityNodeData::ROLE_SCROLLAREA, scroll_area.role); |
| 341 ASSERT_EQ(1U, scroll_area.children.size()); | 355 ASSERT_EQ(1U, scroll_area.children.size()); |
| 342 | 356 |
| 343 const AccessibilityNodeDataTreeNode& sub_document = scroll_area.children[0]; | 357 const AccessibilityNodeDataTreeNode& sub_document = scroll_area.children[0]; |
| 344 EXPECT_EQ(AccessibilityNodeData::ROLE_WEB_AREA, sub_document.role); | 358 EXPECT_EQ(AccessibilityNodeData::ROLE_WEB_AREA, sub_document.role); |
| 345 ASSERT_EQ(1U, sub_document.children.size()); | 359 ASSERT_EQ(1U, sub_document.children.size()); |
| 346 | 360 |
| 347 const AccessibilityNodeDataTreeNode& sub_body = sub_document.children[0]; | 361 const AccessibilityNodeDataTreeNode& sub_body = sub_document.children[0]; |
| 348 ASSERT_EQ(1U, sub_body.children.size()); | 362 ASSERT_EQ(1U, sub_body.children.size()); |
| 349 | 363 |
| 350 const AccessibilityNodeDataTreeNode& button2 = sub_body.children[0]; | 364 const AccessibilityNodeDataTreeNode& button2 = sub_body.children[0]; |
| 351 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button2.role); | 365 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button2.role); |
| 352 EXPECT_STREQ("Button 2", UTF16ToUTF8(button2.name).c_str()); | 366 EXPECT_STREQ("Button 2", |
| 367 GetAttr(button2, AccessibilityNodeData::ATTR_NAME).c_str()); | |
| 353 | 368 |
| 354 const AccessibilityNodeDataTreeNode& button3 = body.children[2]; | 369 const AccessibilityNodeDataTreeNode& button3 = body.children[2]; |
| 355 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button3.role); | 370 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button3.role); |
| 356 EXPECT_STREQ("Button 3", UTF16ToUTF8(button3.name).c_str()); | 371 EXPECT_STREQ("Button 3", |
| 372 GetAttr(button3, AccessibilityNodeData::ATTR_NAME).c_str()); | |
| 357 } | 373 } |
| 358 | 374 |
| 359 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, | 375 IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, |
| 360 DuplicateChildrenAccessibility) { | 376 DuplicateChildrenAccessibility) { |
| 361 // Here's another html snippet where WebKit has a parent node containing | 377 // Here's another html snippet where WebKit has a parent node containing |
| 362 // two duplicate child nodes. Instead of checking the exact output, just | 378 // two duplicate child nodes. Instead of checking the exact output, just |
| 363 // make sure that no id is reused in the resulting tree. | 379 // make sure that no id is reused in the resulting tree. |
| 364 const char url_str[] = | 380 const char url_str[] = |
| 365 "data:text/html," | 381 "data:text/html," |
| 366 "<!doctype html>" | 382 "<!doctype html>" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[4].role); | 422 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[4].role); |
| 407 EXPECT_EQ(3, | 423 EXPECT_EQ(3, |
| 408 GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT)); | 424 GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT)); |
| 409 EXPECT_EQ(2, GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_ROW_COUNT)); | 425 EXPECT_EQ(2, GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_ROW_COUNT)); |
| 410 | 426 |
| 411 const AccessibilityNodeDataTreeNode& cell1 = table.children[0].children[0]; | 427 const AccessibilityNodeDataTreeNode& cell1 = table.children[0].children[0]; |
| 412 const AccessibilityNodeDataTreeNode& cell2 = table.children[0].children[1]; | 428 const AccessibilityNodeDataTreeNode& cell2 = table.children[0].children[1]; |
| 413 const AccessibilityNodeDataTreeNode& cell3 = table.children[1].children[0]; | 429 const AccessibilityNodeDataTreeNode& cell3 = table.children[1].children[0]; |
| 414 const AccessibilityNodeDataTreeNode& cell4 = table.children[1].children[1]; | 430 const AccessibilityNodeDataTreeNode& cell4 = table.children[1].children[1]; |
| 415 | 431 |
| 416 ASSERT_EQ(6U, table.cell_ids.size()); | 432 EXPECT_EQ(AccessibilityNodeData::ATTR_CELL_IDS, |
|
aboxhall
2013/08/07 17:16:09
I think this should be an assert.
dmazzoni
2013/08/07 17:48:18
Done.
| |
| 417 EXPECT_EQ(cell1.id, table.cell_ids[0]); | 433 table.intlist_attributes[0].first); |
| 418 EXPECT_EQ(cell1.id, table.cell_ids[1]); | 434 const std::vector<int32>& table_cell_ids = |
| 419 EXPECT_EQ(cell2.id, table.cell_ids[2]); | 435 table.intlist_attributes[0].second; |
| 420 EXPECT_EQ(cell3.id, table.cell_ids[3]); | 436 ASSERT_EQ(6U, table_cell_ids.size()); |
| 421 EXPECT_EQ(cell4.id, table.cell_ids[4]); | 437 EXPECT_EQ(cell1.id, table_cell_ids[0]); |
| 422 EXPECT_EQ(cell4.id, table.cell_ids[5]); | 438 EXPECT_EQ(cell1.id, table_cell_ids[1]); |
| 439 EXPECT_EQ(cell2.id, table_cell_ids[2]); | |
| 440 EXPECT_EQ(cell3.id, table_cell_ids[3]); | |
| 441 EXPECT_EQ(cell4.id, table_cell_ids[4]); | |
| 442 EXPECT_EQ(cell4.id, table_cell_ids[5]); | |
| 423 | 443 |
| 424 EXPECT_EQ(0, GetIntAttr(cell1, | 444 EXPECT_EQ(0, GetIntAttr(cell1, |
| 425 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); | 445 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); |
| 426 EXPECT_EQ(0, GetIntAttr(cell1, | 446 EXPECT_EQ(0, GetIntAttr(cell1, |
| 427 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX)); | 447 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX)); |
| 428 EXPECT_EQ(2, GetIntAttr(cell1, | 448 EXPECT_EQ(2, GetIntAttr(cell1, |
| 429 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); | 449 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); |
| 430 EXPECT_EQ(1, GetIntAttr(cell1, | 450 EXPECT_EQ(1, GetIntAttr(cell1, |
| 431 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN)); | 451 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN)); |
| 432 EXPECT_EQ(2, GetIntAttr(cell2, | 452 EXPECT_EQ(2, GetIntAttr(cell2, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 456 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); | 476 const AccessibilityNodeDataTreeNode& tree = GetAccessibilityNodeDataTree(); |
| 457 | 477 |
| 458 ASSERT_EQ(1U, tree.children.size()); | 478 ASSERT_EQ(1U, tree.children.size()); |
| 459 const AccessibilityNodeDataTreeNode& textbox = tree.children[0]; | 479 const AccessibilityNodeDataTreeNode& textbox = tree.children[0]; |
| 460 | 480 |
| 461 EXPECT_EQ( | 481 EXPECT_EQ( |
| 462 true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE)); | 482 true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE)); |
| 463 } | 483 } |
| 464 | 484 |
| 465 } // namespace content | 485 } // namespace content |
| OLD | NEW |