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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/CharacterIteratorTest.cpp

Issue 2564763002: Fix calculateCharacterSubrange() when length == 0 (Closed)
Patch Set: Add a unit test Created 4 years 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/iterators/CharacterIterator.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/iterators/CharacterIteratorTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/CharacterIteratorTest.cpp b/third_party/WebKit/Source/core/editing/iterators/CharacterIteratorTest.cpp
index 6fc429312cc29e3c009542e5c017407245cb4cf5..a5e54ed9e9ac9361d92d28f95592e5dd34648347 100644
--- a/third_party/WebKit/Source/core/editing/iterators/CharacterIteratorTest.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/CharacterIteratorTest.cpp
@@ -53,4 +53,21 @@ TEST_F(CharacterIteratorTest, SubrangeWithReplacedElements) {
EXPECT_EQ(Position(textNode, 3), result.endPosition());
}
+TEST_F(CharacterIteratorTest, CollapsedSubrange) {
+ static const char* bodyContent =
+ "<div id='div' contenteditable='true'>hello</div>";
+ setBodyContent(bodyContent);
+ document().view()->updateAllLifecyclePhases();
+
+ Node* textNode = document().getElementById("div")->lastChild();
+ Range* entireRange = Range::create(document(), textNode, 1, textNode, 4);
+ EXPECT_EQ(1, entireRange->startOffset());
+ EXPECT_EQ(4, entireRange->endOffset());
+
+ const EphemeralRange& result =
+ calculateCharacterSubrange(EphemeralRange(entireRange), 2, 0);
+ EXPECT_EQ(Position(textNode, 3), result.startPosition());
+ EXPECT_EQ(Position(textNode, 3), result.endPosition());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/CharacterIterator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698