| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 // Query for the text IAccessible and verify that it returns "old text" as its | 216 // Query for the text IAccessible and verify that it returns "old text" as its |
| 217 // value. | 217 // value. |
| 218 base::win::ScopedVariant one(1); | 218 base::win::ScopedVariant one(1); |
| 219 base::win::ScopedComPtr<IDispatch> text_dispatch; | 219 base::win::ScopedComPtr<IDispatch> text_dispatch; |
| 220 HRESULT hr = ToBrowserAccessibilityWin(manager->GetRoot())->get_accChild( | 220 HRESULT hr = ToBrowserAccessibilityWin(manager->GetRoot())->get_accChild( |
| 221 one, text_dispatch.Receive()); | 221 one, text_dispatch.Receive()); |
| 222 ASSERT_EQ(S_OK, hr); | 222 ASSERT_EQ(S_OK, hr); |
| 223 | 223 |
| 224 base::win::ScopedComPtr<IAccessible> text_accessible; | 224 base::win::ScopedComPtr<IAccessible> text_accessible; |
| 225 hr = text_dispatch.QueryInterface(text_accessible.Receive()); | 225 hr = text_dispatch.CopyTo(text_accessible.Receive()); |
| 226 ASSERT_EQ(S_OK, hr); | 226 ASSERT_EQ(S_OK, hr); |
| 227 | 227 |
| 228 base::win::ScopedVariant childid_self(CHILDID_SELF); | 228 base::win::ScopedVariant childid_self(CHILDID_SELF); |
| 229 base::win::ScopedBstr name; | 229 base::win::ScopedBstr name; |
| 230 hr = text_accessible->get_accName(childid_self, name.Receive()); | 230 hr = text_accessible->get_accName(childid_self, name.Receive()); |
| 231 ASSERT_EQ(S_OK, hr); | 231 ASSERT_EQ(S_OK, hr); |
| 232 EXPECT_EQ(L"old text", base::string16(name)); | 232 EXPECT_EQ(L"old text", base::string16(name)); |
| 233 name.Reset(); | 233 name.Reset(); |
| 234 | 234 |
| 235 text_dispatch.Reset(); | 235 text_dispatch.Reset(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 247 std::vector<AXEventNotificationDetails> events; | 247 std::vector<AXEventNotificationDetails> events; |
| 248 events.push_back(param); | 248 events.push_back(param); |
| 249 manager->OnAccessibilityEvents(events); | 249 manager->OnAccessibilityEvents(events); |
| 250 | 250 |
| 251 // Query for the text IAccessible and verify that it now returns "new text" | 251 // Query for the text IAccessible and verify that it now returns "new text" |
| 252 // as its value. | 252 // as its value. |
| 253 hr = ToBrowserAccessibilityWin(manager->GetRoot())->get_accChild( | 253 hr = ToBrowserAccessibilityWin(manager->GetRoot())->get_accChild( |
| 254 one, text_dispatch.Receive()); | 254 one, text_dispatch.Receive()); |
| 255 ASSERT_EQ(S_OK, hr); | 255 ASSERT_EQ(S_OK, hr); |
| 256 | 256 |
| 257 hr = text_dispatch.QueryInterface(text_accessible.Receive()); | 257 hr = text_dispatch.CopyTo(text_accessible.Receive()); |
| 258 ASSERT_EQ(S_OK, hr); | 258 ASSERT_EQ(S_OK, hr); |
| 259 | 259 |
| 260 hr = text_accessible->get_accName(childid_self, name.Receive()); | 260 hr = text_accessible->get_accName(childid_self, name.Receive()); |
| 261 ASSERT_EQ(S_OK, hr); | 261 ASSERT_EQ(S_OK, hr); |
| 262 EXPECT_EQ(L"new text", base::string16(name)); | 262 EXPECT_EQ(L"new text", base::string16(name)); |
| 263 | 263 |
| 264 text_dispatch.Reset(); | 264 text_dispatch.Reset(); |
| 265 text_accessible.Reset(); | 265 text_accessible.Reset(); |
| 266 | 266 |
| 267 // Delete the manager and test that all BrowserAccessibility instances are | 267 // Delete the manager and test that all BrowserAccessibility instances are |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 EXPECT_EQ(4, hyperlink_count); | 662 EXPECT_EQ(4, hyperlink_count); |
| 663 | 663 |
| 664 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; | 664 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; |
| 665 base::win::ScopedComPtr<IAccessibleText> hypertext; | 665 base::win::ScopedComPtr<IAccessibleText> hypertext; |
| 666 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive())); | 666 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive())); |
| 667 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(4, hyperlink.Receive())); | 667 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(4, hyperlink.Receive())); |
| 668 | 668 |
| 669 // Get the text of the combo box. | 669 // Get the text of the combo box. |
| 670 // It should be its value. | 670 // It should be its value. |
| 671 EXPECT_EQ(S_OK, root_obj->get_hyperlink(0, hyperlink.Receive())); | 671 EXPECT_EQ(S_OK, root_obj->get_hyperlink(0, hyperlink.Receive())); |
| 672 EXPECT_EQ(S_OK, hyperlink.QueryInterface(hypertext.Receive())); | 672 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); |
| 673 EXPECT_EQ(S_OK, | 673 EXPECT_EQ(S_OK, |
| 674 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 674 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
| 675 EXPECT_STREQ(combo_box_value.c_str(), text); | 675 EXPECT_STREQ(combo_box_value.c_str(), text); |
| 676 text.Reset(); | 676 text.Reset(); |
| 677 hyperlink.Reset(); | 677 hyperlink.Reset(); |
| 678 hypertext.Reset(); | 678 hypertext.Reset(); |
| 679 | 679 |
| 680 // Get the text of the check box. | 680 // Get the text of the check box. |
| 681 // It should be its name. | 681 // It should be its name. |
| 682 EXPECT_EQ(S_OK, root_obj->get_hyperlink(1, hyperlink.Receive())); | 682 EXPECT_EQ(S_OK, root_obj->get_hyperlink(1, hyperlink.Receive())); |
| 683 EXPECT_EQ(S_OK, hyperlink.QueryInterface(hypertext.Receive())); | 683 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); |
| 684 EXPECT_EQ(S_OK, | 684 EXPECT_EQ(S_OK, |
| 685 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 685 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
| 686 EXPECT_STREQ(check_box_name.c_str(), text); | 686 EXPECT_STREQ(check_box_name.c_str(), text); |
| 687 text.Reset(); | 687 text.Reset(); |
| 688 hyperlink.Reset(); | 688 hyperlink.Reset(); |
| 689 hypertext.Reset(); | 689 hypertext.Reset(); |
| 690 | 690 |
| 691 // Get the text of the button. | 691 // Get the text of the button. |
| 692 EXPECT_EQ(S_OK, root_obj->get_hyperlink(2, hyperlink.Receive())); | 692 EXPECT_EQ(S_OK, root_obj->get_hyperlink(2, hyperlink.Receive())); |
| 693 EXPECT_EQ(S_OK, hyperlink.QueryInterface(hypertext.Receive())); | 693 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); |
| 694 EXPECT_EQ(S_OK, | 694 EXPECT_EQ(S_OK, |
| 695 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 695 hypertext->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
| 696 EXPECT_STREQ(button_text_name.c_str(), text); | 696 EXPECT_STREQ(button_text_name.c_str(), text); |
| 697 text.Reset(); | 697 text.Reset(); |
| 698 hyperlink.Reset(); | 698 hyperlink.Reset(); |
| 699 hypertext.Reset(); | 699 hypertext.Reset(); |
| 700 | 700 |
| 701 // Get the text of the link. | 701 // Get the text of the link. |
| 702 EXPECT_EQ(S_OK, root_obj->get_hyperlink(3, hyperlink.Receive())); | 702 EXPECT_EQ(S_OK, root_obj->get_hyperlink(3, hyperlink.Receive())); |
| 703 EXPECT_EQ(S_OK, hyperlink.QueryInterface(hypertext.Receive())); | 703 EXPECT_EQ(S_OK, hyperlink.CopyTo(hypertext.Receive())); |
| 704 EXPECT_EQ(S_OK, hypertext->get_text(0, 4, text.Receive())); | 704 EXPECT_EQ(S_OK, hypertext->get_text(0, 4, text.Receive())); |
| 705 EXPECT_STREQ(link_text_name.c_str(), text); | 705 EXPECT_STREQ(link_text_name.c_str(), text); |
| 706 text.Reset(); | 706 text.Reset(); |
| 707 hyperlink.Reset(); | 707 hyperlink.Reset(); |
| 708 hypertext.Reset(); | 708 hypertext.Reset(); |
| 709 | 709 |
| 710 long hyperlink_index; | 710 long hyperlink_index; |
| 711 EXPECT_EQ(S_FALSE, root_obj->get_hyperlinkIndex(0, &hyperlink_index)); | 711 EXPECT_EQ(S_FALSE, root_obj->get_hyperlinkIndex(0, &hyperlink_index)); |
| 712 EXPECT_EQ(-1, hyperlink_index); | 712 EXPECT_EQ(-1, hyperlink_index); |
| 713 // Invalid arguments should not be modified. | 713 // Invalid arguments should not be modified. |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2412 EXPECT_HRESULT_SUCCEEDED( | 2412 EXPECT_HRESULT_SUCCEEDED( |
| 2413 describedby_relation->get_relationType(relation_type.Receive())); | 2413 describedby_relation->get_relationType(relation_type.Receive())); |
| 2414 EXPECT_EQ(L"describedBy", base::string16(relation_type)); | 2414 EXPECT_EQ(L"describedBy", base::string16(relation_type)); |
| 2415 relation_type.Reset(); | 2415 relation_type.Reset(); |
| 2416 | 2416 |
| 2417 EXPECT_HRESULT_SUCCEEDED(describedby_relation->get_nTargets(&n_targets)); | 2417 EXPECT_HRESULT_SUCCEEDED(describedby_relation->get_nTargets(&n_targets)); |
| 2418 EXPECT_EQ(2, n_targets); | 2418 EXPECT_EQ(2, n_targets); |
| 2419 | 2419 |
| 2420 EXPECT_HRESULT_SUCCEEDED( | 2420 EXPECT_HRESULT_SUCCEEDED( |
| 2421 describedby_relation->get_target(0, target.Receive())); | 2421 describedby_relation->get_target(0, target.Receive())); |
| 2422 target.QueryInterface(ax_target.Receive()); | 2422 target.CopyTo(ax_target.Receive()); |
| 2423 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2423 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
| 2424 EXPECT_EQ(-ax_child1->unique_id(), unique_id); | 2424 EXPECT_EQ(-ax_child1->unique_id(), unique_id); |
| 2425 ax_target.Reset(); | 2425 ax_target.Reset(); |
| 2426 target.Reset(); | 2426 target.Reset(); |
| 2427 | 2427 |
| 2428 EXPECT_HRESULT_SUCCEEDED( | 2428 EXPECT_HRESULT_SUCCEEDED( |
| 2429 describedby_relation->get_target(1, target.Receive())); | 2429 describedby_relation->get_target(1, target.Receive())); |
| 2430 target.QueryInterface(ax_target.Receive()); | 2430 target.CopyTo(ax_target.Receive()); |
| 2431 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2431 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
| 2432 EXPECT_EQ(-ax_child2->unique_id(), unique_id); | 2432 EXPECT_EQ(-ax_child2->unique_id(), unique_id); |
| 2433 ax_target.Reset(); | 2433 ax_target.Reset(); |
| 2434 target.Reset(); | 2434 target.Reset(); |
| 2435 describedby_relation.Reset(); | 2435 describedby_relation.Reset(); |
| 2436 | 2436 |
| 2437 // Test the reverse relations. | 2437 // Test the reverse relations. |
| 2438 EXPECT_HRESULT_SUCCEEDED(ax_child1->get_nRelations(&n_relations)); | 2438 EXPECT_HRESULT_SUCCEEDED(ax_child1->get_nRelations(&n_relations)); |
| 2439 EXPECT_EQ(1, n_relations); | 2439 EXPECT_EQ(1, n_relations); |
| 2440 | 2440 |
| 2441 EXPECT_HRESULT_SUCCEEDED( | 2441 EXPECT_HRESULT_SUCCEEDED( |
| 2442 ax_child1->get_relation(0, description_for_relation.Receive())); | 2442 ax_child1->get_relation(0, description_for_relation.Receive())); |
| 2443 EXPECT_HRESULT_SUCCEEDED( | 2443 EXPECT_HRESULT_SUCCEEDED( |
| 2444 description_for_relation->get_relationType(relation_type.Receive())); | 2444 description_for_relation->get_relationType(relation_type.Receive())); |
| 2445 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); | 2445 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); |
| 2446 relation_type.Reset(); | 2446 relation_type.Reset(); |
| 2447 | 2447 |
| 2448 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); | 2448 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); |
| 2449 EXPECT_EQ(1, n_targets); | 2449 EXPECT_EQ(1, n_targets); |
| 2450 | 2450 |
| 2451 EXPECT_HRESULT_SUCCEEDED( | 2451 EXPECT_HRESULT_SUCCEEDED( |
| 2452 description_for_relation->get_target(0, target.Receive())); | 2452 description_for_relation->get_target(0, target.Receive())); |
| 2453 target.QueryInterface(ax_target.Receive()); | 2453 target.CopyTo(ax_target.Receive()); |
| 2454 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2454 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
| 2455 EXPECT_EQ(-ax_root->unique_id(), unique_id); | 2455 EXPECT_EQ(-ax_root->unique_id(), unique_id); |
| 2456 ax_target.Reset(); | 2456 ax_target.Reset(); |
| 2457 target.Reset(); | 2457 target.Reset(); |
| 2458 description_for_relation.Reset(); | 2458 description_for_relation.Reset(); |
| 2459 | 2459 |
| 2460 EXPECT_HRESULT_SUCCEEDED(ax_child2->get_nRelations(&n_relations)); | 2460 EXPECT_HRESULT_SUCCEEDED(ax_child2->get_nRelations(&n_relations)); |
| 2461 EXPECT_EQ(1, n_relations); | 2461 EXPECT_EQ(1, n_relations); |
| 2462 | 2462 |
| 2463 EXPECT_HRESULT_SUCCEEDED( | 2463 EXPECT_HRESULT_SUCCEEDED( |
| 2464 ax_child2->get_relation(0, description_for_relation.Receive())); | 2464 ax_child2->get_relation(0, description_for_relation.Receive())); |
| 2465 EXPECT_HRESULT_SUCCEEDED( | 2465 EXPECT_HRESULT_SUCCEEDED( |
| 2466 description_for_relation->get_relationType(relation_type.Receive())); | 2466 description_for_relation->get_relationType(relation_type.Receive())); |
| 2467 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); | 2467 EXPECT_EQ(L"descriptionFor", base::string16(relation_type)); |
| 2468 relation_type.Reset(); | 2468 relation_type.Reset(); |
| 2469 | 2469 |
| 2470 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); | 2470 EXPECT_HRESULT_SUCCEEDED(description_for_relation->get_nTargets(&n_targets)); |
| 2471 EXPECT_EQ(1, n_targets); | 2471 EXPECT_EQ(1, n_targets); |
| 2472 | 2472 |
| 2473 EXPECT_HRESULT_SUCCEEDED( | 2473 EXPECT_HRESULT_SUCCEEDED( |
| 2474 description_for_relation->get_target(0, target.Receive())); | 2474 description_for_relation->get_target(0, target.Receive())); |
| 2475 target.QueryInterface(ax_target.Receive()); | 2475 target.CopyTo(ax_target.Receive()); |
| 2476 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); | 2476 EXPECT_HRESULT_SUCCEEDED(ax_target->get_uniqueID(&unique_id)); |
| 2477 EXPECT_EQ(-ax_root->unique_id(), unique_id); | 2477 EXPECT_EQ(-ax_root->unique_id(), unique_id); |
| 2478 ax_target.Reset(); | 2478 ax_target.Reset(); |
| 2479 target.Reset(); | 2479 target.Reset(); |
| 2480 | 2480 |
| 2481 // Try adding one more relation. | 2481 // Try adding one more relation. |
| 2482 std::vector<int32_t> labelledby_ids = {3}; | 2482 std::vector<int32_t> labelledby_ids = {3}; |
| 2483 child1.AddIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS, labelledby_ids); | 2483 child1.AddIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS, labelledby_ids); |
| 2484 AXEventNotificationDetails event; | 2484 AXEventNotificationDetails event; |
| 2485 event.event_type = ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED; | 2485 event.event_type = ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED; |
| 2486 event.update.nodes.push_back(child1); | 2486 event.update.nodes.push_back(child1); |
| 2487 event.id = child1.id; | 2487 event.id = child1.id; |
| 2488 std::vector<AXEventNotificationDetails> events = {event}; | 2488 std::vector<AXEventNotificationDetails> events = {event}; |
| 2489 manager->OnAccessibilityEvents(events); | 2489 manager->OnAccessibilityEvents(events); |
| 2490 | 2490 |
| 2491 EXPECT_HRESULT_SUCCEEDED(ax_child1->get_nRelations(&n_relations)); | 2491 EXPECT_HRESULT_SUCCEEDED(ax_child1->get_nRelations(&n_relations)); |
| 2492 EXPECT_EQ(2, n_relations); | 2492 EXPECT_EQ(2, n_relations); |
| 2493 EXPECT_HRESULT_SUCCEEDED(ax_child2->get_nRelations(&n_relations)); | 2493 EXPECT_HRESULT_SUCCEEDED(ax_child2->get_nRelations(&n_relations)); |
| 2494 EXPECT_EQ(2, n_relations); | 2494 EXPECT_EQ(2, n_relations); |
| 2495 } | 2495 } |
| 2496 | 2496 |
| 2497 } // namespace content | 2497 } // namespace content |
| OLD | NEW |