Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_unittest.cc

Issue 895233002: Accessibility BoundsForRange needs to take scroll offsets into account. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/accessibility/browser_accessibility.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 791
792 EXPECT_EQ(gfx::Rect(130, 100, 30, 20).ToString(), 792 EXPECT_EQ(gfx::Rect(130, 100, 30, 20).ToString(),
793 static_text_accessible->GetLocalBoundsForRange(3, 3).ToString()); 793 static_text_accessible->GetLocalBoundsForRange(3, 3).ToString());
794 794
795 // This range is only two characters, but because of the direction switch 795 // This range is only two characters, but because of the direction switch
796 // the bounds are as wide as four characters. 796 // the bounds are as wide as four characters.
797 EXPECT_EQ(gfx::Rect(120, 100, 40, 20).ToString(), 797 EXPECT_EQ(gfx::Rect(120, 100, 40, 20).ToString(),
798 static_text_accessible->GetLocalBoundsForRange(2, 2).ToString()); 798 static_text_accessible->GetLocalBoundsForRange(2, 2).ToString());
799 } 799 }
800 800
801 TEST(BrowserAccessibilityManagerTest, BoundsForRangeScrolledWindow) {
802 ui::AXNodeData root;
803 root.id = 1;
804 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
805 root.AddIntAttribute(ui::AX_ATTR_SCROLL_X, 25);
806 root.AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 50);
807
808 ui::AXNodeData static_text;
809 static_text.id = 2;
810 static_text.SetValue("ABC");
811 static_text.role = ui::AX_ROLE_STATIC_TEXT;
812 static_text.location = gfx::Rect(100, 100, 16, 9);
813 root.child_ids.push_back(2);
814
815 ui::AXNodeData inline_text;
816 inline_text.id = 3;
817 inline_text.SetValue("ABC");
818 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX;
819 inline_text.location = gfx::Rect(100, 100, 16, 9);
820 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
821 ui::AX_TEXT_DIRECTION_LR);
822 std::vector<int32> character_offsets1;
823 character_offsets1.push_back(6); // 0
824 character_offsets1.push_back(11); // 1
825 character_offsets1.push_back(16); // 2
826 inline_text.AddIntListAttribute(
827 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1);
828 static_text.child_ids.push_back(3);
829
830 scoped_ptr<BrowserAccessibilityManager> manager(
831 BrowserAccessibilityManager::Create(
832 MakeAXTreeUpdate(root, static_text, inline_text),
833 NULL,
834 new CountedBrowserAccessibilityFactory()));
835
836 BrowserAccessibility* root_accessible = manager->GetRoot();
837 BrowserAccessibility* static_text_accessible =
838 root_accessible->PlatformGetChild(0);
839
840 if (manager->UseRootScrollOffsetsWhenComputingBounds()) {
841 EXPECT_EQ(gfx::Rect(75, 50, 16, 9).ToString(),
842 static_text_accessible->GetLocalBoundsForRange(0, 3).ToString());
843 } else {
844 EXPECT_EQ(gfx::Rect(100, 100, 16, 9).ToString(),
845 static_text_accessible->GetLocalBoundsForRange(0, 3).ToString());
846 }
847 }
848
801 #if defined(OS_WIN) 849 #if defined(OS_WIN)
802 #define MAYBE_BoundsForRangeOnParentElement \ 850 #define MAYBE_BoundsForRangeOnParentElement \
803 DISABLED_BoundsForRangeOnParentElement 851 DISABLED_BoundsForRangeOnParentElement
804 #else 852 #else
805 #define MAYBE_BoundsForRangeOnParentElement BoundsForRangeOnParentElement 853 #define MAYBE_BoundsForRangeOnParentElement BoundsForRangeOnParentElement
806 #endif 854 #endif
807 TEST(BrowserAccessibilityManagerTest, MAYBE_BoundsForRangeOnParentElement) { 855 TEST(BrowserAccessibilityManagerTest, MAYBE_BoundsForRangeOnParentElement) {
808 ui::AXNodeData root; 856 ui::AXNodeData root;
809 root.id = 1; 857 root.id = 1;
810 root.role = ui::AX_ROLE_ROOT_WEB_AREA; 858 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 ASSERT_EQ(NULL, manager->NextInTreeOrder(node5_accessible)); 981 ASSERT_EQ(NULL, manager->NextInTreeOrder(node5_accessible));
934 982
935 ASSERT_EQ(NULL, manager->PreviousInTreeOrder(NULL)); 983 ASSERT_EQ(NULL, manager->PreviousInTreeOrder(NULL));
936 ASSERT_EQ(node4_accessible, manager->PreviousInTreeOrder(node5_accessible)); 984 ASSERT_EQ(node4_accessible, manager->PreviousInTreeOrder(node5_accessible));
937 ASSERT_EQ(node3_accessible, manager->PreviousInTreeOrder(node4_accessible)); 985 ASSERT_EQ(node3_accessible, manager->PreviousInTreeOrder(node4_accessible));
938 ASSERT_EQ(node2_accessible, manager->PreviousInTreeOrder(node3_accessible)); 986 ASSERT_EQ(node2_accessible, manager->PreviousInTreeOrder(node3_accessible));
939 ASSERT_EQ(root_accessible, manager->PreviousInTreeOrder(node2_accessible)); 987 ASSERT_EQ(root_accessible, manager->PreviousInTreeOrder(node2_accessible));
940 } 988 }
941 989
942 } // namespace content 990 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698