| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 127 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 128 CrossPlatformWebpageAccessibility) { | 128 CrossPlatformWebpageAccessibility) { |
| 129 // Create a data url and load it. | 129 // Create a data url and load it. |
| 130 const char url_str[] = | 130 const char url_str[] = |
| 131 "data:text/html," | 131 "data:text/html," |
| 132 "<!doctype html>" | 132 "<!doctype html>" |
| 133 "<html><head><title>Accessibility Test</title></head>" | 133 "<html><head><title>Accessibility Test</title></head>" |
| 134 "<body><input type='button' value='push' /><input type='checkbox' />" | 134 "<body><input type='button' value='push' /><input type='checkbox' />" |
| 135 "</body></html>"; | 135 "</body></html>"; |
| 136 GURL url(url_str); | 136 GURL url(url_str); |
| 137 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 137 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 138 const WebAccessibility& tree = GetWebAccessibilityTree(); | 138 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 139 | 139 |
| 140 // Check properties of the root element of the tree. | 140 // Check properties of the root element of the tree. |
| 141 EXPECT_STREQ(url_str, GetAttr(tree, WebAccessibility::ATTR_DOC_URL).c_str()); | 141 EXPECT_STREQ(url_str, GetAttr(tree, WebAccessibility::ATTR_DOC_URL).c_str()); |
| 142 EXPECT_STREQ( | 142 EXPECT_STREQ( |
| 143 "Accessibility Test", | 143 "Accessibility Test", |
| 144 GetAttr(tree, WebAccessibility::ATTR_DOC_TITLE).c_str()); | 144 GetAttr(tree, WebAccessibility::ATTR_DOC_TITLE).c_str()); |
| 145 EXPECT_STREQ( | 145 EXPECT_STREQ( |
| 146 "html", GetAttr(tree, WebAccessibility::ATTR_DOC_DOCTYPE).c_str()); | 146 "html", GetAttr(tree, WebAccessibility::ATTR_DOC_DOCTYPE).c_str()); |
| 147 EXPECT_STREQ( | 147 EXPECT_STREQ( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 189 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 190 CrossPlatformUnselectedEditableTextAccessibility) { | 190 CrossPlatformUnselectedEditableTextAccessibility) { |
| 191 // Create a data url and load it. | 191 // Create a data url and load it. |
| 192 const char url_str[] = | 192 const char url_str[] = |
| 193 "data:text/html," | 193 "data:text/html," |
| 194 "<!doctype html>" | 194 "<!doctype html>" |
| 195 "<body>" | 195 "<body>" |
| 196 "<input value=\"Hello, world.\"/>" | 196 "<input value=\"Hello, world.\"/>" |
| 197 "</body></html>"; | 197 "</body></html>"; |
| 198 GURL url(url_str); | 198 GURL url(url_str); |
| 199 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 199 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 200 | 200 |
| 201 const WebAccessibility& tree = GetWebAccessibilityTree(); | 201 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 202 ASSERT_EQ(1U, tree.children.size()); | 202 ASSERT_EQ(1U, tree.children.size()); |
| 203 const WebAccessibility& body = tree.children[0]; | 203 const WebAccessibility& body = tree.children[0]; |
| 204 ASSERT_EQ(1U, body.children.size()); | 204 ASSERT_EQ(1U, body.children.size()); |
| 205 const WebAccessibility& text = body.children[0]; | 205 const WebAccessibility& text = body.children[0]; |
| 206 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text.role); | 206 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text.role); |
| 207 EXPECT_STREQ( | 207 EXPECT_STREQ( |
| 208 "input", GetAttr(text, WebAccessibility::ATTR_HTML_TAG).c_str()); | 208 "input", GetAttr(text, WebAccessibility::ATTR_HTML_TAG).c_str()); |
| 209 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_START)); | 209 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_START)); |
| 210 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_END)); | 210 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_END)); |
| 211 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); | 211 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); |
| 212 | 212 |
| 213 // TODO(dmazzoni): as soon as more accessibility code is cross-platform, | 213 // TODO(dmazzoni): as soon as more accessibility code is cross-platform, |
| 214 // this code should test that the accessible info is dynamically updated | 214 // this code should test that the accessible info is dynamically updated |
| 215 // if the selection or value changes. | 215 // if the selection or value changes. |
| 216 } | 216 } |
| 217 | 217 |
| 218 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 218 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 219 CrossPlatformSelectedEditableTextAccessibility) { | 219 CrossPlatformSelectedEditableTextAccessibility) { |
| 220 // Create a data url and load it. | 220 // Create a data url and load it. |
| 221 const char url_str[] = | 221 const char url_str[] = |
| 222 "data:text/html," | 222 "data:text/html," |
| 223 "<!doctype html>" | 223 "<!doctype html>" |
| 224 "<body onload=\"document.body.children[0].select();\">" | 224 "<body onload=\"document.body.children[0].select();\">" |
| 225 "<input value=\"Hello, world.\"/>" | 225 "<input value=\"Hello, world.\"/>" |
| 226 "</body></html>"; | 226 "</body></html>"; |
| 227 GURL url(url_str); | 227 GURL url(url_str); |
| 228 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 228 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 229 | 229 |
| 230 const WebAccessibility& tree = GetWebAccessibilityTree(); | 230 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 231 ASSERT_EQ(1U, tree.children.size()); | 231 ASSERT_EQ(1U, tree.children.size()); |
| 232 const WebAccessibility& body = tree.children[0]; | 232 const WebAccessibility& body = tree.children[0]; |
| 233 ASSERT_EQ(1U, body.children.size()); | 233 ASSERT_EQ(1U, body.children.size()); |
| 234 const WebAccessibility& text = body.children[0]; | 234 const WebAccessibility& text = body.children[0]; |
| 235 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text.role); | 235 EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, text.role); |
| 236 EXPECT_STREQ( | 236 EXPECT_STREQ( |
| 237 "input", GetAttr(text, WebAccessibility::ATTR_HTML_TAG).c_str()); | 237 "input", GetAttr(text, WebAccessibility::ATTR_HTML_TAG).c_str()); |
| 238 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_START)); | 238 EXPECT_EQ(0, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_START)); |
| 239 EXPECT_EQ(13, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_END)); | 239 EXPECT_EQ(13, GetIntAttr(text, WebAccessibility::ATTR_TEXT_SEL_END)); |
| 240 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); | 240 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); |
| 241 } | 241 } |
| 242 | 242 |
| 243 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 243 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 244 CrossPlatformMultipleInheritanceAccessibility) { | 244 CrossPlatformMultipleInheritanceAccessibility) { |
| 245 // In a WebKit accessibility render tree for a table, each cell is a | 245 // In a WebKit accessibility render tree for a table, each cell is a |
| 246 // child of both a row and a column, so it appears to use multiple | 246 // child of both a row and a column, so it appears to use multiple |
| 247 // inheritance. Make sure that the WebAccessibilityObject tree only | 247 // inheritance. Make sure that the WebAccessibilityObject tree only |
| 248 // keeps one copy of each cell, and uses an indirect child id for the | 248 // keeps one copy of each cell, and uses an indirect child id for the |
| 249 // additional reference to it. | 249 // additional reference to it. |
| 250 const char url_str[] = | 250 const char url_str[] = |
| 251 "data:text/html," | 251 "data:text/html," |
| 252 "<!doctype html>" | 252 "<!doctype html>" |
| 253 "<table border=1><tr><td>1</td><td>2</td></tr></table>"; | 253 "<table border=1><tr><td>1</td><td>2</td></tr></table>"; |
| 254 GURL url(url_str); | 254 GURL url(url_str); |
| 255 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 255 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 256 | 256 |
| 257 const WebAccessibility& tree = GetWebAccessibilityTree(); | 257 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 258 ASSERT_EQ(1U, tree.children.size()); | 258 ASSERT_EQ(1U, tree.children.size()); |
| 259 const WebAccessibility& table = tree.children[0]; | 259 const WebAccessibility& table = tree.children[0]; |
| 260 EXPECT_EQ(WebAccessibility::ROLE_TABLE, table.role); | 260 EXPECT_EQ(WebAccessibility::ROLE_TABLE, table.role); |
| 261 const WebAccessibility& row = table.children[0]; | 261 const WebAccessibility& row = table.children[0]; |
| 262 EXPECT_EQ(WebAccessibility::ROLE_ROW, row.role); | 262 EXPECT_EQ(WebAccessibility::ROLE_ROW, row.role); |
| 263 const WebAccessibility& cell1 = row.children[0]; | 263 const WebAccessibility& cell1 = row.children[0]; |
| 264 EXPECT_EQ(WebAccessibility::ROLE_CELL, cell1.role); | 264 EXPECT_EQ(WebAccessibility::ROLE_CELL, cell1.role); |
| 265 const WebAccessibility& cell2 = row.children[1]; | 265 const WebAccessibility& cell2 = row.children[1]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 284 const char url_str[] = | 284 const char url_str[] = |
| 285 "data:text/html," | 285 "data:text/html," |
| 286 "<!doctype html>" | 286 "<!doctype html>" |
| 287 "<script>\n" | 287 "<script>\n" |
| 288 " document.writeln('<q><section></section></q><q><li>');\n" | 288 " document.writeln('<q><section></section></q><q><li>');\n" |
| 289 " setTimeout(function() {\n" | 289 " setTimeout(function() {\n" |
| 290 " document.close();\n" | 290 " document.close();\n" |
| 291 " }, 1);\n" | 291 " }, 1);\n" |
| 292 "</script>"; | 292 "</script>"; |
| 293 GURL url(url_str); | 293 GURL url(url_str); |
| 294 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 294 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 295 | 295 |
| 296 const WebAccessibility& tree = GetWebAccessibilityTree(); | 296 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 297 base::hash_set<int> ids; | 297 base::hash_set<int> ids; |
| 298 RecursiveAssertUniqueIds(tree, &ids); | 298 RecursiveAssertUniqueIds(tree, &ids); |
| 299 } | 299 } |
| 300 | 300 |
| 301 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 301 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 302 CrossPlatformIframeAccessibility) { | 302 CrossPlatformIframeAccessibility) { |
| 303 // Create a data url and load it. | 303 // Create a data url and load it. |
| 304 const char url_str[] = | 304 const char url_str[] = |
| 305 "data:text/html," | 305 "data:text/html," |
| 306 "<!doctype html><html><body>" | 306 "<!doctype html><html><body>" |
| 307 "<button>Button 1</button>" | 307 "<button>Button 1</button>" |
| 308 "<iframe src='data:text/html," | 308 "<iframe src='data:text/html," |
| 309 "<!doctype html><html><body><button>Button 2</button></body></html>" | 309 "<!doctype html><html><body><button>Button 2</button></body></html>" |
| 310 "'></iframe>" | 310 "'></iframe>" |
| 311 "<button>Button 3</button>" | 311 "<button>Button 3</button>" |
| 312 "</body></html>"; | 312 "</body></html>"; |
| 313 GURL url(url_str); | 313 GURL url(url_str); |
| 314 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 314 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 315 | 315 |
| 316 const WebAccessibility& tree = GetWebAccessibilityTree(); | 316 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 317 ASSERT_EQ(1U, tree.children.size()); | 317 ASSERT_EQ(1U, tree.children.size()); |
| 318 const WebAccessibility& body = tree.children[0]; | 318 const WebAccessibility& body = tree.children[0]; |
| 319 ASSERT_EQ(3U, body.children.size()); | 319 ASSERT_EQ(3U, body.children.size()); |
| 320 | 320 |
| 321 const WebAccessibility& button1 = body.children[0]; | 321 const WebAccessibility& button1 = body.children[0]; |
| 322 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, button1.role); | 322 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, button1.role); |
| 323 EXPECT_STREQ("Button 1", UTF16ToUTF8(button1.name).c_str()); | 323 EXPECT_STREQ("Button 1", UTF16ToUTF8(button1.name).c_str()); |
| 324 | 324 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 350 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 350 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 351 CrossPlatformDuplicateChildrenAccessibility) { | 351 CrossPlatformDuplicateChildrenAccessibility) { |
| 352 // Here's another html snippet where WebKit has a parent node containing | 352 // Here's another html snippet where WebKit has a parent node containing |
| 353 // two duplicate child nodes. Instead of checking the exact output, just | 353 // two duplicate child nodes. Instead of checking the exact output, just |
| 354 // make sure that no id is reused in the resulting tree. | 354 // make sure that no id is reused in the resulting tree. |
| 355 const char url_str[] = | 355 const char url_str[] = |
| 356 "data:text/html," | 356 "data:text/html," |
| 357 "<!doctype html>" | 357 "<!doctype html>" |
| 358 "<em><code ><h4 ></em>"; | 358 "<em><code ><h4 ></em>"; |
| 359 GURL url(url_str); | 359 GURL url(url_str); |
| 360 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 360 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 361 | 361 |
| 362 const WebAccessibility& tree = GetWebAccessibilityTree(); | 362 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 363 base::hash_set<int> ids; | 363 base::hash_set<int> ids; |
| 364 RecursiveAssertUniqueIds(tree, &ids); | 364 RecursiveAssertUniqueIds(tree, &ids); |
| 365 } | 365 } |
| 366 | 366 |
| 367 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 367 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 368 CrossPlatformTableSpan) { | 368 CrossPlatformTableSpan) { |
| 369 // +---+---+---+ | 369 // +---+---+---+ |
| 370 // | 1 | 2 | | 370 // | 1 | 2 | |
| 371 // +---+---+---+ | 371 // +---+---+---+ |
| 372 // | 3 | 4 | | 372 // | 3 | 4 | |
| 373 // +---+---+---+ | 373 // +---+---+---+ |
| 374 | 374 |
| 375 const char url_str[] = | 375 const char url_str[] = |
| 376 "data:text/html," | 376 "data:text/html," |
| 377 "<!doctype html>" | 377 "<!doctype html>" |
| 378 "<table border=1>" | 378 "<table border=1>" |
| 379 " <tr>" | 379 " <tr>" |
| 380 " <td colspan=2>1</td><td>2</td>" | 380 " <td colspan=2>1</td><td>2</td>" |
| 381 " </tr>" | 381 " </tr>" |
| 382 " <tr>" | 382 " <tr>" |
| 383 " <td>3</td><td colspan=2>4</td>" | 383 " <td>3</td><td colspan=2>4</td>" |
| 384 " </tr>" | 384 " </tr>" |
| 385 "</table>"; | 385 "</table>"; |
| 386 GURL url(url_str); | 386 GURL url(url_str); |
| 387 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 387 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 388 | 388 |
| 389 const WebAccessibility& tree = GetWebAccessibilityTree(); | 389 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 390 const WebAccessibility& table = tree.children[0]; | 390 const WebAccessibility& table = tree.children[0]; |
| 391 EXPECT_EQ(WebAccessibility::ROLE_TABLE, table.role); | 391 EXPECT_EQ(WebAccessibility::ROLE_TABLE, table.role); |
| 392 ASSERT_GE(table.children.size(), 5U); | 392 ASSERT_GE(table.children.size(), 5U); |
| 393 EXPECT_EQ(WebAccessibility::ROLE_ROW, table.children[0].role); | 393 EXPECT_EQ(WebAccessibility::ROLE_ROW, table.children[0].role); |
| 394 EXPECT_EQ(WebAccessibility::ROLE_ROW, table.children[1].role); | 394 EXPECT_EQ(WebAccessibility::ROLE_ROW, table.children[1].role); |
| 395 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[2].role); | 395 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[2].role); |
| 396 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[3].role); | 396 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[3].role); |
| 397 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[4].role); | 397 EXPECT_EQ(WebAccessibility::ROLE_COLUMN, table.children[4].role); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 435 |
| 436 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | 436 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, |
| 437 CrossPlatformWritableElement) { | 437 CrossPlatformWritableElement) { |
| 438 const char url_str[] = | 438 const char url_str[] = |
| 439 "data:text/html," | 439 "data:text/html," |
| 440 "<!doctype html>" | 440 "<!doctype html>" |
| 441 "<div role='textbox' tabindex=0>" | 441 "<div role='textbox' tabindex=0>" |
| 442 " Some text" | 442 " Some text" |
| 443 "</div>"; | 443 "</div>"; |
| 444 GURL url(url_str); | 444 GURL url(url_str); |
| 445 browser()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 445 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 446 const WebAccessibility& tree = GetWebAccessibilityTree(); | 446 const WebAccessibility& tree = GetWebAccessibilityTree(); |
| 447 | 447 |
| 448 ASSERT_EQ(1U, tree.children.size()); | 448 ASSERT_EQ(1U, tree.children.size()); |
| 449 const WebAccessibility& textbox = tree.children[0]; | 449 const WebAccessibility& textbox = tree.children[0]; |
| 450 | 450 |
| 451 EXPECT_EQ( | 451 EXPECT_EQ( |
| 452 true, GetBoolAttr(textbox, WebAccessibility::ATTR_CAN_SET_VALUE)); | 452 true, GetBoolAttr(textbox, WebAccessibility::ATTR_CAN_SET_VALUE)); |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace | 455 } // namespace |
| OLD | NEW |