| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 635 |
| 636 TEST(BrowserAccessibilityManagerTest, BoundsForRange) { | 636 TEST(BrowserAccessibilityManagerTest, BoundsForRange) { |
| 637 ui::AXNodeData root; | 637 ui::AXNodeData root; |
| 638 root.id = 1; | 638 root.id = 1; |
| 639 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 639 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 640 | 640 |
| 641 ui::AXNodeData static_text; | 641 ui::AXNodeData static_text; |
| 642 static_text.id = 2; | 642 static_text.id = 2; |
| 643 static_text.SetName("Hello, world."); | 643 static_text.SetName("Hello, world."); |
| 644 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 644 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 645 static_text.location = gfx::Rect(100, 100, 29, 18); | 645 static_text.location = gfx::RectF(100, 100, 29, 18); |
| 646 root.child_ids.push_back(2); | 646 root.child_ids.push_back(2); |
| 647 | 647 |
| 648 ui::AXNodeData inline_text1; | 648 ui::AXNodeData inline_text1; |
| 649 inline_text1.id = 3; | 649 inline_text1.id = 3; |
| 650 inline_text1.SetName("Hello, "); | 650 inline_text1.SetName("Hello, "); |
| 651 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 651 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 652 inline_text1.location = gfx::Rect(100, 100, 29, 9); | 652 inline_text1.location = gfx::RectF(100, 100, 29, 9); |
| 653 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 653 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 654 ui::AX_TEXT_DIRECTION_LTR); | 654 ui::AX_TEXT_DIRECTION_LTR); |
| 655 std::vector<int32_t> character_offsets1; | 655 std::vector<int32_t> character_offsets1; |
| 656 character_offsets1.push_back(6); // 0 | 656 character_offsets1.push_back(6); // 0 |
| 657 character_offsets1.push_back(11); // 1 | 657 character_offsets1.push_back(11); // 1 |
| 658 character_offsets1.push_back(16); // 2 | 658 character_offsets1.push_back(16); // 2 |
| 659 character_offsets1.push_back(21); // 3 | 659 character_offsets1.push_back(21); // 3 |
| 660 character_offsets1.push_back(26); // 4 | 660 character_offsets1.push_back(26); // 4 |
| 661 character_offsets1.push_back(29); // 5 | 661 character_offsets1.push_back(29); // 5 |
| 662 character_offsets1.push_back(29); // 6 (note that the space has no width) | 662 character_offsets1.push_back(29); // 6 (note that the space has no width) |
| 663 inline_text1.AddIntListAttribute( | 663 inline_text1.AddIntListAttribute( |
| 664 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 664 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 665 static_text.child_ids.push_back(3); | 665 static_text.child_ids.push_back(3); |
| 666 | 666 |
| 667 ui::AXNodeData inline_text2; | 667 ui::AXNodeData inline_text2; |
| 668 inline_text2.id = 4; | 668 inline_text2.id = 4; |
| 669 inline_text2.SetName("world."); | 669 inline_text2.SetName("world."); |
| 670 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 670 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 671 inline_text2.location = gfx::Rect(100, 109, 28, 9); | 671 inline_text2.location = gfx::RectF(100, 109, 28, 9); |
| 672 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 672 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 673 ui::AX_TEXT_DIRECTION_LTR); | 673 ui::AX_TEXT_DIRECTION_LTR); |
| 674 std::vector<int32_t> character_offsets2; | 674 std::vector<int32_t> character_offsets2; |
| 675 character_offsets2.push_back(5); | 675 character_offsets2.push_back(5); |
| 676 character_offsets2.push_back(10); | 676 character_offsets2.push_back(10); |
| 677 character_offsets2.push_back(15); | 677 character_offsets2.push_back(15); |
| 678 character_offsets2.push_back(20); | 678 character_offsets2.push_back(20); |
| 679 character_offsets2.push_back(25); | 679 character_offsets2.push_back(25); |
| 680 character_offsets2.push_back(28); | 680 character_offsets2.push_back(28); |
| 681 inline_text2.AddIntListAttribute( | 681 inline_text2.AddIntListAttribute( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 // returns the correct bounds for different ranges. | 728 // returns the correct bounds for different ranges. |
| 729 | 729 |
| 730 ui::AXNodeData root; | 730 ui::AXNodeData root; |
| 731 root.id = 1; | 731 root.id = 1; |
| 732 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 732 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 733 | 733 |
| 734 ui::AXNodeData static_text; | 734 ui::AXNodeData static_text; |
| 735 static_text.id = 2; | 735 static_text.id = 2; |
| 736 static_text.SetName("123abc"); | 736 static_text.SetName("123abc"); |
| 737 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 737 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 738 static_text.location = gfx::Rect(100, 100, 60, 20); | 738 static_text.location = gfx::RectF(100, 100, 60, 20); |
| 739 root.child_ids.push_back(2); | 739 root.child_ids.push_back(2); |
| 740 | 740 |
| 741 ui::AXNodeData inline_text1; | 741 ui::AXNodeData inline_text1; |
| 742 inline_text1.id = 3; | 742 inline_text1.id = 3; |
| 743 inline_text1.SetName("123"); | 743 inline_text1.SetName("123"); |
| 744 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 744 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 745 inline_text1.location = gfx::Rect(100, 100, 30, 20); | 745 inline_text1.location = gfx::RectF(100, 100, 30, 20); |
| 746 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 746 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 747 ui::AX_TEXT_DIRECTION_LTR); | 747 ui::AX_TEXT_DIRECTION_LTR); |
| 748 std::vector<int32_t> character_offsets1; | 748 std::vector<int32_t> character_offsets1; |
| 749 character_offsets1.push_back(10); // 0 | 749 character_offsets1.push_back(10); // 0 |
| 750 character_offsets1.push_back(20); // 1 | 750 character_offsets1.push_back(20); // 1 |
| 751 character_offsets1.push_back(30); // 2 | 751 character_offsets1.push_back(30); // 2 |
| 752 inline_text1.AddIntListAttribute( | 752 inline_text1.AddIntListAttribute( |
| 753 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 753 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 754 static_text.child_ids.push_back(3); | 754 static_text.child_ids.push_back(3); |
| 755 | 755 |
| 756 ui::AXNodeData inline_text2; | 756 ui::AXNodeData inline_text2; |
| 757 inline_text2.id = 4; | 757 inline_text2.id = 4; |
| 758 inline_text2.SetName("abc"); | 758 inline_text2.SetName("abc"); |
| 759 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 759 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 760 inline_text2.location = gfx::Rect(130, 100, 30, 20); | 760 inline_text2.location = gfx::RectF(130, 100, 30, 20); |
| 761 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 761 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 762 ui::AX_TEXT_DIRECTION_RTL); | 762 ui::AX_TEXT_DIRECTION_RTL); |
| 763 std::vector<int32_t> character_offsets2; | 763 std::vector<int32_t> character_offsets2; |
| 764 character_offsets2.push_back(10); | 764 character_offsets2.push_back(10); |
| 765 character_offsets2.push_back(20); | 765 character_offsets2.push_back(20); |
| 766 character_offsets2.push_back(30); | 766 character_offsets2.push_back(30); |
| 767 inline_text2.AddIntListAttribute( | 767 inline_text2.AddIntListAttribute( |
| 768 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); | 768 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
| 769 static_text.child_ids.push_back(4); | 769 static_text.child_ids.push_back(4); |
| 770 | 770 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 ui::AXNodeData root; | 804 ui::AXNodeData root; |
| 805 root.id = 1; | 805 root.id = 1; |
| 806 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 806 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 807 root.AddIntAttribute(ui::AX_ATTR_SCROLL_X, 25); | 807 root.AddIntAttribute(ui::AX_ATTR_SCROLL_X, 25); |
| 808 root.AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 50); | 808 root.AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 50); |
| 809 | 809 |
| 810 ui::AXNodeData static_text; | 810 ui::AXNodeData static_text; |
| 811 static_text.id = 2; | 811 static_text.id = 2; |
| 812 static_text.SetName("ABC"); | 812 static_text.SetName("ABC"); |
| 813 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 813 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 814 static_text.location = gfx::Rect(100, 100, 16, 9); | 814 static_text.location = gfx::RectF(100, 100, 16, 9); |
| 815 root.child_ids.push_back(2); | 815 root.child_ids.push_back(2); |
| 816 | 816 |
| 817 ui::AXNodeData inline_text; | 817 ui::AXNodeData inline_text; |
| 818 inline_text.id = 3; | 818 inline_text.id = 3; |
| 819 inline_text.SetName("ABC"); | 819 inline_text.SetName("ABC"); |
| 820 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 820 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 821 inline_text.location = gfx::Rect(100, 100, 16, 9); | 821 inline_text.location = gfx::RectF(100, 100, 16, 9); |
| 822 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 822 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 823 ui::AX_TEXT_DIRECTION_LTR); | 823 ui::AX_TEXT_DIRECTION_LTR); |
| 824 std::vector<int32_t> character_offsets1; | 824 std::vector<int32_t> character_offsets1; |
| 825 character_offsets1.push_back(6); // 0 | 825 character_offsets1.push_back(6); // 0 |
| 826 character_offsets1.push_back(11); // 1 | 826 character_offsets1.push_back(11); // 1 |
| 827 character_offsets1.push_back(16); // 2 | 827 character_offsets1.push_back(16); // 2 |
| 828 inline_text.AddIntListAttribute( | 828 inline_text.AddIntListAttribute( |
| 829 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 829 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 830 static_text.child_ids.push_back(3); | 830 static_text.child_ids.push_back(3); |
| 831 | 831 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 851 | 851 |
| 852 TEST(BrowserAccessibilityManagerTest, BoundsForRangeOnParentElement) { | 852 TEST(BrowserAccessibilityManagerTest, BoundsForRangeOnParentElement) { |
| 853 ui::AXNodeData root; | 853 ui::AXNodeData root; |
| 854 root.id = 1; | 854 root.id = 1; |
| 855 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 855 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 856 root.child_ids.push_back(2); | 856 root.child_ids.push_back(2); |
| 857 | 857 |
| 858 ui::AXNodeData div; | 858 ui::AXNodeData div; |
| 859 div.id = 2; | 859 div.id = 2; |
| 860 div.role = ui::AX_ROLE_DIV; | 860 div.role = ui::AX_ROLE_DIV; |
| 861 div.location = gfx::Rect(100, 100, 100, 20); | 861 div.location = gfx::RectF(100, 100, 100, 20); |
| 862 div.child_ids.push_back(3); | 862 div.child_ids.push_back(3); |
| 863 div.child_ids.push_back(4); | 863 div.child_ids.push_back(4); |
| 864 div.child_ids.push_back(5); | 864 div.child_ids.push_back(5); |
| 865 | 865 |
| 866 ui::AXNodeData static_text1; | 866 ui::AXNodeData static_text1; |
| 867 static_text1.id = 3; | 867 static_text1.id = 3; |
| 868 static_text1.SetName("AB"); | 868 static_text1.SetName("AB"); |
| 869 static_text1.role = ui::AX_ROLE_STATIC_TEXT; | 869 static_text1.role = ui::AX_ROLE_STATIC_TEXT; |
| 870 static_text1.location = gfx::Rect(100, 100, 40, 20); | 870 static_text1.location = gfx::RectF(100, 100, 40, 20); |
| 871 static_text1.child_ids.push_back(6); | 871 static_text1.child_ids.push_back(6); |
| 872 | 872 |
| 873 ui::AXNodeData img; | 873 ui::AXNodeData img; |
| 874 img.id = 4; | 874 img.id = 4; |
| 875 img.SetName("Test image"); | 875 img.SetName("Test image"); |
| 876 img.role = ui::AX_ROLE_IMAGE; | 876 img.role = ui::AX_ROLE_IMAGE; |
| 877 img.location = gfx::Rect(140, 100, 20, 20); | 877 img.location = gfx::RectF(140, 100, 20, 20); |
| 878 | 878 |
| 879 ui::AXNodeData static_text2; | 879 ui::AXNodeData static_text2; |
| 880 static_text2.id = 5; | 880 static_text2.id = 5; |
| 881 static_text2.SetName("CD"); | 881 static_text2.SetName("CD"); |
| 882 static_text2.role = ui::AX_ROLE_STATIC_TEXT; | 882 static_text2.role = ui::AX_ROLE_STATIC_TEXT; |
| 883 static_text2.location = gfx::Rect(160, 100, 40, 20); | 883 static_text2.location = gfx::RectF(160, 100, 40, 20); |
| 884 static_text2.child_ids.push_back(7); | 884 static_text2.child_ids.push_back(7); |
| 885 | 885 |
| 886 ui::AXNodeData inline_text1; | 886 ui::AXNodeData inline_text1; |
| 887 inline_text1.id = 6; | 887 inline_text1.id = 6; |
| 888 inline_text1.SetName("AB"); | 888 inline_text1.SetName("AB"); |
| 889 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 889 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 890 inline_text1.location = gfx::Rect(100, 100, 40, 20); | 890 inline_text1.location = gfx::RectF(100, 100, 40, 20); |
| 891 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 891 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 892 ui::AX_TEXT_DIRECTION_LTR); | 892 ui::AX_TEXT_DIRECTION_LTR); |
| 893 std::vector<int32_t> character_offsets1; | 893 std::vector<int32_t> character_offsets1; |
| 894 character_offsets1.push_back(20); // 0 | 894 character_offsets1.push_back(20); // 0 |
| 895 character_offsets1.push_back(40); // 1 | 895 character_offsets1.push_back(40); // 1 |
| 896 inline_text1.AddIntListAttribute( | 896 inline_text1.AddIntListAttribute( |
| 897 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 897 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 898 | 898 |
| 899 ui::AXNodeData inline_text2; | 899 ui::AXNodeData inline_text2; |
| 900 inline_text2.id = 7; | 900 inline_text2.id = 7; |
| 901 inline_text2.SetName("CD"); | 901 inline_text2.SetName("CD"); |
| 902 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 902 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 903 inline_text2.location = gfx::Rect(160, 100, 40, 20); | 903 inline_text2.location = gfx::RectF(160, 100, 40, 20); |
| 904 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 904 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 905 ui::AX_TEXT_DIRECTION_LTR); | 905 ui::AX_TEXT_DIRECTION_LTR); |
| 906 std::vector<int32_t> character_offsets2; | 906 std::vector<int32_t> character_offsets2; |
| 907 character_offsets2.push_back(20); // 0 | 907 character_offsets2.push_back(20); // 0 |
| 908 character_offsets2.push_back(40); // 1 | 908 character_offsets2.push_back(40); // 1 |
| 909 inline_text2.AddIntListAttribute( | 909 inline_text2.AddIntListAttribute( |
| 910 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); | 910 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
| 911 | 911 |
| 912 std::unique_ptr<BrowserAccessibilityManager> manager( | 912 std::unique_ptr<BrowserAccessibilityManager> manager( |
| 913 BrowserAccessibilityManager::Create( | 913 BrowserAccessibilityManager::Create( |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 events2[0].event_type = ui::AX_EVENT_NONE; | 1488 events2[0].event_type = ui::AX_EVENT_NONE; |
| 1489 manager->OnAccessibilityEvents(events2); | 1489 manager->OnAccessibilityEvents(events2); |
| 1490 | 1490 |
| 1491 // Make sure that the focused node was updated to the new root and | 1491 // Make sure that the focused node was updated to the new root and |
| 1492 // that this doesn't crash. | 1492 // that this doesn't crash. |
| 1493 ASSERT_EQ(3, manager->GetRoot()->GetId()); | 1493 ASSERT_EQ(3, manager->GetRoot()->GetId()); |
| 1494 ASSERT_EQ(3, manager->GetFocus()->GetId()); | 1494 ASSERT_EQ(3, manager->GetFocus()->GetId()); |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 } // namespace content | 1497 } // namespace content |
| OLD | NEW |