Index: Source/core/editing/FrameSelectionTest.cpp |
diff --git a/Source/core/editing/FrameSelectionTest.cpp b/Source/core/editing/FrameSelectionTest.cpp |
index e40ed01019e3cce02718e89edbf67e8a956b3e46..7807cde2b3fafa55464d9028bd11a091fddc267b 100644 |
--- a/Source/core/editing/FrameSelectionTest.cpp |
+++ b/Source/core/editing/FrameSelectionTest.cpp |
@@ -159,6 +159,124 @@ TEST_F(FrameSelectionTest, SelectWordAroundPosition) |
EXPECT_EQ_SELECTED_TEXT("Baz"); |
} |
+// TODO: Same test for RTL |
+TEST_F(FrameSelectionTest, MoveRangeSelectionExtent) |
+{ |
+ RefPtrWillBeRawPtr<Text> text = document().createTextNode("abcdef ghij kl mnopqr stuvwx yzab,"); |
+ document().body()->appendChild(text); |
+ |
+ // "abcdef ghij kl mno|p>qr stuvwx yzab," (| means start and > means end). |
+ selection().setSelection(VisibleSelection(Position(text, 18), Position(text, 19))); |
+ EXPECT_EQ_SELECTED_TEXT("p"); |
+ // "abcdef ghij kl mno|pq>r stuvwx yzab," - expand selection using character granularity |
+ // until the end of the word is reached. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 20))); |
+ EXPECT_EQ_SELECTED_TEXT("pq"); |
+ // "abcdef ghij kl mno|pqr> stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 21))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr"); |
+ // "abcdef ghij kl mno|pqr >stuvwx yzab," - confirm selection doesn't |
+ // jump over the beginning of the word. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 22))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr "); |
+ // "abcdef ghij kl mno|pqr s>tuvwx yzab," - confirm selection switches to word granularity. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 23))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx"); |
+ // "abcdef ghij kl mno|pqr stu>vwx yzab," - selection stays the same. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 25))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx"); |
+ // "abcdef ghij kl mno|pqr stuvwx yz>ab," - next word. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 31))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx yzab"); |
+ // "abcdef ghij kl mno|pqr stuvwx y>zab," - move back one character - |
+ // confirm switch to character granularity. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 30))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx y"); |
+ // "abcdef ghij kl mno|pqr stuvwx yz>ab," - stay in character granularity |
+ // if the user moves the position within the word. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 31))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx yz"); |
+ // "abcdef ghij kl mno|pqr stuvwx >yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 29))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx "); |
+ // "abcdef ghij kl mno|pqr stuvwx y>zab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 30))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx y"); |
+ // "abcdef ghij kl mno|pqr stuv>wx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 26))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuv"); |
+ // "abcdef ghij kl mno|pqr stuvw>x yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 27))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvw"); |
+ // "abcdef ghij kl mno|pqr stuvwx y>zab," - switch to word granularity |
+ // after expanding beyond the word boundary |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 30))); |
+ EXPECT_EQ_SELECTED_TEXT("pqr stuvwx yzab"); |
+ // "abcdef ghij kl mn<o|pqr stuvwx yzab," - over to the other side of the base |
+ // - stay in character granularity until the beginning of the word is passed. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 17))); |
+ EXPECT_EQ_SELECTED_TEXT("o"); |
+ // "abcdef ghij kl m<no|pqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 16))); |
+ EXPECT_EQ_SELECTED_TEXT("no"); |
+ // "abcdef ghij kl <mno|pqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 15))); |
+ EXPECT_EQ_SELECTED_TEXT("mno"); |
+ // "abcdef ghij kl mn<o|pqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 17))); |
+ EXPECT_EQ_SELECTED_TEXT("o"); |
+ // "abcdef ghij k<l mno|pqr stuvwx yzab," - switch to word granularity |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 13))); |
+ EXPECT_EQ_SELECTED_TEXT("kl mno"); |
+ // "abcd<ef ghij kl mno|pqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 4))); |
+ EXPECT_EQ_SELECTED_TEXT("abcdef ghij kl mno"); |
+ // "abcde<f ghij kl mno|pqr stuvwx yzab," - decrease selection - |
+ // switch back to character granularity. |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5))); |
+ EXPECT_EQ_SELECTED_TEXT("f ghij kl mno"); |
+ // "abcdef ghij kl mn<o|pqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 17))); |
+ EXPECT_EQ_SELECTED_TEXT("o"); |
+ // "abcdef ghij kl m<no|pqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 16))); |
+ EXPECT_EQ_SELECTED_TEXT("no"); |
+ // "abcdef ghij k<l mno|pqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 13))); |
+ EXPECT_EQ_SELECTED_TEXT("kl mno"); |
+ |
+ // Make sure we switch to word granularity right away when starting on a |
+ // word boundary and extending. |
+ // "abcdef ghij kl |mnopqr >stuvwx yzab," (| means start and > means end). |
+ selection().setSelection(VisibleSelection(Position(text, 15), Position(text, 22))); |
+ EXPECT_EQ_SELECTED_TEXT("mnopqr "); |
+ // "abcdef ghij kl |mnopqr s>tuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 23))); |
+ EXPECT_EQ_SELECTED_TEXT("mnopqr stuvwx"); |
+ |
+ // Make sure we start in character granularity when moving extent over to the other |
+ // side of the base. |
+ // "abcdef| ghij> kl mnopqr stuvwx yzab," (| means start and > means end). |
+ selection().setSelection(VisibleSelection(Position(text, 6), Position(text, 11))); |
+ EXPECT_EQ_SELECTED_TEXT(" ghij"); |
+ // "abcde<f| ghij kl mnopqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5))); |
+ EXPECT_EQ_SELECTED_TEXT("f"); |
+ |
+ // Make sure we switch to word granularity when moving over to the other |
+ // side of the base and then passing over the word boundary. |
+ // "abcdef |ghij> kl mnopqr stuvwx yzab," |
+ selection().setSelection(VisibleSelection(Position(text, 7), Position(text, 11))); |
+ EXPECT_EQ_SELECTED_TEXT("ghij"); |
+ // "abcdef< |ghij kl mnopqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 6))); |
+ EXPECT_EQ_SELECTED_TEXT(" "); |
+ // "abcde<f |ghij kl mnopqr stuvwx yzab," |
+ selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5))); |
+ EXPECT_EQ_SELECTED_TEXT("abcdef "); |
+} |
+ |
+/* |
TEST_F(FrameSelectionTest, MoveRangeSelectionExtent) |
{ |
// "Foo Bar Baz," |
@@ -203,5 +321,5 @@ TEST_F(FrameSelectionTest, MoveRangeSelectionTest) |
selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePosition(Position(text, 2)), WordGranularity); |
EXPECT_EQ_SELECTED_TEXT("Foo Bar"); |
} |
- |
+*/ |
} |