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

Unified Diff: Source/core/editing/FrameSelectionTest.cpp

Issue 675413003: WebLocalFrameImpl::selectWordAroundPosition should select a word before space. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adapt to selectWordAroundPosition too Created 6 years, 1 month 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 | « Source/core/editing/FrameSelection.cpp ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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&nbsp;&nbsp;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");
+}
+
}
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698