Index: third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp |
index 4a1890b1188d3e753c65b26781d70c271cfee20a..7dc224ac57b6aeac6229f93129714f9311aaf28a 100644 |
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp |
@@ -493,4 +493,24 @@ TEST_F(TextIteratorTest, characterAt) |
EXPECT_EQ('o', iter2.characterAt(4)) << message2; |
} |
+TEST_F(TextIteratorTest, CopyWholeCodePoints) |
+{ |
+ const char* bodyContent = "𓀀𓀁𓀂 𓅀𓅁."; |
+ setBodyContent(bodyContent); |
+ updateLayoutAndStyleForPainting(); |
+ |
+ const UChar expected[] = {0xD80C, 0xDC00, 0xD80C, 0xDC01, 0xD80C, 0xDC02, ' ', 0xD80C, 0xDD40, 0xD80C, 0xDD41, '.'}; |
+ |
+ EphemeralRange range(EphemeralRange::rangeOfContents(document())); |
+ TextIterator iter(range.startPosition(), range.endPosition()); |
+ Vector<UChar> buffer; |
+ EXPECT_EQ(2, iter.copyTextTo(buffer, 0, 1)) << "Should emit 2 UChars for 'U+13000'."; |
+ EXPECT_EQ(4, iter.copyTextTo(buffer, 2, 3)) << "Should emit 4 UChars for 'U+13001U+13002'."; |
+ EXPECT_EQ(3, iter.copyTextTo(buffer, 6, 2)) << "Should emit 3 UChars for ' U+13140'."; |
+ EXPECT_EQ(2, iter.copyTextTo(buffer, 9, 2)) << "Should emit 2 UChars for 'U+13141'."; |
+ EXPECT_EQ(1, iter.copyTextTo(buffer, 11, 1)) << "Should emit 1 UChar for '.'."; |
+ for (int i = 0; i < 12; i++) |
+ EXPECT_EQ(expected[i], buffer[i]); |
+} |
+ |
} // namespace blink |