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

Unified Diff: ui/accessibility/ax_node_position_unittest.cc

Issue 2565833002: Uses |AXPosition| to enable navigation by character, word and line in content editables on the Mac. (Closed)
Patch Set: Fixed some boundary errors. Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/accessibility/browser_accessibility_cocoa.mm ('k') | ui/accessibility/ax_position.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/ax_node_position_unittest.cc
diff --git a/ui/accessibility/ax_node_position_unittest.cc b/ui/accessibility/ax_node_position_unittest.cc
index f2fc9c3463b36fc152b97cce7400e6fa3b153188..253967c1fde037ae069ccbee519b140f6e23372a 100644
--- a/ui/accessibility/ax_node_position_unittest.cc
+++ b/ui/accessibility/ax_node_position_unittest.cc
@@ -1900,7 +1900,7 @@ INSTANTIATE_TEST_CASE_P(
// TODO(nektar): Move these tests to their own file.
-TEST_F(AXPositionTest, AXRangeGetText) {
+TEST_F(AXPositionTest, AXRangeGetTextWithWholeObjects) {
base::string16 all_text = base::UTF8ToUTF16("ButtonCheck boxLine 1\nLine 2");
// Create a range starting from the button object and ending at the last
// character of the root, i.e. at the last character of the second line in the
@@ -1918,4 +1918,22 @@ TEST_F(AXPositionTest, AXRangeGetText) {
EXPECT_EQ(all_text, backward_range.GetText());
}
+TEST_F(AXPositionTest, AXRangeGetTextWithTextOffsets) {
+ base::string16 most_text = base::UTF8ToUTF16("tonCheck boxLine 1\nLine");
+ // Create a range starting from the third character in the button object and
+ // ending two characters before the end of the root.
+ TestPositionType start = AXNodePosition::CreateTextPosition(
+ tree_.data().tree_id, button_.id, 3 /* text_offset */,
+ AX_TEXT_AFFINITY_DOWNSTREAM);
+ TestPositionType end = AXNodePosition::CreateTextPosition(
+ tree_.data().tree_id, static_text2_.id, 4 /* text_offset */,
+ AX_TEXT_AFFINITY_DOWNSTREAM);
+ AXRange<AXPosition<AXNodePosition, AXNode>> forward_range(start->Clone(),
+ end->Clone());
+ EXPECT_EQ(most_text, forward_range.GetText());
+ AXRange<AXPosition<AXNodePosition, AXNode>> backward_range(std::move(end),
+ std::move(start));
+ EXPECT_EQ(most_text, backward_range.GetText());
+}
+
} // namespace ui
« no previous file with comments | « content/browser/accessibility/browser_accessibility_cocoa.mm ('k') | ui/accessibility/ax_position.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698