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

Side by Side 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 3 years, 12 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 "TextPosition tree_id=0 anchor_id=3 text_offset=9 " 1893 "TextPosition tree_id=0 anchor_id=3 text_offset=9 "
1894 "affinity=downstream annotated_text=Check box<>", 1894 "affinity=downstream annotated_text=Check box<>",
1895 "NullPosition"}})); 1895 "NullPosition"}}));
1896 1896
1897 // 1897 //
1898 // Tests for |AXRange|. 1898 // Tests for |AXRange|.
1899 // 1899 //
1900 1900
1901 // TODO(nektar): Move these tests to their own file. 1901 // TODO(nektar): Move these tests to their own file.
1902 1902
1903 TEST_F(AXPositionTest, AXRangeGetText) { 1903 TEST_F(AXPositionTest, AXRangeGetTextWithWholeObjects) {
1904 base::string16 all_text = base::UTF8ToUTF16("ButtonCheck boxLine 1\nLine 2"); 1904 base::string16 all_text = base::UTF8ToUTF16("ButtonCheck boxLine 1\nLine 2");
1905 // Create a range starting from the button object and ending at the last 1905 // Create a range starting from the button object and ending at the last
1906 // character of the root, i.e. at the last character of the second line in the 1906 // character of the root, i.e. at the last character of the second line in the
1907 // text field. 1907 // text field.
1908 TestPositionType start = AXNodePosition::CreateTreePosition( 1908 TestPositionType start = AXNodePosition::CreateTreePosition(
1909 tree_.data().tree_id, root_.id, 0 /* child_index */); 1909 tree_.data().tree_id, root_.id, 0 /* child_index */);
1910 TestPositionType end = AXNodePosition::CreateTextPosition( 1910 TestPositionType end = AXNodePosition::CreateTextPosition(
1911 tree_.data().tree_id, root_.id, 28 /* text_offset */, 1911 tree_.data().tree_id, root_.id, 28 /* text_offset */,
1912 AX_TEXT_AFFINITY_DOWNSTREAM); 1912 AX_TEXT_AFFINITY_DOWNSTREAM);
1913 AXRange<AXPosition<AXNodePosition, AXNode>> forward_range(start->Clone(), 1913 AXRange<AXPosition<AXNodePosition, AXNode>> forward_range(start->Clone(),
1914 end->Clone()); 1914 end->Clone());
1915 EXPECT_EQ(all_text, forward_range.GetText()); 1915 EXPECT_EQ(all_text, forward_range.GetText());
1916 AXRange<AXPosition<AXNodePosition, AXNode>> backward_range(std::move(end), 1916 AXRange<AXPosition<AXNodePosition, AXNode>> backward_range(std::move(end),
1917 std::move(start)); 1917 std::move(start));
1918 EXPECT_EQ(all_text, backward_range.GetText()); 1918 EXPECT_EQ(all_text, backward_range.GetText());
1919 } 1919 }
1920 1920
1921 TEST_F(AXPositionTest, AXRangeGetTextWithTextOffsets) {
1922 base::string16 most_text = base::UTF8ToUTF16("tonCheck boxLine 1\nLine");
1923 // Create a range starting from the third character in the button object and
1924 // ending two characters before the end of the root.
1925 TestPositionType start = AXNodePosition::CreateTextPosition(
1926 tree_.data().tree_id, button_.id, 3 /* text_offset */,
1927 AX_TEXT_AFFINITY_DOWNSTREAM);
1928 TestPositionType end = AXNodePosition::CreateTextPosition(
1929 tree_.data().tree_id, static_text2_.id, 4 /* text_offset */,
1930 AX_TEXT_AFFINITY_DOWNSTREAM);
1931 AXRange<AXPosition<AXNodePosition, AXNode>> forward_range(start->Clone(),
1932 end->Clone());
1933 EXPECT_EQ(most_text, forward_range.GetText());
1934 AXRange<AXPosition<AXNodePosition, AXNode>> backward_range(std::move(end),
1935 std::move(start));
1936 EXPECT_EQ(most_text, backward_range.GetText());
1937 }
1938
1921 } // namespace ui 1939 } // namespace ui
OLDNEW
« 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