Index: Source/core/editing/FrameSelectionTest.cpp |
diff --git a/Source/core/editing/FrameSelectionTest.cpp b/Source/core/editing/FrameSelectionTest.cpp |
index 2aea63be379eab58fcfb09c86e29415cfadeeaae..b5ab2ddc8ad8ad4936a4fa6504f999ed4ac6f93f 100644 |
--- a/Source/core/editing/FrameSelectionTest.cpp |
+++ b/Source/core/editing/FrameSelectionTest.cpp |
@@ -138,4 +138,25 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) |
EXPECT_EQ(startCount, layoutCount()); |
} |
+#define EXPECT_EQ_SELECTED_TEXT(text) \ |
+ EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) |
+ |
+TEST_F(FrameSelectionTest, SelectWordAroundPosition) |
+{ |
+ // "Foo Bar Baz," |
+ RefPtrWillBeRawPtr<Text> text = document().createTextNode("Foo Bar Baz,"); |
+ document().body()->appendChild(text); |
+ // "Fo|o Bar Baz," |
+ EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(text, 2)))); |
+ EXPECT_EQ_SELECTED_TEXT("Foo"); |
+ // "Foo| Bar Baz," |
+ EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(text, 3)))); |
+ EXPECT_EQ_SELECTED_TEXT("Foo"); |
+ // "Foo Bar | Baz," |
+ EXPECT_FALSE(selection().selectWordAroundPosition(VisiblePosition(Position(text, 13)))); |
+ // "Foo Bar Baz|," |
+ EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(text, 22)))); |
+ EXPECT_EQ_SELECTED_TEXT("Baz"); |
+} |
+ |
} |