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

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: nit picks 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
Index: Source/core/editing/FrameSelectionTest.cpp
diff --git a/Source/core/editing/FrameSelectionTest.cpp b/Source/core/editing/FrameSelectionTest.cpp
index 2aea63be379eab58fcfb09c86e29415cfadeeaae..0751de893c5e3ed980b47c50965ace8c6066a176 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_SELECTEDTEXT(text) \
Yuta Kitamura 2014/11/14 05:14:56 SELECTED_TEXT
yoichio 2014/11/14 06:19:58 Done.
+ EXPECT_EQ(text, WebString(selection().selectedText()).utf8());
Yuta Kitamura 2014/11/14 05:14:56 1. Semicolon is unnecessary. 2. Usually, macros l
yoichio 2014/11/14 06:19:59 Anyway, we need something bridges WTFString to utf
+
+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_SELECTEDTEXT("Foo");
+ // "Foo| Bar Baz,"
+ EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(text, 3))));
+ EXPECT_EQ_SELECTEDTEXT("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_SELECTEDTEXT("Baz");
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698