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

Side by Side Diff: Source/platform/fonts/shaping/HarfBuzzShaperTest.cpp

Issue 1144033004: Unicode Variation Selectors support in collectCandidateRuns (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Avoid using wcslen() in tests Created 5 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 unified diff | Download patch
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/fonts/shaping/HarfBuzzShaper.h" 6 #include "platform/fonts/shaping/HarfBuzzShaper.h"
7 7
8 #include "platform/fonts/Font.h" 8 #include "platform/fonts/Font.h"
9 #include "platform/fonts/FontCache.h" 9 #include "platform/fonts/FontCache.h"
10 #include "platform/fonts/GlyphPage.h" 10 #include "platform/fonts/GlyphPage.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 HarfBuzzShaper shaper(font, leadingCommon); 60 HarfBuzzShaper shaper(font, leadingCommon);
61 shaper.shape(); 61 shaper.shape();
62 62
63 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u); 63 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u);
64 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); 64 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true);
65 ASSERT_EQ(startIndex, 0u); 65 ASSERT_EQ(startIndex, 0u);
66 ASSERT_EQ(numGlyphs, 8u); 66 ASSERT_EQ(numGlyphs, 8u);
67 ASSERT_EQ(script, HB_SCRIPT_LATIN); 67 ASSERT_EQ(script, HB_SCRIPT_LATIN);
68 } 68 }
69 69
70 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsUnicodeVariants)
71 {
72 struct {
73 const char* name;
74 UChar string[4];
75 hb_script_t script;
76 } testlist[] = {
77 { "Standard Variants text style", { 0x30, 0xFE0E }, HB_SCRIPT_COMMON },
78 { "Standard Variants emoji style", { 0x203C, 0xFE0F }, HB_SCRIPT_COMMON },
79 { "Standard Variants of Ideograph", { 0x4FAE, 0xFE00 }, HB_SCRIPT_HAN },
80 { "Ideographic Variants", { 0x3402, 0xDB40, 0xDD00 }, HB_SCRIPT_HAN },
81 { "Not-defined Variants", { 0x41, 0xDB40, 0xDDEF }, HB_SCRIPT_LATIN },
82 };
83 for (auto& test : testlist) {
84 String str(test.string);
85 TextRun run(str);
86 HarfBuzzShaper shaper(font, run);
87 shaper.shape();
88 EXPECT_EQ(1u, shaper.numberOfRunsForTesting()) << test.name;
89 ASSERT_TRUE(shaper.runInfoForTesting(0, startIndex, numGlyphs, script)) << test.name;
90 EXPECT_EQ(0u, startIndex) << test.name;
91 // TODO(kojii): HarfBuzzFace does not support UVS yet and numGlyphs beco mes 2
92 // EXPECT_EQ(1u, numGlyphs) << test.name;
93 EXPECT_EQ(test.script, script) << test.name;
94 }
95 }
96
70 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsDevanagariCommon) 97 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsDevanagariCommon)
71 { 98 {
72 UChar devanagariCommonString[] = { 0x915, 0x94d, 0x930, 0x28, 0x20, 0x29 }; 99 UChar devanagariCommonString[] = { 0x915, 0x94d, 0x930, 0x28, 0x20, 0x29 };
73 TextRun devanagariCommonLatin(devanagariCommonString, 6); 100 TextRun devanagariCommonLatin(devanagariCommonString, 6);
74 HarfBuzzShaper shaper(font, devanagariCommonLatin); 101 HarfBuzzShaper shaper(font, devanagariCommonLatin);
75 shaper.shape(); 102 shaper.shape();
76 103
77 ASSERT_EQ(shaper.numberOfRunsForTesting(), 2u); 104 ASSERT_EQ(shaper.numberOfRunsForTesting(), 2u);
78 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); 105 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true);
79 ASSERT_EQ(startIndex, 0u); 106 ASSERT_EQ(startIndex, 0u);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 shaper.shape(); 174 shaper.shape();
148 175
149 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u); 176 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u);
150 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); 177 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true);
151 ASSERT_EQ(startIndex, 0u); 178 ASSERT_EQ(startIndex, 0u);
152 ASSERT_EQ(numGlyphs, 3u); 179 ASSERT_EQ(numGlyphs, 3u);
153 ASSERT_EQ(script, HB_SCRIPT_ARABIC); 180 ASSERT_EQ(script, HB_SCRIPT_ARABIC);
154 } 181 }
155 182
156 } 183 }
OLDNEW
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698