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

Unified Diff: third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaperTest.cpp

Issue 1525993005: Change CachingWordShapeIterator to delimit CJK characters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TestExpectations Created 5 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/platform/fonts/shaping/CachingWordShapeIterator.h ('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/platform/fonts/shaping/CachingWordShaperTest.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaperTest.cpp b/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaperTest.cpp
index 11fccabe23ce84c1656f8ec0304c82d4c7061f85..83129b2b50b38d25e8cd3a76fc928e5a77484405 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaperTest.cpp
+++ b/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaperTest.cpp
@@ -179,6 +179,162 @@ TEST_F(CachingWordShaperTest, SubRunWithZeroGlyphs)
shaper.selectionRect(&font, textRun, point, height, 0, 8);
}
+TEST_F(CachingWordShaperTest, SegmentCJKByCharacter)
+{
+ const UChar str[] = {
+ 0x56FD, 0x56FD, // CJK Unified Ideograph
+ 'a', 'b',
+ 0x56FD, // CJK Unified Ideograph
+ 'x', 'y', 'z',
+ 0x3042, // HIRAGANA LETTER A
+ 0x56FD, // CJK Unified Ideograph
+ 0x0
+ };
+ TextRun textRun(str, 10);
+
+ RefPtr<ShapeResult> wordResult;
+ CachingWordShapeIterator iterator(cache.get(), textRun, &font);
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(2u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(3u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_FALSE(iterator.next(&wordResult));
+}
+
+TEST_F(CachingWordShaperTest, SegmentCJKAndCommon)
+{
+ const UChar str[] = {
+ 'a', 'b',
+ 0xFF08, // FULLWIDTH LEFT PARENTHESIS (script=common)
+ 0x56FD, // CJK Unified Ideograph
+ 0x56FD, // CJK Unified Ideograph
+ 0x56FD, // CJK Unified Ideograph
+ 0x3002, // IDEOGRAPHIC FULL STOP (script=common)
+ 0x0
+ };
+ TextRun textRun(str, 7);
+
+ RefPtr<ShapeResult> wordResult;
+ CachingWordShapeIterator iterator(cache.get(), textRun, &font);
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(2u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(2u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(2u, wordResult->numCharacters());
+
+ ASSERT_FALSE(iterator.next(&wordResult));
+}
+
+TEST_F(CachingWordShaperTest, SegmentCJKAndInherit)
+{
+ const UChar str[] = {
+ 0x304B, // HIRAGANA LETTER KA
+ 0x304B, // HIRAGANA LETTER KA
+ 0x3009, // COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK
+ 0x304B, // HIRAGANA LETTER KA
+ 0x0
+ };
+ TextRun textRun(str, 4);
+
+ RefPtr<ShapeResult> wordResult;
+ CachingWordShapeIterator iterator(cache.get(), textRun, &font);
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(2u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_FALSE(iterator.next(&wordResult));
+}
+
+TEST_F(CachingWordShaperTest, SegmentCJKAndNonCJKCommon)
+{
+ const UChar str[] = {
+ 0x56FD, // CJK Unified Ideograph
+ ' ',
+ 0x0
+ };
+ TextRun textRun(str, 2);
+
+ RefPtr<ShapeResult> wordResult;
+ CachingWordShapeIterator iterator(cache.get(), textRun, &font);
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_FALSE(iterator.next(&wordResult));
+}
+
+TEST_F(CachingWordShaperTest, SegmentCJKCommon)
+{
+ const UChar str[] = {
+ 0xFF08, // FULLWIDTH LEFT PARENTHESIS (script=common)
+ 0xFF08, // FULLWIDTH LEFT PARENTHESIS (script=common)
+ 0xFF08, // FULLWIDTH LEFT PARENTHESIS (script=common)
+ 0x0
+ };
+ TextRun textRun(str, 3);
+
+ RefPtr<ShapeResult> wordResult;
+ CachingWordShapeIterator iterator(cache.get(), textRun, &font);
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(3u, wordResult->numCharacters());
+
+ ASSERT_FALSE(iterator.next(&wordResult));
+}
+
+TEST_F(CachingWordShaperTest, SegmentCJKCommonAndNonCJK)
+{
+ const UChar str[] = {
+ 0xFF08, // FULLWIDTH LEFT PARENTHESIS (script=common)
+ 'a', 'b',
+ 0x0
+ };
+ TextRun textRun(str, 3);
+
+ RefPtr<ShapeResult> wordResult;
+ CachingWordShapeIterator iterator(cache.get(), textRun, &font);
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(1u, wordResult->numCharacters());
+
+ ASSERT_TRUE(iterator.next(&wordResult));
+ EXPECT_EQ(2u, wordResult->numCharacters());
+
+ ASSERT_FALSE(iterator.next(&wordResult));
+}
+
TEST_F(CachingWordShaperTest, TextOrientationFallbackShouldNotInFallbackList)
{
const UChar str[] = {
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/shaping/CachingWordShapeIterator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698