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

Unified Diff: third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp

Issue 2928073002: Reland: Made surrounding text work for last word in a document (Closed)
Patch Set: Do not create surrounding text for control elements, updated layout tests Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/SurroundingText.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp b/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
index 2fe38bfe7bfe7d1d01e06cb488de5f2b789e6898..f6d724fe1b4c4f090c69d0f23308f54438cd970f 100644
--- a/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
+++ b/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
@@ -80,14 +80,12 @@ TEST_F(SurroundingTextTest, BasicCaretSelection) {
}
{
- // FIXME: if the selection is at the end of the text, SurroundingText
- // will return nothing.
VisibleSelection selection = Select(7);
SurroundingText surrounding_text(selection.Start(), 42);
- EXPECT_EQ(0u, surrounding_text.Content().length());
- EXPECT_EQ(0u, surrounding_text.StartOffsetInContent());
- EXPECT_EQ(0u, surrounding_text.EndOffsetInContent());
+ EXPECT_EQ("foo bar", surrounding_text.Content().SimplifyWhiteSpace());
+ EXPECT_EQ(8u, surrounding_text.StartOffsetInContent());
+ EXPECT_EQ(8u, surrounding_text.EndOffsetInContent());
}
{
@@ -163,6 +161,17 @@ TEST_F(SurroundingTextTest, BasicRangeSelection) {
EXPECT_EQ(7u, surrounding_text.StartOffsetInContent());
EXPECT_EQ(12u, surrounding_text.EndOffsetInContent());
}
+
+ {
+ // Last word.
+ VisibleSelection selection = Select(22, 26);
+ SurroundingText surrounding_text(
+ *CreateRange(FirstEphemeralRangeOf(selection)), 8);
+
+ EXPECT_EQ("sit amet", surrounding_text.Content());
+ EXPECT_EQ(4u, surrounding_text.StartOffsetInContent());
+ EXPECT_EQ(8u, surrounding_text.EndOffsetInContent());
+ }
}
TEST_F(SurroundingTextTest, TreeCaretSelection) {
« no previous file with comments | « third_party/WebKit/Source/core/editing/SurroundingText.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698