| 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 "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/browser/accessibility/browser_accessibility.h" | 7 #include "content/browser/accessibility/browser_accessibility.h" |
| 8 #include "content/browser/accessibility/browser_accessibility_manager.h" | 8 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include "content/browser/accessibility/browser_accessibility_win.h" | 10 #include "content/browser/accessibility/browser_accessibility_win.h" |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 ASSERT_TRUE(delegate->got_fatal_error()); | 626 ASSERT_TRUE(delegate->got_fatal_error()); |
| 627 } | 627 } |
| 628 | 628 |
| 629 TEST(BrowserAccessibilityManagerTest, BoundsForRange) { | 629 TEST(BrowserAccessibilityManagerTest, BoundsForRange) { |
| 630 ui::AXNodeData root; | 630 ui::AXNodeData root; |
| 631 root.id = 1; | 631 root.id = 1; |
| 632 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 632 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 633 | 633 |
| 634 ui::AXNodeData static_text; | 634 ui::AXNodeData static_text; |
| 635 static_text.id = 2; | 635 static_text.id = 2; |
| 636 static_text.SetValue("Hello, world."); | 636 static_text.SetName("Hello, world."); |
| 637 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 637 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 638 static_text.location = gfx::Rect(100, 100, 29, 18); | 638 static_text.location = gfx::Rect(100, 100, 29, 18); |
| 639 root.child_ids.push_back(2); | 639 root.child_ids.push_back(2); |
| 640 | 640 |
| 641 ui::AXNodeData inline_text1; | 641 ui::AXNodeData inline_text1; |
| 642 inline_text1.id = 3; | 642 inline_text1.id = 3; |
| 643 inline_text1.SetValue("Hello, "); | 643 inline_text1.SetName("Hello, "); |
| 644 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 644 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 645 inline_text1.location = gfx::Rect(100, 100, 29, 9); | 645 inline_text1.location = gfx::Rect(100, 100, 29, 9); |
| 646 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 646 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 647 ui::AX_TEXT_DIRECTION_LTR); | 647 ui::AX_TEXT_DIRECTION_LTR); |
| 648 std::vector<int32> character_offsets1; | 648 std::vector<int32> character_offsets1; |
| 649 character_offsets1.push_back(6); // 0 | 649 character_offsets1.push_back(6); // 0 |
| 650 character_offsets1.push_back(11); // 1 | 650 character_offsets1.push_back(11); // 1 |
| 651 character_offsets1.push_back(16); // 2 | 651 character_offsets1.push_back(16); // 2 |
| 652 character_offsets1.push_back(21); // 3 | 652 character_offsets1.push_back(21); // 3 |
| 653 character_offsets1.push_back(26); // 4 | 653 character_offsets1.push_back(26); // 4 |
| 654 character_offsets1.push_back(29); // 5 | 654 character_offsets1.push_back(29); // 5 |
| 655 character_offsets1.push_back(29); // 6 (note that the space has no width) | 655 character_offsets1.push_back(29); // 6 (note that the space has no width) |
| 656 inline_text1.AddIntListAttribute( | 656 inline_text1.AddIntListAttribute( |
| 657 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 657 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 658 static_text.child_ids.push_back(3); | 658 static_text.child_ids.push_back(3); |
| 659 | 659 |
| 660 ui::AXNodeData inline_text2; | 660 ui::AXNodeData inline_text2; |
| 661 inline_text2.id = 4; | 661 inline_text2.id = 4; |
| 662 inline_text2.SetValue("world."); | 662 inline_text2.SetName("world."); |
| 663 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 663 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 664 inline_text2.location = gfx::Rect(100, 109, 28, 9); | 664 inline_text2.location = gfx::Rect(100, 109, 28, 9); |
| 665 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 665 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 666 ui::AX_TEXT_DIRECTION_LTR); | 666 ui::AX_TEXT_DIRECTION_LTR); |
| 667 std::vector<int32> character_offsets2; | 667 std::vector<int32> character_offsets2; |
| 668 character_offsets2.push_back(5); | 668 character_offsets2.push_back(5); |
| 669 character_offsets2.push_back(10); | 669 character_offsets2.push_back(10); |
| 670 character_offsets2.push_back(15); | 670 character_offsets2.push_back(15); |
| 671 character_offsets2.push_back(20); | 671 character_offsets2.push_back(20); |
| 672 character_offsets2.push_back(25); | 672 character_offsets2.push_back(25); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 // to switch directions. This test doesn't worry about how, though - it just | 721 // to switch directions. This test doesn't worry about how, though - it just |
| 722 // tests that if something like that were to occur, GetLocalBoundsForRange | 722 // tests that if something like that were to occur, GetLocalBoundsForRange |
| 723 // returns the correct bounds for different ranges. | 723 // returns the correct bounds for different ranges. |
| 724 | 724 |
| 725 ui::AXNodeData root; | 725 ui::AXNodeData root; |
| 726 root.id = 1; | 726 root.id = 1; |
| 727 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 727 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 728 | 728 |
| 729 ui::AXNodeData static_text; | 729 ui::AXNodeData static_text; |
| 730 static_text.id = 2; | 730 static_text.id = 2; |
| 731 static_text.SetValue("123abc"); | 731 static_text.SetName("123abc"); |
| 732 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 732 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 733 static_text.location = gfx::Rect(100, 100, 60, 20); | 733 static_text.location = gfx::Rect(100, 100, 60, 20); |
| 734 root.child_ids.push_back(2); | 734 root.child_ids.push_back(2); |
| 735 | 735 |
| 736 ui::AXNodeData inline_text1; | 736 ui::AXNodeData inline_text1; |
| 737 inline_text1.id = 3; | 737 inline_text1.id = 3; |
| 738 inline_text1.SetValue("123"); | 738 inline_text1.SetName("123"); |
| 739 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 739 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 740 inline_text1.location = gfx::Rect(100, 100, 30, 20); | 740 inline_text1.location = gfx::Rect(100, 100, 30, 20); |
| 741 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 741 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 742 ui::AX_TEXT_DIRECTION_LTR); | 742 ui::AX_TEXT_DIRECTION_LTR); |
| 743 std::vector<int32> character_offsets1; | 743 std::vector<int32> character_offsets1; |
| 744 character_offsets1.push_back(10); // 0 | 744 character_offsets1.push_back(10); // 0 |
| 745 character_offsets1.push_back(20); // 1 | 745 character_offsets1.push_back(20); // 1 |
| 746 character_offsets1.push_back(30); // 2 | 746 character_offsets1.push_back(30); // 2 |
| 747 inline_text1.AddIntListAttribute( | 747 inline_text1.AddIntListAttribute( |
| 748 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 748 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 749 static_text.child_ids.push_back(3); | 749 static_text.child_ids.push_back(3); |
| 750 | 750 |
| 751 ui::AXNodeData inline_text2; | 751 ui::AXNodeData inline_text2; |
| 752 inline_text2.id = 4; | 752 inline_text2.id = 4; |
| 753 inline_text2.SetValue("abc"); | 753 inline_text2.SetName("abc"); |
| 754 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 754 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 755 inline_text2.location = gfx::Rect(130, 100, 30, 20); | 755 inline_text2.location = gfx::Rect(130, 100, 30, 20); |
| 756 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 756 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 757 ui::AX_TEXT_DIRECTION_RTL); | 757 ui::AX_TEXT_DIRECTION_RTL); |
| 758 std::vector<int32> character_offsets2; | 758 std::vector<int32> character_offsets2; |
| 759 character_offsets2.push_back(10); | 759 character_offsets2.push_back(10); |
| 760 character_offsets2.push_back(20); | 760 character_offsets2.push_back(20); |
| 761 character_offsets2.push_back(30); | 761 character_offsets2.push_back(30); |
| 762 inline_text2.AddIntListAttribute( | 762 inline_text2.AddIntListAttribute( |
| 763 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); | 763 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 | 796 |
| 797 TEST(BrowserAccessibilityManagerTest, BoundsForRangeScrolledWindow) { | 797 TEST(BrowserAccessibilityManagerTest, BoundsForRangeScrolledWindow) { |
| 798 ui::AXNodeData root; | 798 ui::AXNodeData root; |
| 799 root.id = 1; | 799 root.id = 1; |
| 800 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 800 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 801 root.AddIntAttribute(ui::AX_ATTR_SCROLL_X, 25); | 801 root.AddIntAttribute(ui::AX_ATTR_SCROLL_X, 25); |
| 802 root.AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 50); | 802 root.AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 50); |
| 803 | 803 |
| 804 ui::AXNodeData static_text; | 804 ui::AXNodeData static_text; |
| 805 static_text.id = 2; | 805 static_text.id = 2; |
| 806 static_text.SetValue("ABC"); | 806 static_text.SetName("ABC"); |
| 807 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 807 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 808 static_text.location = gfx::Rect(100, 100, 16, 9); | 808 static_text.location = gfx::Rect(100, 100, 16, 9); |
| 809 root.child_ids.push_back(2); | 809 root.child_ids.push_back(2); |
| 810 | 810 |
| 811 ui::AXNodeData inline_text; | 811 ui::AXNodeData inline_text; |
| 812 inline_text.id = 3; | 812 inline_text.id = 3; |
| 813 inline_text.SetValue("ABC"); | 813 inline_text.SetName("ABC"); |
| 814 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 814 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 815 inline_text.location = gfx::Rect(100, 100, 16, 9); | 815 inline_text.location = gfx::Rect(100, 100, 16, 9); |
| 816 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 816 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 817 ui::AX_TEXT_DIRECTION_LTR); | 817 ui::AX_TEXT_DIRECTION_LTR); |
| 818 std::vector<int32> character_offsets1; | 818 std::vector<int32> character_offsets1; |
| 819 character_offsets1.push_back(6); // 0 | 819 character_offsets1.push_back(6); // 0 |
| 820 character_offsets1.push_back(11); // 1 | 820 character_offsets1.push_back(11); // 1 |
| 821 character_offsets1.push_back(16); // 2 | 821 character_offsets1.push_back(16); // 2 |
| 822 inline_text.AddIntListAttribute( | 822 inline_text.AddIntListAttribute( |
| 823 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 823 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 ui::AXNodeData div; | 857 ui::AXNodeData div; |
| 858 div.id = 2; | 858 div.id = 2; |
| 859 div.role = ui::AX_ROLE_DIV; | 859 div.role = ui::AX_ROLE_DIV; |
| 860 div.location = gfx::Rect(100, 100, 100, 20); | 860 div.location = gfx::Rect(100, 100, 100, 20); |
| 861 div.child_ids.push_back(3); | 861 div.child_ids.push_back(3); |
| 862 div.child_ids.push_back(4); | 862 div.child_ids.push_back(4); |
| 863 div.child_ids.push_back(5); | 863 div.child_ids.push_back(5); |
| 864 | 864 |
| 865 ui::AXNodeData static_text1; | 865 ui::AXNodeData static_text1; |
| 866 static_text1.id = 3; | 866 static_text1.id = 3; |
| 867 static_text1.SetValue("AB"); | 867 static_text1.SetName("AB"); |
| 868 static_text1.role = ui::AX_ROLE_STATIC_TEXT; | 868 static_text1.role = ui::AX_ROLE_STATIC_TEXT; |
| 869 static_text1.location = gfx::Rect(100, 100, 40, 20); | 869 static_text1.location = gfx::Rect(100, 100, 40, 20); |
| 870 static_text1.child_ids.push_back(6); | 870 static_text1.child_ids.push_back(6); |
| 871 | 871 |
| 872 ui::AXNodeData img; | 872 ui::AXNodeData img; |
| 873 img.id = 4; | 873 img.id = 4; |
| 874 img.role = ui::AX_ROLE_IMAGE; | 874 img.role = ui::AX_ROLE_IMAGE; |
| 875 img.location = gfx::Rect(140, 100, 20, 20); | 875 img.location = gfx::Rect(140, 100, 20, 20); |
| 876 | 876 |
| 877 ui::AXNodeData static_text2; | 877 ui::AXNodeData static_text2; |
| 878 static_text2.id = 5; | 878 static_text2.id = 5; |
| 879 static_text2.SetValue("CD"); | 879 static_text2.SetName("CD"); |
| 880 static_text2.role = ui::AX_ROLE_STATIC_TEXT; | 880 static_text2.role = ui::AX_ROLE_STATIC_TEXT; |
| 881 static_text2.location = gfx::Rect(160, 100, 40, 20); | 881 static_text2.location = gfx::Rect(160, 100, 40, 20); |
| 882 static_text2.child_ids.push_back(7); | 882 static_text2.child_ids.push_back(7); |
| 883 | 883 |
| 884 ui::AXNodeData inline_text1; | 884 ui::AXNodeData inline_text1; |
| 885 inline_text1.id = 6; | 885 inline_text1.id = 6; |
| 886 inline_text1.SetValue("AB"); | 886 inline_text1.SetName("AB"); |
| 887 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 887 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 888 inline_text1.location = gfx::Rect(100, 100, 40, 20); | 888 inline_text1.location = gfx::Rect(100, 100, 40, 20); |
| 889 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 889 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 890 ui::AX_TEXT_DIRECTION_LTR); | 890 ui::AX_TEXT_DIRECTION_LTR); |
| 891 std::vector<int32> character_offsets1; | 891 std::vector<int32> character_offsets1; |
| 892 character_offsets1.push_back(20); // 0 | 892 character_offsets1.push_back(20); // 0 |
| 893 character_offsets1.push_back(40); // 1 | 893 character_offsets1.push_back(40); // 1 |
| 894 inline_text1.AddIntListAttribute( | 894 inline_text1.AddIntListAttribute( |
| 895 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 895 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 896 | 896 |
| 897 ui::AXNodeData inline_text2; | 897 ui::AXNodeData inline_text2; |
| 898 inline_text2.id = 7; | 898 inline_text2.id = 7; |
| 899 inline_text2.SetValue("CD"); | 899 inline_text2.SetName("CD"); |
| 900 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 900 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 901 inline_text2.location = gfx::Rect(160, 100, 40, 20); | 901 inline_text2.location = gfx::Rect(160, 100, 40, 20); |
| 902 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 902 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 903 ui::AX_TEXT_DIRECTION_LTR); | 903 ui::AX_TEXT_DIRECTION_LTR); |
| 904 std::vector<int32> character_offsets2; | 904 std::vector<int32> character_offsets2; |
| 905 character_offsets2.push_back(20); // 0 | 905 character_offsets2.push_back(20); // 0 |
| 906 character_offsets2.push_back(40); // 1 | 906 character_offsets2.push_back(40); // 1 |
| 907 inline_text2.AddIntListAttribute( | 907 inline_text2.AddIntListAttribute( |
| 908 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); | 908 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
| 909 | 909 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 events2[0].event_type = ui::AX_EVENT_NONE; | 1195 events2[0].event_type = ui::AX_EVENT_NONE; |
| 1196 manager->OnAccessibilityEvents(events2); | 1196 manager->OnAccessibilityEvents(events2); |
| 1197 | 1197 |
| 1198 // Make sure that the focused node was updated to the new root and | 1198 // Make sure that the focused node was updated to the new root and |
| 1199 // that this doesn't crash. | 1199 // that this doesn't crash. |
| 1200 ASSERT_EQ(3, manager->GetRoot()->GetId()); | 1200 ASSERT_EQ(3, manager->GetRoot()->GetId()); |
| 1201 ASSERT_EQ(3, manager->GetFocus(manager->GetRoot())->GetId()); | 1201 ASSERT_EQ(3, manager->GetFocus(manager->GetRoot())->GetId()); |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 } // namespace content | 1204 } // namespace content |
| OLD | NEW |