| 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 "content/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 // Actual tests --------------------------------------------------------------- | 118 // Actual tests --------------------------------------------------------------- |
| 119 | 119 |
| 120 // Test that BrowserAccessibilityManager correctly releases the tree of | 120 // Test that BrowserAccessibilityManager correctly releases the tree of |
| 121 // BrowserAccessibility instances upon delete. | 121 // BrowserAccessibility instances upon delete. |
| 122 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { | 122 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { |
| 123 // Create ui::AXNodeData objects for a simple document tree, | 123 // Create ui::AXNodeData objects for a simple document tree, |
| 124 // representing the accessibility information used to initialize | 124 // representing the accessibility information used to initialize |
| 125 // BrowserAccessibilityManager. | 125 // BrowserAccessibilityManager. |
| 126 ui::AXNodeData button; | 126 ui::AXNodeData button; |
| 127 button.ClearBitfields(); |
| 127 button.id = 2; | 128 button.id = 2; |
| 128 button.SetName("Button"); | 129 button.SetName("Button"); |
| 129 button.role = ui::AX_ROLE_BUTTON; | 130 button.role = ui::AX_ROLE_BUTTON; |
| 130 button.state = 0; | |
| 131 | 131 |
| 132 ui::AXNodeData checkbox; | 132 ui::AXNodeData checkbox; |
| 133 checkbox.ClearBitfields(); |
| 133 checkbox.id = 3; | 134 checkbox.id = 3; |
| 134 checkbox.SetName("Checkbox"); | 135 checkbox.SetName("Checkbox"); |
| 135 checkbox.role = ui::AX_ROLE_CHECK_BOX; | 136 checkbox.role = ui::AX_ROLE_CHECK_BOX; |
| 136 checkbox.state = 0; | |
| 137 | 137 |
| 138 ui::AXNodeData root; | 138 ui::AXNodeData root; |
| 139 root.ClearBitfields(); |
| 139 root.id = 1; | 140 root.id = 1; |
| 140 root.SetName("Document"); | 141 root.SetName("Document"); |
| 141 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 142 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 142 root.state = 0; | |
| 143 root.child_ids.push_back(2); | 143 root.child_ids.push_back(2); |
| 144 root.child_ids.push_back(3); | 144 root.child_ids.push_back(3); |
| 145 | 145 |
| 146 // Construct a BrowserAccessibilityManager with this | 146 // Construct a BrowserAccessibilityManager with this |
| 147 // ui::AXNodeData tree and a factory for an instance-counting | 147 // ui::AXNodeData tree and a factory for an instance-counting |
| 148 // BrowserAccessibility, and ensure that exactly 3 instances were | 148 // BrowserAccessibility, and ensure that exactly 3 instances were |
| 149 // created. Note that the manager takes ownership of the factory. | 149 // created. Note that the manager takes ownership of the factory. |
| 150 CountedBrowserAccessibility::reset(); | 150 CountedBrowserAccessibility::reset(); |
| 151 std::unique_ptr<BrowserAccessibilityManager> manager( | 151 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 152 BrowserAccessibilityManager::Create( | 152 BrowserAccessibilityManager::Create( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); | 185 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); |
| 186 child1_iaccessible->Release(); | 186 child1_iaccessible->Release(); |
| 187 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 187 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 TEST_F(BrowserAccessibilityTest, TestChildrenChange) { | 190 TEST_F(BrowserAccessibilityTest, TestChildrenChange) { |
| 191 // Create ui::AXNodeData objects for a simple document tree, | 191 // Create ui::AXNodeData objects for a simple document tree, |
| 192 // representing the accessibility information used to initialize | 192 // representing the accessibility information used to initialize |
| 193 // BrowserAccessibilityManager. | 193 // BrowserAccessibilityManager. |
| 194 ui::AXNodeData text; | 194 ui::AXNodeData text; |
| 195 text.ClearBitfields(); |
| 195 text.id = 2; | 196 text.id = 2; |
| 196 text.role = ui::AX_ROLE_STATIC_TEXT; | 197 text.role = ui::AX_ROLE_STATIC_TEXT; |
| 197 text.SetName("old text"); | 198 text.SetName("old text"); |
| 198 text.state = 0; | |
| 199 | 199 |
| 200 ui::AXNodeData root; | 200 ui::AXNodeData root; |
| 201 root.ClearBitfields(); |
| 201 root.id = 1; | 202 root.id = 1; |
| 202 root.SetName("Document"); | 203 root.SetName("Document"); |
| 203 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 204 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 204 root.state = 0; | |
| 205 root.child_ids.push_back(2); | 205 root.child_ids.push_back(2); |
| 206 | 206 |
| 207 // Construct a BrowserAccessibilityManager with this | 207 // Construct a BrowserAccessibilityManager with this |
| 208 // ui::AXNodeData tree and a factory for an instance-counting | 208 // ui::AXNodeData tree and a factory for an instance-counting |
| 209 // BrowserAccessibility. | 209 // BrowserAccessibility. |
| 210 CountedBrowserAccessibility::reset(); | 210 CountedBrowserAccessibility::reset(); |
| 211 std::unique_ptr<BrowserAccessibilityManager> manager( | 211 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 212 BrowserAccessibilityManager::Create( | 212 BrowserAccessibilityManager::Create( |
| 213 MakeAXTreeUpdate(root, text), nullptr, | 213 MakeAXTreeUpdate(root, text), nullptr, |
| 214 new CountedBrowserAccessibilityFactory())); | 214 new CountedBrowserAccessibilityFactory())); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // deleted. | 268 // deleted. |
| 269 manager.reset(); | 269 manager.reset(); |
| 270 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 270 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { | 273 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { |
| 274 // Create ui::AXNodeData objects for a simple document tree, | 274 // Create ui::AXNodeData objects for a simple document tree, |
| 275 // representing the accessibility information used to initialize | 275 // representing the accessibility information used to initialize |
| 276 // BrowserAccessibilityManager. | 276 // BrowserAccessibilityManager. |
| 277 ui::AXNodeData div; | 277 ui::AXNodeData div; |
| 278 div.ClearBitfields(); |
| 278 div.id = 2; | 279 div.id = 2; |
| 279 div.role = ui::AX_ROLE_GROUP; | 280 div.role = ui::AX_ROLE_GROUP; |
| 280 div.state = 0; | |
| 281 | 281 |
| 282 ui::AXNodeData text3; | 282 ui::AXNodeData text3; |
| 283 text3.ClearBitfields(); |
| 283 text3.id = 3; | 284 text3.id = 3; |
| 284 text3.role = ui::AX_ROLE_STATIC_TEXT; | 285 text3.role = ui::AX_ROLE_STATIC_TEXT; |
| 285 text3.state = 0; | |
| 286 | 286 |
| 287 ui::AXNodeData text4; | 287 ui::AXNodeData text4; |
| 288 text4.ClearBitfields(); |
| 288 text4.id = 4; | 289 text4.id = 4; |
| 289 text4.role = ui::AX_ROLE_STATIC_TEXT; | 290 text4.role = ui::AX_ROLE_STATIC_TEXT; |
| 290 text4.state = 0; | |
| 291 | 291 |
| 292 div.child_ids.push_back(3); | 292 div.child_ids.push_back(3); |
| 293 div.child_ids.push_back(4); | 293 div.child_ids.push_back(4); |
| 294 | 294 |
| 295 ui::AXNodeData root; | 295 ui::AXNodeData root; |
| 296 root.ClearBitfields(); |
| 296 root.id = 1; | 297 root.id = 1; |
| 297 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 298 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 298 root.state = 0; | |
| 299 root.child_ids.push_back(2); | 299 root.child_ids.push_back(2); |
| 300 | 300 |
| 301 // Construct a BrowserAccessibilityManager with this | 301 // Construct a BrowserAccessibilityManager with this |
| 302 // ui::AXNodeData tree and a factory for an instance-counting | 302 // ui::AXNodeData tree and a factory for an instance-counting |
| 303 // BrowserAccessibility and ensure that exactly 4 instances were | 303 // BrowserAccessibility and ensure that exactly 4 instances were |
| 304 // created. Note that the manager takes ownership of the factory. | 304 // created. Note that the manager takes ownership of the factory. |
| 305 CountedBrowserAccessibility::reset(); | 305 CountedBrowserAccessibility::reset(); |
| 306 std::unique_ptr<BrowserAccessibilityManager> manager( | 306 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 307 BrowserAccessibilityManager::Create( | 307 BrowserAccessibilityManager::Create( |
| 308 MakeAXTreeUpdate(root, div, text3, text4), nullptr, | 308 MakeAXTreeUpdate(root, div, text3, text4), nullptr, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 331 std::string line1 = "One two three."; | 331 std::string line1 = "One two three."; |
| 332 std::string line2 = "Four five six."; | 332 std::string line2 = "Four five six."; |
| 333 std::string text_value = line1 + '\n' + line2; | 333 std::string text_value = line1 + '\n' + line2; |
| 334 | 334 |
| 335 ui::AXNodeData root; | 335 ui::AXNodeData root; |
| 336 root.id = 1; | 336 root.id = 1; |
| 337 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 337 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 338 root.child_ids.push_back(2); | 338 root.child_ids.push_back(2); |
| 339 | 339 |
| 340 ui::AXNodeData text_field; | 340 ui::AXNodeData text_field; |
| 341 text_field.ClearBitfields(); |
| 341 text_field.id = 2; | 342 text_field.id = 2; |
| 342 text_field.role = ui::AX_ROLE_TEXT_FIELD; | 343 text_field.role = ui::AX_ROLE_TEXT_FIELD; |
| 343 text_field.state = 1 << ui::AX_STATE_EDITABLE; | 344 text_field.AddState(ui::AX_STATE_EDITABLE); |
| 344 text_field.SetValue(text_value); | 345 text_field.SetValue(text_value); |
| 345 std::vector<int32_t> line_start_offsets; | 346 std::vector<int32_t> line_start_offsets; |
| 346 line_start_offsets.push_back(15); | 347 line_start_offsets.push_back(15); |
| 347 text_field.AddIntListAttribute(ui::AX_ATTR_CACHED_LINE_STARTS, | 348 text_field.AddIntListAttribute(ui::AX_ATTR_CACHED_LINE_STARTS, |
| 348 line_start_offsets); | 349 line_start_offsets); |
| 349 text_field.child_ids.push_back(3); | 350 text_field.child_ids.push_back(3); |
| 350 text_field.child_ids.push_back(5); | 351 text_field.child_ids.push_back(5); |
| 351 text_field.child_ids.push_back(6); | 352 text_field.child_ids.push_back(6); |
| 352 | 353 |
| 353 ui::AXNodeData static_text1; | 354 ui::AXNodeData static_text1; |
| 355 static_text1.ClearBitfields(); |
| 354 static_text1.id = 3; | 356 static_text1.id = 3; |
| 355 static_text1.role = ui::AX_ROLE_STATIC_TEXT; | 357 static_text1.role = ui::AX_ROLE_STATIC_TEXT; |
| 356 static_text1.state = 1 << ui::AX_STATE_EDITABLE; | 358 static_text1.AddState(ui::AX_STATE_EDITABLE); |
| 357 static_text1.SetName(line1); | 359 static_text1.SetName(line1); |
| 358 static_text1.child_ids.push_back(4); | 360 static_text1.child_ids.push_back(4); |
| 359 | 361 |
| 360 ui::AXNodeData inline_box1; | 362 ui::AXNodeData inline_box1; |
| 363 inline_box1.ClearBitfields(); |
| 361 inline_box1.id = 4; | 364 inline_box1.id = 4; |
| 362 inline_box1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 365 inline_box1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 363 inline_box1.state = 1 << ui::AX_STATE_EDITABLE; | 366 inline_box1.AddState(ui::AX_STATE_EDITABLE); |
| 364 inline_box1.SetName(line1); | 367 inline_box1.SetName(line1); |
| 365 std::vector<int32_t> word_start_offsets1; | 368 std::vector<int32_t> word_start_offsets1; |
| 366 word_start_offsets1.push_back(0); | 369 word_start_offsets1.push_back(0); |
| 367 word_start_offsets1.push_back(4); | 370 word_start_offsets1.push_back(4); |
| 368 word_start_offsets1.push_back(8); | 371 word_start_offsets1.push_back(8); |
| 369 inline_box1.AddIntListAttribute( | 372 inline_box1.AddIntListAttribute( |
| 370 ui::AX_ATTR_WORD_STARTS, word_start_offsets1); | 373 ui::AX_ATTR_WORD_STARTS, word_start_offsets1); |
| 371 | 374 |
| 372 ui::AXNodeData line_break; | 375 ui::AXNodeData line_break; |
| 376 line_break.ClearBitfields(); |
| 373 line_break.id = 5; | 377 line_break.id = 5; |
| 374 line_break.role = ui::AX_ROLE_LINE_BREAK; | 378 line_break.role = ui::AX_ROLE_LINE_BREAK; |
| 375 line_break.state = 1 << ui::AX_STATE_EDITABLE; | 379 line_break.AddState(ui::AX_STATE_EDITABLE); |
| 376 line_break.SetName("\n"); | 380 line_break.SetName("\n"); |
| 377 | 381 |
| 378 ui::AXNodeData static_text2; | 382 ui::AXNodeData static_text2; |
| 383 static_text2.ClearBitfields(); |
| 379 static_text2.id = 6; | 384 static_text2.id = 6; |
| 380 static_text2.role = ui::AX_ROLE_STATIC_TEXT; | 385 static_text2.role = ui::AX_ROLE_STATIC_TEXT; |
| 381 static_text2.state = 1 << ui::AX_STATE_EDITABLE; | 386 static_text2.AddState(ui::AX_STATE_EDITABLE); |
| 382 static_text2.SetName(line2); | 387 static_text2.SetName(line2); |
| 383 static_text2.child_ids.push_back(7); | 388 static_text2.child_ids.push_back(7); |
| 384 | 389 |
| 385 ui::AXNodeData inline_box2; | 390 ui::AXNodeData inline_box2; |
| 391 inline_box2.ClearBitfields(); |
| 386 inline_box2.id = 7; | 392 inline_box2.id = 7; |
| 387 inline_box2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 393 inline_box2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 388 inline_box2.state = 1 << ui::AX_STATE_EDITABLE; | 394 inline_box2.AddState(ui::AX_STATE_EDITABLE); |
| 389 inline_box2.SetName(line2); | 395 inline_box2.SetName(line2); |
| 390 std::vector<int32_t> word_start_offsets2; | 396 std::vector<int32_t> word_start_offsets2; |
| 391 word_start_offsets2.push_back(0); | 397 word_start_offsets2.push_back(0); |
| 392 word_start_offsets2.push_back(5); | 398 word_start_offsets2.push_back(5); |
| 393 word_start_offsets2.push_back(10); | 399 word_start_offsets2.push_back(10); |
| 394 inline_box2.AddIntListAttribute( | 400 inline_box2.AddIntListAttribute( |
| 395 ui::AX_ATTR_WORD_STARTS, word_start_offsets2); | 401 ui::AX_ATTR_WORD_STARTS, word_start_offsets2); |
| 396 | 402 |
| 397 CountedBrowserAccessibility::reset(); | 403 CountedBrowserAccessibility::reset(); |
| 398 std::unique_ptr<BrowserAccessibilityManager> manager( | 404 std::unique_ptr<BrowserAccessibilityManager> manager( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 manager.reset(); | 496 manager.reset(); |
| 491 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 497 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 492 } | 498 } |
| 493 | 499 |
| 494 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { | 500 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { |
| 495 const std::string text1_name = "One two three."; | 501 const std::string text1_name = "One two three."; |
| 496 const std::string text2_name = " Four five six."; | 502 const std::string text2_name = " Four five six."; |
| 497 const long text_name_len = text1_name.length() + text2_name.length(); | 503 const long text_name_len = text1_name.length() + text2_name.length(); |
| 498 | 504 |
| 499 ui::AXNodeData text1; | 505 ui::AXNodeData text1; |
| 506 text1.ClearBitfields(); |
| 500 text1.id = 11; | 507 text1.id = 11; |
| 501 text1.role = ui::AX_ROLE_STATIC_TEXT; | 508 text1.role = ui::AX_ROLE_STATIC_TEXT; |
| 502 text1.state = 1 << ui::AX_STATE_READ_ONLY; | 509 text1.AddState(ui::AX_STATE_READ_ONLY); |
| 503 text1.SetName(text1_name); | 510 text1.SetName(text1_name); |
| 504 | 511 |
| 505 ui::AXNodeData text2; | 512 ui::AXNodeData text2; |
| 513 text2.ClearBitfields(); |
| 506 text2.id = 12; | 514 text2.id = 12; |
| 507 text2.role = ui::AX_ROLE_STATIC_TEXT; | 515 text2.role = ui::AX_ROLE_STATIC_TEXT; |
| 508 text2.state = 1 << ui::AX_STATE_READ_ONLY; | 516 text2.AddState(ui::AX_STATE_READ_ONLY); |
| 509 text2.SetName(text2_name); | 517 text2.SetName(text2_name); |
| 510 | 518 |
| 511 ui::AXNodeData root; | 519 ui::AXNodeData root; |
| 520 root.ClearBitfields(); |
| 512 root.id = 1; | 521 root.id = 1; |
| 513 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 522 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 514 root.state = 1 << ui::AX_STATE_READ_ONLY; | 523 root.AddState(ui::AX_STATE_READ_ONLY); |
| 515 root.child_ids.push_back(text1.id); | 524 root.child_ids.push_back(text1.id); |
| 516 root.child_ids.push_back(text2.id); | 525 root.child_ids.push_back(text2.id); |
| 517 | 526 |
| 518 CountedBrowserAccessibility::reset(); | 527 CountedBrowserAccessibility::reset(); |
| 519 std::unique_ptr<BrowserAccessibilityManager> manager( | 528 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 520 BrowserAccessibilityManager::Create( | 529 BrowserAccessibilityManager::Create( |
| 521 MakeAXTreeUpdate(root, text1, text2), nullptr, | 530 MakeAXTreeUpdate(root, text1, text2), nullptr, |
| 522 new CountedBrowserAccessibilityFactory())); | 531 new CountedBrowserAccessibilityFactory())); |
| 523 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); | 532 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
| 524 | 533 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 const base::string16 button_text_name = L"Red"; | 582 const base::string16 button_text_name = L"Red"; |
| 574 const base::string16 link_text_name = L"Blue"; | 583 const base::string16 link_text_name = L"Blue"; |
| 575 // Each control (combo / check box, button and link) will be represented by an | 584 // Each control (combo / check box, button and link) will be represented by an |
| 576 // embedded object character. | 585 // embedded object character. |
| 577 const base::string16 embed(1, BrowserAccessibilityWin::kEmbeddedCharacter); | 586 const base::string16 embed(1, BrowserAccessibilityWin::kEmbeddedCharacter); |
| 578 const base::string16 root_hypertext = | 587 const base::string16 root_hypertext = |
| 579 text1_name + embed + text2_name + embed + embed + embed; | 588 text1_name + embed + text2_name + embed + embed + embed; |
| 580 const long root_hypertext_len = root_hypertext.length(); | 589 const long root_hypertext_len = root_hypertext.length(); |
| 581 | 590 |
| 582 ui::AXNodeData text1; | 591 ui::AXNodeData text1; |
| 592 text1.ClearBitfields(); |
| 583 text1.id = 11; | 593 text1.id = 11; |
| 584 text1.role = ui::AX_ROLE_STATIC_TEXT; | 594 text1.role = ui::AX_ROLE_STATIC_TEXT; |
| 585 text1.state = 1 << ui::AX_STATE_READ_ONLY; | 595 text1.AddState(ui::AX_STATE_READ_ONLY); |
| 586 text1.SetName(base::UTF16ToUTF8(text1_name)); | 596 text1.SetName(base::UTF16ToUTF8(text1_name)); |
| 587 | 597 |
| 588 ui::AXNodeData combo_box; | 598 ui::AXNodeData combo_box; |
| 589 combo_box.id = 12; | 599 combo_box.id = 12; |
| 590 combo_box.role = ui::AX_ROLE_COMBO_BOX; | 600 combo_box.role = ui::AX_ROLE_COMBO_BOX; |
| 591 combo_box.SetName(base::UTF16ToUTF8(combo_box_name)); | 601 combo_box.SetName(base::UTF16ToUTF8(combo_box_name)); |
| 592 combo_box.SetValue(base::UTF16ToUTF8(combo_box_value)); | 602 combo_box.SetValue(base::UTF16ToUTF8(combo_box_value)); |
| 593 | 603 |
| 594 ui::AXNodeData text2; | 604 ui::AXNodeData text2; |
| 605 text2.ClearBitfields(); |
| 595 text2.id = 13; | 606 text2.id = 13; |
| 596 text2.role = ui::AX_ROLE_STATIC_TEXT; | 607 text2.role = ui::AX_ROLE_STATIC_TEXT; |
| 597 text2.state = 1 << ui::AX_STATE_READ_ONLY; | 608 text2.AddState(ui::AX_STATE_READ_ONLY); |
| 598 text2.SetName(base::UTF16ToUTF8(text2_name)); | 609 text2.SetName(base::UTF16ToUTF8(text2_name)); |
| 599 | 610 |
| 600 ui::AXNodeData check_box; | 611 ui::AXNodeData check_box; |
| 612 check_box.ClearBitfields(); |
| 601 check_box.id = 14; | 613 check_box.id = 14; |
| 602 check_box.role = ui::AX_ROLE_CHECK_BOX; | 614 check_box.role = ui::AX_ROLE_CHECK_BOX; |
| 603 check_box.state = 0; | |
| 604 check_box.AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, | 615 check_box.AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, |
| 605 ui::AX_CHECKED_STATE_TRUE); | 616 ui::AX_CHECKED_STATE_TRUE); |
| 606 check_box.SetName(base::UTF16ToUTF8(check_box_name)); | 617 check_box.SetName(base::UTF16ToUTF8(check_box_name)); |
| 607 check_box.SetValue(base::UTF16ToUTF8(check_box_value)); | 618 check_box.SetValue(base::UTF16ToUTF8(check_box_value)); |
| 608 | 619 |
| 609 ui::AXNodeData button, button_text; | 620 ui::AXNodeData button, button_text; |
| 621 button.ClearBitfields(); |
| 622 button_text.ClearBitfields(); |
| 610 button.id = 15; | 623 button.id = 15; |
| 611 button_text.id = 17; | 624 button_text.id = 17; |
| 612 button_text.SetName(base::UTF16ToUTF8(button_text_name)); | 625 button_text.SetName(base::UTF16ToUTF8(button_text_name)); |
| 613 button.role = ui::AX_ROLE_BUTTON; | 626 button.role = ui::AX_ROLE_BUTTON; |
| 614 button_text.role = ui::AX_ROLE_STATIC_TEXT; | 627 button_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 615 button.state = 1 << ui::AX_STATE_READ_ONLY; | 628 button.AddState(ui::AX_STATE_READ_ONLY); |
| 616 button_text.state = 1 << ui::AX_STATE_READ_ONLY; | 629 button_text.AddState(ui::AX_STATE_READ_ONLY); |
| 617 button.child_ids.push_back(button_text.id); | 630 button.child_ids.push_back(button_text.id); |
| 618 | 631 |
| 619 ui::AXNodeData link, link_text; | 632 ui::AXNodeData link, link_text; |
| 633 link.ClearBitfields(); |
| 634 link_text.ClearBitfields(); |
| 620 link.id = 16; | 635 link.id = 16; |
| 621 link_text.id = 18; | 636 link_text.id = 18; |
| 622 link_text.SetName(base::UTF16ToUTF8(link_text_name)); | 637 link_text.SetName(base::UTF16ToUTF8(link_text_name)); |
| 623 link.role = ui::AX_ROLE_LINK; | 638 link.role = ui::AX_ROLE_LINK; |
| 624 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 639 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 625 link.state = 1 << ui::AX_STATE_READ_ONLY; | 640 link.AddState(ui::AX_STATE_READ_ONLY); |
| 626 link_text.state = 1 << ui::AX_STATE_READ_ONLY; | 641 link_text.AddState(ui::AX_STATE_READ_ONLY); |
| 627 link.child_ids.push_back(link_text.id); | 642 link.child_ids.push_back(link_text.id); |
| 628 | 643 |
| 629 ui::AXNodeData root; | 644 ui::AXNodeData root; |
| 645 root.ClearBitfields(); |
| 630 root.id = 1; | 646 root.id = 1; |
| 631 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 647 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 632 root.state = 1 << ui::AX_STATE_READ_ONLY; | 648 root.AddState(ui::AX_STATE_READ_ONLY); |
| 633 root.child_ids.push_back(text1.id); | 649 root.child_ids.push_back(text1.id); |
| 634 root.child_ids.push_back(combo_box.id); | 650 root.child_ids.push_back(combo_box.id); |
| 635 root.child_ids.push_back(text2.id); | 651 root.child_ids.push_back(text2.id); |
| 636 root.child_ids.push_back(check_box.id); | 652 root.child_ids.push_back(check_box.id); |
| 637 root.child_ids.push_back(button.id); | 653 root.child_ids.push_back(button.id); |
| 638 root.child_ids.push_back(link.id); | 654 root.child_ids.push_back(link.id); |
| 639 | 655 |
| 640 CountedBrowserAccessibility::reset(); | 656 CountedBrowserAccessibility::reset(); |
| 641 std::unique_ptr<BrowserAccessibilityManager> manager( | 657 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 642 BrowserAccessibilityManager::Create( | 658 BrowserAccessibilityManager::Create( |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 ui::AXNodeData pseudo_before; | 850 ui::AXNodeData pseudo_before; |
| 835 pseudo_before.id = 2; | 851 pseudo_before.id = 2; |
| 836 pseudo_before.role = ui::AX_ROLE_DIV; | 852 pseudo_before.role = ui::AX_ROLE_DIV; |
| 837 pseudo_before.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "<pseudo:before>"); | 853 pseudo_before.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "<pseudo:before>"); |
| 838 pseudo_before.AddStringAttribute(ui::AX_ATTR_DISPLAY, "none"); | 854 pseudo_before.AddStringAttribute(ui::AX_ATTR_DISPLAY, "none"); |
| 839 | 855 |
| 840 ui::AXNodeData checkbox; | 856 ui::AXNodeData checkbox; |
| 841 checkbox.id = 3; | 857 checkbox.id = 3; |
| 842 checkbox.SetName("Checkbox"); | 858 checkbox.SetName("Checkbox"); |
| 843 checkbox.role = ui::AX_ROLE_CHECK_BOX; | 859 checkbox.role = ui::AX_ROLE_CHECK_BOX; |
| 844 checkbox.state = 0; | 860 checkbox.ClearBitfields(); |
| 845 checkbox.AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, | 861 checkbox.AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, |
| 846 ui::AX_CHECKED_STATE_TRUE); | 862 ui::AX_CHECKED_STATE_TRUE); |
| 847 | 863 |
| 848 ui::AXNodeData root; | 864 ui::AXNodeData root; |
| 865 root.ClearBitfields(); |
| 849 root.id = 1; | 866 root.id = 1; |
| 850 root.SetName("Document"); | 867 root.SetName("Document"); |
| 851 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 868 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 852 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 869 root.AddState(ui::AX_STATE_READ_ONLY); |
| 870 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 853 root.child_ids.push_back(2); | 871 root.child_ids.push_back(2); |
| 854 root.child_ids.push_back(3); | 872 root.child_ids.push_back(3); |
| 855 | 873 |
| 856 CountedBrowserAccessibility::reset(); | 874 CountedBrowserAccessibility::reset(); |
| 857 std::unique_ptr<BrowserAccessibilityManager> manager( | 875 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 858 BrowserAccessibilityManager::Create( | 876 BrowserAccessibilityManager::Create( |
| 859 MakeAXTreeUpdate(root, pseudo_before, checkbox), nullptr, | 877 MakeAXTreeUpdate(root, pseudo_before, checkbox), nullptr, |
| 860 new CountedBrowserAccessibilityFactory())); | 878 new CountedBrowserAccessibilityFactory())); |
| 861 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); | 879 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); |
| 862 | 880 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 887 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); | 905 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); |
| 888 attributes_str = std::wstring(attributes, attributes.Length()); | 906 attributes_str = std::wstring(attributes, attributes.Length()); |
| 889 EXPECT_EQ(L"checkable:true;", attributes_str); | 907 EXPECT_EQ(L"checkable:true;", attributes_str); |
| 890 | 908 |
| 891 manager.reset(); | 909 manager.reset(); |
| 892 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 910 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 893 } | 911 } |
| 894 | 912 |
| 895 TEST_F(BrowserAccessibilityTest, TestValueAttributeInTextControls) { | 913 TEST_F(BrowserAccessibilityTest, TestValueAttributeInTextControls) { |
| 896 ui::AXNodeData root; | 914 ui::AXNodeData root; |
| 915 root.ClearBitfields(); |
| 897 root.id = 1; | 916 root.id = 1; |
| 898 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 917 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 899 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 918 root.AddState(ui::AX_STATE_READ_ONLY); |
| 919 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 900 | 920 |
| 901 ui::AXNodeData combo_box, combo_box_text; | 921 ui::AXNodeData combo_box, combo_box_text; |
| 922 combo_box.ClearBitfields(); |
| 923 combo_box_text.ClearBitfields(); |
| 902 combo_box.id = 2; | 924 combo_box.id = 2; |
| 903 combo_box_text.id = 3; | 925 combo_box_text.id = 3; |
| 904 combo_box.SetName("Combo box:"); | 926 combo_box.SetName("Combo box:"); |
| 905 combo_box_text.SetName("Combo box text"); | 927 combo_box_text.SetName("Combo box text"); |
| 906 combo_box.role = ui::AX_ROLE_COMBO_BOX; | 928 combo_box.role = ui::AX_ROLE_COMBO_BOX; |
| 907 combo_box_text.role = ui::AX_ROLE_STATIC_TEXT; | 929 combo_box_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 908 combo_box.state = (1 << ui::AX_STATE_EDITABLE) | | 930 combo_box.AddState(ui::AX_STATE_EDITABLE); |
| 909 (1 << ui::AX_STATE_FOCUSABLE); | 931 combo_box.AddState(ui::AX_STATE_FOCUSABLE); |
| 910 combo_box_text.state = 1 << ui::AX_STATE_EDITABLE; | 932 combo_box_text.AddState(ui::AX_STATE_EDITABLE); |
| 911 combo_box.child_ids.push_back(combo_box_text.id); | 933 combo_box.child_ids.push_back(combo_box_text.id); |
| 912 | 934 |
| 913 ui::AXNodeData search_box, search_box_text, new_line; | 935 ui::AXNodeData search_box, search_box_text, new_line; |
| 936 search_box.ClearBitfields(); |
| 937 search_box_text.ClearBitfields(); |
| 938 new_line.ClearBitfields(); |
| 914 search_box.id = 4; | 939 search_box.id = 4; |
| 915 search_box_text.id = 5; | 940 search_box_text.id = 5; |
| 916 new_line.id = 6; | 941 new_line.id = 6; |
| 917 search_box.SetName("Search for:"); | 942 search_box.SetName("Search for:"); |
| 918 search_box_text.SetName("Search box text"); | 943 search_box_text.SetName("Search box text"); |
| 919 new_line.SetName("\n"); | 944 new_line.SetName("\n"); |
| 920 search_box.role = ui::AX_ROLE_SEARCH_BOX; | 945 search_box.role = ui::AX_ROLE_SEARCH_BOX; |
| 921 search_box_text.role = ui::AX_ROLE_STATIC_TEXT; | 946 search_box_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 922 new_line.role = ui::AX_ROLE_LINE_BREAK; | 947 new_line.role = ui::AX_ROLE_LINE_BREAK; |
| 923 search_box.state = (1 << ui::AX_STATE_EDITABLE) | | 948 search_box.AddState(ui::AX_STATE_EDITABLE); |
| 924 (1 << ui::AX_STATE_FOCUSABLE); | 949 search_box.AddState(ui::AX_STATE_FOCUSABLE); |
| 925 search_box_text.state = new_line.state = 1 << ui::AX_STATE_EDITABLE; | 950 search_box_text.AddState(ui::AX_STATE_EDITABLE); |
| 951 new_line.AddState(ui::AX_STATE_EDITABLE); |
| 926 search_box.child_ids.push_back(search_box_text.id); | 952 search_box.child_ids.push_back(search_box_text.id); |
| 927 search_box.child_ids.push_back(new_line.id); | 953 search_box.child_ids.push_back(new_line.id); |
| 928 | 954 |
| 929 ui::AXNodeData text_field; | 955 ui::AXNodeData text_field; |
| 956 text_field.ClearBitfields(); |
| 930 text_field.id = 7; | 957 text_field.id = 7; |
| 931 text_field.role = ui::AX_ROLE_TEXT_FIELD; | 958 text_field.role = ui::AX_ROLE_TEXT_FIELD; |
| 932 text_field.state = | 959 text_field.AddState(ui::AX_STATE_EDITABLE); |
| 933 (1 << ui::AX_STATE_EDITABLE) | (1 << ui::AX_STATE_FOCUSABLE); | 960 text_field.AddState(ui::AX_STATE_FOCUSABLE); |
| 934 text_field.SetValue("Text field text"); | 961 text_field.SetValue("Text field text"); |
| 935 | 962 |
| 936 ui::AXNodeData link, link_text; | 963 ui::AXNodeData link, link_text; |
| 964 link.ClearBitfields(); |
| 965 link_text.ClearBitfields(); |
| 937 link.id = 8; | 966 link.id = 8; |
| 938 link_text.id = 9; | 967 link_text.id = 9; |
| 939 link_text.SetName("Link text"); | 968 link_text.SetName("Link text"); |
| 940 link.role = ui::AX_ROLE_LINK; | 969 link.role = ui::AX_ROLE_LINK; |
| 941 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 970 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 942 link.state = link_text.state = 1 << ui::AX_STATE_READ_ONLY; | 971 link.AddState(ui::AX_STATE_READ_ONLY); |
| 972 link_text.AddState(ui::AX_STATE_READ_ONLY); |
| 943 link.child_ids.push_back(link_text.id); | 973 link.child_ids.push_back(link_text.id); |
| 944 | 974 |
| 945 ui::AXNodeData slider, slider_text; | 975 ui::AXNodeData slider, slider_text; |
| 976 slider.ClearBitfields(); |
| 977 slider_text.ClearBitfields(); |
| 946 slider.id = 10; | 978 slider.id = 10; |
| 947 slider_text.id = 11; | 979 slider_text.id = 11; |
| 948 slider.AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, 5.0F); | 980 slider.AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, 5.0F); |
| 949 slider_text.SetName("Slider text"); | 981 slider_text.SetName("Slider text"); |
| 950 slider.role = ui::AX_ROLE_SLIDER; | 982 slider.role = ui::AX_ROLE_SLIDER; |
| 951 slider_text.role = ui::AX_ROLE_STATIC_TEXT; | 983 slider_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 952 slider.state = slider_text.state = 1 << ui::AX_STATE_READ_ONLY; | 984 slider.AddState(ui::AX_STATE_READ_ONLY); |
| 985 slider_text.AddState(ui::AX_STATE_READ_ONLY); |
| 953 slider.child_ids.push_back(slider_text.id); | 986 slider.child_ids.push_back(slider_text.id); |
| 954 | 987 |
| 955 root.child_ids.push_back(2); // Combo box. | 988 root.child_ids.push_back(2); // Combo box. |
| 956 root.child_ids.push_back(4); // Search box. | 989 root.child_ids.push_back(4); // Search box. |
| 957 root.child_ids.push_back(7); // Text field. | 990 root.child_ids.push_back(7); // Text field. |
| 958 root.child_ids.push_back(8); // Link. | 991 root.child_ids.push_back(8); // Link. |
| 959 root.child_ids.push_back(10); // Slider. | 992 root.child_ids.push_back(10); // Slider. |
| 960 | 993 |
| 961 CountedBrowserAccessibility::reset(); | 994 CountedBrowserAccessibility::reset(); |
| 962 std::unique_ptr<BrowserAccessibilityManager> manager( | 995 std::unique_ptr<BrowserAccessibilityManager> manager( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 std::vector<int32_t> line2_word_starts; | 1081 std::vector<int32_t> line2_word_starts; |
| 1049 line2_word_starts.push_back(0); | 1082 line2_word_starts.push_back(0); |
| 1050 line2_word_starts.push_back(7); | 1083 line2_word_starts.push_back(7); |
| 1051 line2_word_starts.push_back(12); | 1084 line2_word_starts.push_back(12); |
| 1052 line2_word_starts.push_back(15); | 1085 line2_word_starts.push_back(15); |
| 1053 line2_word_starts.push_back(20); | 1086 line2_word_starts.push_back(20); |
| 1054 line2_word_starts.push_back(25); | 1087 line2_word_starts.push_back(25); |
| 1055 line2_word_starts.push_back(29); | 1088 line2_word_starts.push_back(29); |
| 1056 | 1089 |
| 1057 ui::AXNodeData root; | 1090 ui::AXNodeData root; |
| 1091 root.ClearBitfields(); |
| 1058 root.id = 1; | 1092 root.id = 1; |
| 1059 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 1093 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 1060 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 1094 root.AddState(ui::AX_STATE_READ_ONLY); |
| 1095 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 1061 | 1096 |
| 1062 ui::AXNodeData textarea, textarea_div, textarea_text; | 1097 ui::AXNodeData textarea, textarea_div, textarea_text; |
| 1098 textarea.ClearBitfields(); |
| 1099 textarea_div.ClearBitfields(); |
| 1100 textarea_text.ClearBitfields(); |
| 1063 textarea.id = 2; | 1101 textarea.id = 2; |
| 1064 textarea_div.id = 3; | 1102 textarea_div.id = 3; |
| 1065 textarea_text.id = 4; | 1103 textarea_text.id = 4; |
| 1066 textarea.role = ui::AX_ROLE_TEXT_FIELD; | 1104 textarea.role = ui::AX_ROLE_TEXT_FIELD; |
| 1067 textarea_div.role = ui::AX_ROLE_DIV; | 1105 textarea_div.role = ui::AX_ROLE_DIV; |
| 1068 textarea_text.role = ui::AX_ROLE_STATIC_TEXT; | 1106 textarea_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1069 textarea.state = (1 << ui::AX_STATE_EDITABLE) | | 1107 textarea.AddState(ui::AX_STATE_EDITABLE); |
| 1070 (1 << ui::AX_STATE_FOCUSABLE) | | 1108 textarea.AddState(ui::AX_STATE_FOCUSABLE); |
| 1071 (1 << ui::AX_STATE_MULTILINE); | 1109 textarea.AddState(ui::AX_STATE_MULTILINE); |
| 1072 textarea_div.state = 1 << ui::AX_STATE_EDITABLE; | 1110 textarea_div.AddState(ui::AX_STATE_EDITABLE); |
| 1073 textarea_text.state = 1 << ui::AX_STATE_EDITABLE; | 1111 textarea_text.AddState(ui::AX_STATE_EDITABLE); |
| 1074 textarea.SetValue(base::UTF16ToUTF8(text)); | 1112 textarea.SetValue(base::UTF16ToUTF8(text)); |
| 1075 textarea_text.SetName(base::UTF16ToUTF8(text)); | 1113 textarea_text.SetName(base::UTF16ToUTF8(text)); |
| 1076 textarea.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "textarea"); | 1114 textarea.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "textarea"); |
| 1077 textarea.child_ids.push_back(textarea_div.id); | 1115 textarea.child_ids.push_back(textarea_div.id); |
| 1078 textarea_div.child_ids.push_back(textarea_text.id); | 1116 textarea_div.child_ids.push_back(textarea_text.id); |
| 1079 | 1117 |
| 1080 ui::AXNodeData textarea_line1, textarea_line2; | 1118 ui::AXNodeData textarea_line1, textarea_line2; |
| 1119 textarea_line1.ClearBitfields(); |
| 1120 textarea_line2.ClearBitfields(); |
| 1081 textarea_line1.id = 5; | 1121 textarea_line1.id = 5; |
| 1082 textarea_line2.id = 6; | 1122 textarea_line2.id = 6; |
| 1083 textarea_line1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 1123 textarea_line1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 1084 textarea_line2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 1124 textarea_line2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 1085 textarea_line1.state = 1 << ui::AX_STATE_EDITABLE; | 1125 textarea_line1.AddState(ui::AX_STATE_EDITABLE); |
| 1086 textarea_line2.state = 1 << ui::AX_STATE_EDITABLE; | 1126 textarea_line2.AddState(ui::AX_STATE_EDITABLE); |
| 1087 textarea_line1.SetName(base::UTF16ToUTF8(line1)); | 1127 textarea_line1.SetName(base::UTF16ToUTF8(line1)); |
| 1088 textarea_line2.SetName(base::UTF16ToUTF8(line2)); | 1128 textarea_line2.SetName(base::UTF16ToUTF8(line2)); |
| 1089 textarea_line1.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, | 1129 textarea_line1.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, |
| 1090 line1_word_starts); | 1130 line1_word_starts); |
| 1091 textarea_line2.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, | 1131 textarea_line2.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, |
| 1092 line2_word_starts); | 1132 line2_word_starts); |
| 1093 textarea_text.child_ids.push_back(textarea_line1.id); | 1133 textarea_text.child_ids.push_back(textarea_line1.id); |
| 1094 textarea_text.child_ids.push_back(textarea_line2.id); | 1134 textarea_text.child_ids.push_back(textarea_line2.id); |
| 1095 | 1135 |
| 1096 ui::AXNodeData text_field, text_field_div, text_field_text; | 1136 ui::AXNodeData text_field, text_field_div, text_field_text; |
| 1137 text_field.ClearBitfields(); |
| 1138 text_field_div.ClearBitfields(); |
| 1139 text_field_text.ClearBitfields(); |
| 1097 text_field.id = 7; | 1140 text_field.id = 7; |
| 1098 text_field_div.id = 8; | 1141 text_field_div.id = 8; |
| 1099 text_field_text.id = 9; | 1142 text_field_text.id = 9; |
| 1100 text_field.role = ui::AX_ROLE_TEXT_FIELD; | 1143 text_field.role = ui::AX_ROLE_TEXT_FIELD; |
| 1101 text_field_div.role = ui::AX_ROLE_DIV; | 1144 text_field_div.role = ui::AX_ROLE_DIV; |
| 1102 text_field_text.role = ui::AX_ROLE_STATIC_TEXT; | 1145 text_field_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1103 text_field.state = | 1146 text_field.AddState(ui::AX_STATE_EDITABLE); |
| 1104 (1 << ui::AX_STATE_EDITABLE) | (1 << ui::AX_STATE_FOCUSABLE); | 1147 text_field.AddState(ui::AX_STATE_FOCUSABLE); |
| 1105 text_field_div.state = 1 << ui::AX_STATE_EDITABLE; | 1148 text_field_div.AddState(ui::AX_STATE_EDITABLE); |
| 1106 text_field_text.state = 1 << ui::AX_STATE_EDITABLE; | 1149 text_field_text.AddState(ui::AX_STATE_EDITABLE); |
| 1107 text_field.SetValue(base::UTF16ToUTF8(line1)); | 1150 text_field.SetValue(base::UTF16ToUTF8(line1)); |
| 1108 text_field_text.SetName(base::UTF16ToUTF8(line1)); | 1151 text_field_text.SetName(base::UTF16ToUTF8(line1)); |
| 1109 text_field.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "input"); | 1152 text_field.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "input"); |
| 1110 text_field.html_attributes.push_back(std::make_pair("type", "text")); | 1153 text_field.html_attributes.push_back(std::make_pair("type", "text")); |
| 1111 text_field.child_ids.push_back(text_field_div.id); | 1154 text_field.child_ids.push_back(text_field_div.id); |
| 1112 text_field_div.child_ids.push_back(text_field_text.id); | 1155 text_field_div.child_ids.push_back(text_field_text.id); |
| 1113 | 1156 |
| 1114 ui::AXNodeData text_field_line; | 1157 ui::AXNodeData text_field_line; |
| 1158 text_field_line.ClearBitfields(); |
| 1115 text_field_line.id = 10; | 1159 text_field_line.id = 10; |
| 1116 text_field_line.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 1160 text_field_line.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 1117 text_field_line.state = 1 << ui::AX_STATE_EDITABLE; | 1161 text_field_line.AddState(ui::AX_STATE_EDITABLE); |
| 1118 text_field_line.SetName(base::UTF16ToUTF8(line1)); | 1162 text_field_line.SetName(base::UTF16ToUTF8(line1)); |
| 1119 text_field_line.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, | 1163 text_field_line.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, |
| 1120 line1_word_starts); | 1164 line1_word_starts); |
| 1121 text_field_text.child_ids.push_back(text_field_line.id); | 1165 text_field_text.child_ids.push_back(text_field_line.id); |
| 1122 | 1166 |
| 1123 root.child_ids.push_back(2); // Textarea. | 1167 root.child_ids.push_back(2); // Textarea. |
| 1124 root.child_ids.push_back(7); // Text field. | 1168 root.child_ids.push_back(7); // Text field. |
| 1125 | 1169 |
| 1126 CountedBrowserAccessibility::reset(); | 1170 CountedBrowserAccessibility::reset(); |
| 1127 std::unique_ptr<BrowserAccessibilityManager> manager( | 1171 std::unique_ptr<BrowserAccessibilityManager> manager( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 | 1234 |
| 1191 textarea_object.Reset(); | 1235 textarea_object.Reset(); |
| 1192 text_field_object.Reset(); | 1236 text_field_object.Reset(); |
| 1193 | 1237 |
| 1194 manager.reset(); | 1238 manager.reset(); |
| 1195 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 1239 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 1196 } | 1240 } |
| 1197 | 1241 |
| 1198 TEST_F(BrowserAccessibilityTest, TestCaretAndSelectionInSimpleFields) { | 1242 TEST_F(BrowserAccessibilityTest, TestCaretAndSelectionInSimpleFields) { |
| 1199 ui::AXNodeData root; | 1243 ui::AXNodeData root; |
| 1244 root.ClearBitfields(); |
| 1200 root.id = 1; | 1245 root.id = 1; |
| 1201 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 1246 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 1202 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 1247 root.AddState(ui::AX_STATE_READ_ONLY); |
| 1248 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 1203 | 1249 |
| 1204 ui::AXNodeData combo_box; | 1250 ui::AXNodeData combo_box; |
| 1251 combo_box.ClearBitfields(); |
| 1205 combo_box.id = 2; | 1252 combo_box.id = 2; |
| 1206 combo_box.role = ui::AX_ROLE_COMBO_BOX; | 1253 combo_box.role = ui::AX_ROLE_COMBO_BOX; |
| 1207 combo_box.state = (1 << ui::AX_STATE_EDITABLE) | | 1254 combo_box.AddState(ui::AX_STATE_EDITABLE); |
| 1208 (1 << ui::AX_STATE_FOCUSABLE); | 1255 combo_box.AddState(ui::AX_STATE_FOCUSABLE); |
| 1209 combo_box.SetValue("Test1"); | 1256 combo_box.SetValue("Test1"); |
| 1210 // Place the caret between 't' and 'e'. | 1257 // Place the caret between 't' and 'e'. |
| 1211 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); | 1258 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); |
| 1212 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 1); | 1259 combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 1); |
| 1213 | 1260 |
| 1214 ui::AXNodeData text_field; | 1261 ui::AXNodeData text_field; |
| 1262 text_field.ClearBitfields(); |
| 1215 text_field.id = 3; | 1263 text_field.id = 3; |
| 1216 text_field.role = ui::AX_ROLE_TEXT_FIELD; | 1264 text_field.role = ui::AX_ROLE_TEXT_FIELD; |
| 1217 text_field.state = (1 << ui::AX_STATE_EDITABLE) | | 1265 text_field.AddState(ui::AX_STATE_EDITABLE); |
| 1218 (1 << ui::AX_STATE_FOCUSABLE); | 1266 text_field.AddState(ui::AX_STATE_FOCUSABLE); |
| 1219 text_field.SetValue("Test2"); | 1267 text_field.SetValue("Test2"); |
| 1220 // Select the letter 'e'. | 1268 // Select the letter 'e'. |
| 1221 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); | 1269 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); |
| 1222 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 2); | 1270 text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 2); |
| 1223 | 1271 |
| 1224 root.child_ids.push_back(2); | 1272 root.child_ids.push_back(2); |
| 1225 root.child_ids.push_back(3); | 1273 root.child_ids.push_back(3); |
| 1226 | 1274 |
| 1227 CountedBrowserAccessibility::reset(); | 1275 CountedBrowserAccessibility::reset(); |
| 1228 std::unique_ptr<BrowserAccessibilityManager> manager( | 1276 std::unique_ptr<BrowserAccessibilityManager> manager( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 EXPECT_EQ(S_OK, hr); | 1337 EXPECT_EQ(S_OK, hr); |
| 1290 EXPECT_EQ(1, selection_start); | 1338 EXPECT_EQ(1, selection_start); |
| 1291 EXPECT_EQ(2, selection_end); | 1339 EXPECT_EQ(2, selection_end); |
| 1292 | 1340 |
| 1293 manager.reset(); | 1341 manager.reset(); |
| 1294 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 1342 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 1295 } | 1343 } |
| 1296 | 1344 |
| 1297 TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) { | 1345 TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) { |
| 1298 ui::AXNodeData root; | 1346 ui::AXNodeData root; |
| 1347 root.ClearBitfields(); |
| 1299 root.id = 1; | 1348 root.id = 1; |
| 1300 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 1349 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 1301 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 1350 root.AddState(ui::AX_STATE_READ_ONLY); |
| 1351 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 1302 | 1352 |
| 1303 ui::AXNodeData div_editable; | 1353 ui::AXNodeData div_editable; |
| 1354 div_editable.ClearBitfields(); |
| 1304 div_editable.id = 2; | 1355 div_editable.id = 2; |
| 1305 div_editable.role = ui::AX_ROLE_DIV; | 1356 div_editable.role = ui::AX_ROLE_DIV; |
| 1306 div_editable.state = (1 << ui::AX_STATE_EDITABLE) | | 1357 div_editable.AddState(ui::AX_STATE_EDITABLE); |
| 1307 (1 << ui::AX_STATE_FOCUSABLE); | 1358 div_editable.AddState(ui::AX_STATE_FOCUSABLE); |
| 1308 | 1359 |
| 1309 ui::AXNodeData text; | 1360 ui::AXNodeData text; |
| 1361 text.ClearBitfields(); |
| 1310 text.id = 3; | 1362 text.id = 3; |
| 1311 text.role = ui::AX_ROLE_STATIC_TEXT; | 1363 text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1312 text.state = (1 << ui::AX_STATE_EDITABLE); | 1364 text.AddState(ui::AX_STATE_EDITABLE); |
| 1313 text.SetName("Click "); | 1365 text.SetName("Click "); |
| 1314 | 1366 |
| 1315 ui::AXNodeData link; | 1367 ui::AXNodeData link; |
| 1368 link.ClearBitfields(); |
| 1316 link.id = 4; | 1369 link.id = 4; |
| 1317 link.role = ui::AX_ROLE_LINK; | 1370 link.role = ui::AX_ROLE_LINK; |
| 1318 link.state = (1 << ui::AX_STATE_EDITABLE) | | 1371 link.AddState(ui::AX_STATE_EDITABLE); |
| 1319 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 1372 link.AddState(ui::AX_STATE_FOCUSABLE); |
| 1373 link.AddState(ui::AX_STATE_LINKED); |
| 1320 link.SetName("here"); | 1374 link.SetName("here"); |
| 1321 | 1375 |
| 1322 ui::AXNodeData link_text; | 1376 ui::AXNodeData link_text; |
| 1377 link_text.ClearBitfields(); |
| 1323 link_text.id = 5; | 1378 link_text.id = 5; |
| 1324 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 1379 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1325 link_text.state = (1 << ui::AX_STATE_EDITABLE) | | 1380 link_text.AddState(ui::AX_STATE_EDITABLE); |
| 1326 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 1381 link_text.AddState(ui::AX_STATE_FOCUSABLE); |
| 1382 link_text.AddState(ui::AX_STATE_LINKED); |
| 1327 link_text.SetName("here"); | 1383 link_text.SetName("here"); |
| 1328 | 1384 |
| 1329 root.child_ids.push_back(2); | 1385 root.child_ids.push_back(2); |
| 1330 div_editable.child_ids.push_back(3); | 1386 div_editable.child_ids.push_back(3); |
| 1331 div_editable.child_ids.push_back(4); | 1387 div_editable.child_ids.push_back(4); |
| 1332 link.child_ids.push_back(5); | 1388 link.child_ids.push_back(5); |
| 1333 | 1389 |
| 1334 ui::AXTreeUpdate update = MakeAXTreeUpdate( | 1390 ui::AXTreeUpdate update = MakeAXTreeUpdate( |
| 1335 root, div_editable, link, link_text, text); | 1391 root, div_editable, link, link_text, text); |
| 1336 | 1392 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 hr = link_text_accessible->get_caretOffset(&caret_offset); | 1466 hr = link_text_accessible->get_caretOffset(&caret_offset); |
| 1411 EXPECT_EQ(S_OK, hr); | 1467 EXPECT_EQ(S_OK, hr); |
| 1412 EXPECT_EQ(1, caret_offset); | 1468 EXPECT_EQ(1, caret_offset); |
| 1413 | 1469 |
| 1414 manager.reset(); | 1470 manager.reset(); |
| 1415 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 1471 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 1416 } | 1472 } |
| 1417 | 1473 |
| 1418 TEST_F(BrowserAccessibilityTest, TestSelectionInContentEditables) { | 1474 TEST_F(BrowserAccessibilityTest, TestSelectionInContentEditables) { |
| 1419 ui::AXNodeData root; | 1475 ui::AXNodeData root; |
| 1476 root.ClearBitfields(); |
| 1420 root.id = 1; | 1477 root.id = 1; |
| 1421 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 1478 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 1422 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 1479 root.AddState(ui::AX_STATE_READ_ONLY); |
| 1480 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 1423 | 1481 |
| 1424 ui::AXNodeData div_editable; | 1482 ui::AXNodeData div_editable; |
| 1483 div_editable.ClearBitfields(); |
| 1425 div_editable.id = 2; | 1484 div_editable.id = 2; |
| 1426 div_editable.role = ui::AX_ROLE_DIV; | 1485 div_editable.role = ui::AX_ROLE_DIV; |
| 1427 div_editable.state = | 1486 div_editable.AddState(ui::AX_STATE_FOCUSABLE); |
| 1428 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_EDITABLE); | 1487 div_editable.AddState(ui::AX_STATE_EDITABLE); |
| 1429 | 1488 |
| 1430 ui::AXNodeData text; | 1489 ui::AXNodeData text; |
| 1490 text.ClearBitfields(); |
| 1431 text.id = 3; | 1491 text.id = 3; |
| 1432 text.role = ui::AX_ROLE_STATIC_TEXT; | 1492 text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1433 text.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_EDITABLE); | 1493 text.AddState(ui::AX_STATE_FOCUSABLE); |
| 1494 text.AddState(ui::AX_STATE_EDITABLE); |
| 1434 text.SetName("Click "); | 1495 text.SetName("Click "); |
| 1435 | 1496 |
| 1436 ui::AXNodeData link; | 1497 ui::AXNodeData link; |
| 1498 link.ClearBitfields(); |
| 1437 link.id = 4; | 1499 link.id = 4; |
| 1438 link.role = ui::AX_ROLE_LINK; | 1500 link.role = ui::AX_ROLE_LINK; |
| 1439 link.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_EDITABLE) | | 1501 link.AddState(ui::AX_STATE_FOCUSABLE); |
| 1440 (1 << ui::AX_STATE_LINKED); | 1502 link.AddState(ui::AX_STATE_EDITABLE); |
| 1503 link.AddState(ui::AX_STATE_LINKED); |
| 1441 link.SetName("here"); | 1504 link.SetName("here"); |
| 1442 | 1505 |
| 1443 ui::AXNodeData link_text; | 1506 ui::AXNodeData link_text; |
| 1507 link_text.ClearBitfields(); |
| 1444 link_text.id = 5; | 1508 link_text.id = 5; |
| 1445 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 1509 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1446 link_text.state = (1 << ui::AX_STATE_FOCUSABLE) | | 1510 link_text.AddState(ui::AX_STATE_FOCUSABLE); |
| 1447 (1 << ui::AX_STATE_EDITABLE) | (1 << ui::AX_STATE_LINKED); | 1511 link_text.AddState(ui::AX_STATE_EDITABLE); |
| 1512 link_text.AddState(ui::AX_STATE_LINKED); |
| 1448 link_text.SetName("here"); | 1513 link_text.SetName("here"); |
| 1449 | 1514 |
| 1450 root.child_ids.push_back(2); | 1515 root.child_ids.push_back(2); |
| 1451 div_editable.child_ids.push_back(3); | 1516 div_editable.child_ids.push_back(3); |
| 1452 div_editable.child_ids.push_back(4); | 1517 div_editable.child_ids.push_back(4); |
| 1453 link.child_ids.push_back(5); | 1518 link.child_ids.push_back(5); |
| 1454 | 1519 |
| 1455 ui::AXTreeUpdate update = | 1520 ui::AXTreeUpdate update = |
| 1456 MakeAXTreeUpdate(root, div_editable, link, link_text, text); | 1521 MakeAXTreeUpdate(root, div_editable, link, link_text, text); |
| 1457 | 1522 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 EXPECT_EQ(S_OK, hr); | 1630 EXPECT_EQ(S_OK, hr); |
| 1566 EXPECT_EQ(1, selection_start); | 1631 EXPECT_EQ(1, selection_start); |
| 1567 EXPECT_EQ(7, selection_end); | 1632 EXPECT_EQ(7, selection_end); |
| 1568 | 1633 |
| 1569 manager.reset(); | 1634 manager.reset(); |
| 1570 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 1635 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 1571 } | 1636 } |
| 1572 | 1637 |
| 1573 TEST_F(BrowserAccessibilityTest, TestIAccessibleHyperlink) { | 1638 TEST_F(BrowserAccessibilityTest, TestIAccessibleHyperlink) { |
| 1574 ui::AXNodeData root; | 1639 ui::AXNodeData root; |
| 1640 root.ClearBitfields(); |
| 1575 root.id = 1; | 1641 root.id = 1; |
| 1576 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 1642 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 1577 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 1643 root.AddState(ui::AX_STATE_READ_ONLY); |
| 1644 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 1578 | 1645 |
| 1579 ui::AXNodeData div; | 1646 ui::AXNodeData div; |
| 1647 div.ClearBitfields(); |
| 1580 div.id = 2; | 1648 div.id = 2; |
| 1581 div.role = ui::AX_ROLE_DIV; | 1649 div.role = ui::AX_ROLE_DIV; |
| 1582 div.state = (1 << ui::AX_STATE_FOCUSABLE); | 1650 div.AddState(ui::AX_STATE_FOCUSABLE); |
| 1583 | 1651 |
| 1584 ui::AXNodeData text; | 1652 ui::AXNodeData text; |
| 1653 text.ClearBitfields(); |
| 1585 text.id = 3; | 1654 text.id = 3; |
| 1586 text.role = ui::AX_ROLE_STATIC_TEXT; | 1655 text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1587 text.SetName("Click "); | 1656 text.SetName("Click "); |
| 1588 | 1657 |
| 1589 ui::AXNodeData link; | 1658 ui::AXNodeData link; |
| 1659 link.ClearBitfields(); |
| 1590 link.id = 4; | 1660 link.id = 4; |
| 1591 link.role = ui::AX_ROLE_LINK; | 1661 link.role = ui::AX_ROLE_LINK; |
| 1592 link.state = (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 1662 link.AddState(ui::AX_STATE_FOCUSABLE); |
| 1663 link.AddState(ui::AX_STATE_LINKED); |
| 1593 link.SetName("here"); | 1664 link.SetName("here"); |
| 1594 link.AddStringAttribute(ui::AX_ATTR_URL, "example.com"); | 1665 link.AddStringAttribute(ui::AX_ATTR_URL, "example.com"); |
| 1595 | 1666 |
| 1596 root.child_ids.push_back(2); | 1667 root.child_ids.push_back(2); |
| 1597 div.child_ids.push_back(3); | 1668 div.child_ids.push_back(3); |
| 1598 div.child_ids.push_back(4); | 1669 div.child_ids.push_back(4); |
| 1599 | 1670 |
| 1600 CountedBrowserAccessibility::reset(); | 1671 CountedBrowserAccessibility::reset(); |
| 1601 std::unique_ptr<BrowserAccessibilityManager> manager( | 1672 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 1602 BrowserAccessibilityManager::Create( | 1673 BrowserAccessibilityManager::Create( |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 EXPECT_HRESULT_FAILED(root_accessible->get_endIndex(&end_index)); | 1790 EXPECT_HRESULT_FAILED(root_accessible->get_endIndex(&end_index)); |
| 1720 EXPECT_HRESULT_SUCCEEDED(div_accessible->get_endIndex(&end_index)); | 1791 EXPECT_HRESULT_SUCCEEDED(div_accessible->get_endIndex(&end_index)); |
| 1721 EXPECT_EQ(1, end_index); | 1792 EXPECT_EQ(1, end_index); |
| 1722 EXPECT_HRESULT_FAILED(text_accessible->get_endIndex(&end_index)); | 1793 EXPECT_HRESULT_FAILED(text_accessible->get_endIndex(&end_index)); |
| 1723 EXPECT_HRESULT_SUCCEEDED(link_accessible->get_endIndex(&end_index)); | 1794 EXPECT_HRESULT_SUCCEEDED(link_accessible->get_endIndex(&end_index)); |
| 1724 EXPECT_EQ(7, end_index); | 1795 EXPECT_EQ(7, end_index); |
| 1725 } | 1796 } |
| 1726 | 1797 |
| 1727 TEST_F(BrowserAccessibilityTest, TestTextAttributesInContentEditables) { | 1798 TEST_F(BrowserAccessibilityTest, TestTextAttributesInContentEditables) { |
| 1728 ui::AXNodeData root; | 1799 ui::AXNodeData root; |
| 1800 root.ClearBitfields(); |
| 1729 root.id = 1; | 1801 root.id = 1; |
| 1730 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 1802 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 1731 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 1803 root.AddState(ui::AX_STATE_READ_ONLY); |
| 1804 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 1732 | 1805 |
| 1733 ui::AXNodeData div_editable; | 1806 ui::AXNodeData div_editable; |
| 1807 div_editable.ClearBitfields(); |
| 1734 div_editable.id = 2; | 1808 div_editable.id = 2; |
| 1735 div_editable.role = ui::AX_ROLE_DIV; | 1809 div_editable.role = ui::AX_ROLE_DIV; |
| 1736 div_editable.state = | 1810 div_editable.AddState(ui::AX_STATE_EDITABLE); |
| 1737 (1 << ui::AX_STATE_EDITABLE) | (1 << ui::AX_STATE_FOCUSABLE); | 1811 div_editable.AddState(ui::AX_STATE_FOCUSABLE); |
| 1738 div_editable.AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, "Helvetica"); | 1812 div_editable.AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, "Helvetica"); |
| 1739 | 1813 |
| 1740 ui::AXNodeData text_before; | 1814 ui::AXNodeData text_before; |
| 1815 text_before.ClearBitfields(); |
| 1741 text_before.id = 3; | 1816 text_before.id = 3; |
| 1742 text_before.role = ui::AX_ROLE_STATIC_TEXT; | 1817 text_before.role = ui::AX_ROLE_STATIC_TEXT; |
| 1743 text_before.state = (1 << ui::AX_STATE_EDITABLE); | 1818 text_before.AddState(ui::AX_STATE_EDITABLE); |
| 1744 text_before.SetName("Before "); | 1819 text_before.SetName("Before "); |
| 1745 text_before.AddIntAttribute( | 1820 text_before.AddIntAttribute( |
| 1746 ui::AX_ATTR_TEXT_STYLE, | 1821 ui::AX_ATTR_TEXT_STYLE, |
| 1747 (ui::AX_TEXT_STYLE_BOLD | ui::AX_TEXT_STYLE_ITALIC)); | 1822 (ui::AX_TEXT_STYLE_BOLD | ui::AX_TEXT_STYLE_ITALIC)); |
| 1748 | 1823 |
| 1749 ui::AXNodeData link; | 1824 ui::AXNodeData link; |
| 1825 link.ClearBitfields(); |
| 1750 link.id = 4; | 1826 link.id = 4; |
| 1751 link.role = ui::AX_ROLE_LINK; | 1827 link.role = ui::AX_ROLE_LINK; |
| 1752 link.state = (1 << ui::AX_STATE_EDITABLE) | (1 << ui::AX_STATE_FOCUSABLE) | | 1828 link.AddState(ui::AX_STATE_EDITABLE); |
| 1753 (1 << ui::AX_STATE_LINKED); | 1829 link.AddState(ui::AX_STATE_FOCUSABLE); |
| 1830 link.AddState(ui::AX_STATE_LINKED); |
| 1754 link.SetName("lnk"); | 1831 link.SetName("lnk"); |
| 1755 link.AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, ui::AX_TEXT_STYLE_UNDERLINE); | 1832 link.AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, ui::AX_TEXT_STYLE_UNDERLINE); |
| 1756 | 1833 |
| 1757 ui::AXNodeData link_text; | 1834 ui::AXNodeData link_text; |
| 1835 link_text.ClearBitfields(); |
| 1758 link_text.id = 5; | 1836 link_text.id = 5; |
| 1759 link_text.role = ui::AX_ROLE_STATIC_TEXT; | 1837 link_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 1760 link_text.state = (1 << ui::AX_STATE_EDITABLE) | | 1838 link_text.AddState(ui::AX_STATE_EDITABLE); |
| 1761 (1 << ui::AX_STATE_FOCUSABLE) | (1 << ui::AX_STATE_LINKED); | 1839 link_text.AddState(ui::AX_STATE_FOCUSABLE); |
| 1840 link_text.AddState(ui::AX_STATE_LINKED); |
| 1762 link_text.SetName("lnk"); | 1841 link_text.SetName("lnk"); |
| 1763 link_text.AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, | 1842 link_text.AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, |
| 1764 ui::AX_TEXT_STYLE_UNDERLINE); | 1843 ui::AX_TEXT_STYLE_UNDERLINE); |
| 1765 | 1844 |
| 1766 // The name "lnk" is misspelled. | 1845 // The name "lnk" is misspelled. |
| 1767 std::vector<int32_t> marker_types; | 1846 std::vector<int32_t> marker_types; |
| 1768 marker_types.push_back(static_cast<int32_t>(ui::AX_MARKER_TYPE_SPELLING)); | 1847 marker_types.push_back(static_cast<int32_t>(ui::AX_MARKER_TYPE_SPELLING)); |
| 1769 std::vector<int32_t> marker_starts; | 1848 std::vector<int32_t> marker_starts; |
| 1770 marker_starts.push_back(0); | 1849 marker_starts.push_back(0); |
| 1771 std::vector<int32_t> marker_ends; | 1850 std::vector<int32_t> marker_ends; |
| 1772 marker_ends.push_back(3); | 1851 marker_ends.push_back(3); |
| 1773 link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); | 1852 link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); |
| 1774 link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); | 1853 link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); |
| 1775 link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_ENDS, marker_ends); | 1854 link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_ENDS, marker_ends); |
| 1776 | 1855 |
| 1777 ui::AXNodeData text_after; | 1856 ui::AXNodeData text_after; |
| 1857 text_after.ClearBitfields(); |
| 1778 text_after.id = 6; | 1858 text_after.id = 6; |
| 1779 text_after.role = ui::AX_ROLE_STATIC_TEXT; | 1859 text_after.role = ui::AX_ROLE_STATIC_TEXT; |
| 1780 text_after.state = (1 << ui::AX_STATE_EDITABLE); | 1860 text_after.AddState(ui::AX_STATE_EDITABLE); |
| 1781 text_after.SetName(" after."); | 1861 text_after.SetName(" after."); |
| 1782 // Leave text style as normal. | 1862 // Leave text style as normal. |
| 1783 | 1863 |
| 1784 root.child_ids.push_back(div_editable.id); | 1864 root.child_ids.push_back(div_editable.id); |
| 1785 div_editable.child_ids.push_back(text_before.id); | 1865 div_editable.child_ids.push_back(text_before.id); |
| 1786 div_editable.child_ids.push_back(link.id); | 1866 div_editable.child_ids.push_back(link.id); |
| 1787 div_editable.child_ids.push_back(text_after.id); | 1867 div_editable.child_ids.push_back(text_after.id); |
| 1788 link.child_ids.push_back(link_text.id); | 1868 link.child_ids.push_back(link_text.id); |
| 1789 | 1869 |
| 1790 ui::AXTreeUpdate update = MakeAXTreeUpdate(root, div_editable, text_before, | 1870 ui::AXTreeUpdate update = MakeAXTreeUpdate(root, div_editable, text_before, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 TEST_F(BrowserAccessibilityTest, TestMisspellingsInSimpleTextFields) { | 2039 TEST_F(BrowserAccessibilityTest, TestMisspellingsInSimpleTextFields) { |
| 1960 std::string value1("Testing ."); | 2040 std::string value1("Testing ."); |
| 1961 // The word "helo" is misspelled. | 2041 // The word "helo" is misspelled. |
| 1962 std::string value2("Helo there."); | 2042 std::string value2("Helo there."); |
| 1963 | 2043 |
| 1964 LONG value1_length = static_cast<LONG>(value1.length()); | 2044 LONG value1_length = static_cast<LONG>(value1.length()); |
| 1965 LONG value2_length = static_cast<LONG>(value2.length()); | 2045 LONG value2_length = static_cast<LONG>(value2.length()); |
| 1966 LONG combo_box_value_length = value1_length + value2_length; | 2046 LONG combo_box_value_length = value1_length + value2_length; |
| 1967 | 2047 |
| 1968 ui::AXNodeData root; | 2048 ui::AXNodeData root; |
| 2049 root.ClearBitfields(); |
| 1969 root.id = 1; | 2050 root.id = 1; |
| 1970 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 2051 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 1971 root.state = (1 << ui::AX_STATE_READ_ONLY) | (1 << ui::AX_STATE_FOCUSABLE); | 2052 root.AddState(ui::AX_STATE_READ_ONLY); |
| 2053 root.AddState(ui::AX_STATE_FOCUSABLE); |
| 1972 | 2054 |
| 1973 ui::AXNodeData combo_box; | 2055 ui::AXNodeData combo_box; |
| 2056 combo_box.ClearBitfields(); |
| 1974 combo_box.id = 2; | 2057 combo_box.id = 2; |
| 1975 combo_box.role = ui::AX_ROLE_COMBO_BOX; | 2058 combo_box.role = ui::AX_ROLE_COMBO_BOX; |
| 1976 combo_box.state = | 2059 combo_box.AddState(ui::AX_STATE_EDITABLE); |
| 1977 (1 << ui::AX_STATE_EDITABLE) | (1 << ui::AX_STATE_FOCUSABLE); | 2060 combo_box.AddState(ui::AX_STATE_FOCUSABLE); |
| 1978 combo_box.SetValue(value1 + value2); | 2061 combo_box.SetValue(value1 + value2); |
| 1979 | 2062 |
| 1980 ui::AXNodeData combo_box_div; | 2063 ui::AXNodeData combo_box_div; |
| 2064 combo_box_div.ClearBitfields(); |
| 1981 combo_box_div.id = 3; | 2065 combo_box_div.id = 3; |
| 1982 combo_box_div.role = ui::AX_ROLE_DIV; | 2066 combo_box_div.role = ui::AX_ROLE_DIV; |
| 1983 combo_box_div.state = 1 << ui::AX_STATE_EDITABLE; | 2067 combo_box_div.AddState(ui::AX_STATE_EDITABLE); |
| 1984 | 2068 |
| 1985 ui::AXNodeData static_text1; | 2069 ui::AXNodeData static_text1; |
| 2070 static_text1.ClearBitfields(); |
| 1986 static_text1.id = 4; | 2071 static_text1.id = 4; |
| 1987 static_text1.role = ui::AX_ROLE_STATIC_TEXT; | 2072 static_text1.role = ui::AX_ROLE_STATIC_TEXT; |
| 1988 static_text1.state = 1 << ui::AX_STATE_EDITABLE; | 2073 static_text1.AddState(ui::AX_STATE_EDITABLE); |
| 1989 static_text1.SetName(value1); | 2074 static_text1.SetName(value1); |
| 1990 | 2075 |
| 1991 ui::AXNodeData static_text2; | 2076 ui::AXNodeData static_text2; |
| 2077 static_text2.ClearBitfields(); |
| 1992 static_text2.id = 5; | 2078 static_text2.id = 5; |
| 1993 static_text2.role = ui::AX_ROLE_STATIC_TEXT; | 2079 static_text2.role = ui::AX_ROLE_STATIC_TEXT; |
| 1994 static_text2.state = 1 << ui::AX_STATE_EDITABLE; | 2080 static_text2.AddState(ui::AX_STATE_EDITABLE); |
| 1995 static_text2.SetName(value2); | 2081 static_text2.SetName(value2); |
| 1996 | 2082 |
| 1997 std::vector<int32_t> marker_types; | 2083 std::vector<int32_t> marker_types; |
| 1998 marker_types.push_back(static_cast<int32_t>(ui::AX_MARKER_TYPE_SPELLING)); | 2084 marker_types.push_back(static_cast<int32_t>(ui::AX_MARKER_TYPE_SPELLING)); |
| 1999 std::vector<int32_t> marker_starts; | 2085 std::vector<int32_t> marker_starts; |
| 2000 marker_starts.push_back(0); | 2086 marker_starts.push_back(0); |
| 2001 std::vector<int32_t> marker_ends; | 2087 std::vector<int32_t> marker_ends; |
| 2002 marker_ends.push_back(4); | 2088 marker_ends.push_back(4); |
| 2003 static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); | 2089 static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); |
| 2004 static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); | 2090 static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2488 std::vector<AXEventNotificationDetails> events = {event}; | 2574 std::vector<AXEventNotificationDetails> events = {event}; |
| 2489 manager->OnAccessibilityEvents(events); | 2575 manager->OnAccessibilityEvents(events); |
| 2490 | 2576 |
| 2491 EXPECT_HRESULT_SUCCEEDED(ax_child1->get_nRelations(&n_relations)); | 2577 EXPECT_HRESULT_SUCCEEDED(ax_child1->get_nRelations(&n_relations)); |
| 2492 EXPECT_EQ(2, n_relations); | 2578 EXPECT_EQ(2, n_relations); |
| 2493 EXPECT_HRESULT_SUCCEEDED(ax_child2->get_nRelations(&n_relations)); | 2579 EXPECT_HRESULT_SUCCEEDED(ax_child2->get_nRelations(&n_relations)); |
| 2494 EXPECT_EQ(2, n_relations); | 2580 EXPECT_EQ(2, n_relations); |
| 2495 } | 2581 } |
| 2496 | 2582 |
| 2497 } // namespace content | 2583 } // namespace content |
| OLD | NEW |