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

Side by Side Diff: Source/platform/fonts/FontTest.cpp

Issue 116423007: Moving Text Simple/Complex Path prefix from Font.cpp to new File (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing merge issues Created 6 years, 11 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/Font.cpp ('k') | Source/platform/fonts/mac/ComplexTextController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 29 matching lines...) Expand all
40 UChar midway[1]; 40 UChar midway[1];
41 UChar end[1]; 41 UChar end[1];
42 UChar above[1]; 42 UChar above[1];
43 43
44 below[0] = rangeStart - 1; 44 below[0] = rangeStart - 1;
45 start[0] = rangeStart; 45 start[0] = rangeStart;
46 midway[0] = ((int)rangeStart + (int)rangeEnd) / 2; 46 midway[0] = ((int)rangeStart + (int)rangeEnd) / 2;
47 end[0] = rangeEnd; 47 end[0] = rangeEnd;
48 above[0] = rangeEnd + 1; 48 above[0] = rangeEnd + 1;
49 49
50 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(below, 1)); 50 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(below, 1));
51 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(start, 1)); 51 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(start, 1));
52 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(midway, 1)); 52 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(midway, 1));
53 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(end, 1)); 53 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(end, 1));
54 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(above, 1)); 54 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(above, 1));
55 } 55 }
56 56
57 TEST(FontTest, TestCharacterRangeCodePath) 57 TEST(FontTest, TestCharacterRangeCodePath)
58 { 58 {
59 static UChar c1[] = { 0x0 }; 59 static UChar c1[] = { 0x0 };
60 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c1, 1)); 60 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c1, 1));
61 61
62 TestSpecificUCharRange(0x2E5, 0x2E9); 62 TestSpecificUCharRange(0x2E5, 0x2E9);
63 TestSpecificUCharRange(0x300, 0x36F); 63 TestSpecificUCharRange(0x300, 0x36F);
64 TestSpecificUCharRange(0x0591, 0x05BD); 64 TestSpecificUCharRange(0x0591, 0x05BD);
65 TestSpecificUCharRange(0x05BF, 0x05CF); 65 TestSpecificUCharRange(0x05BF, 0x05CF);
66 TestSpecificUCharRange(0x0600, 0x109F); 66 TestSpecificUCharRange(0x0600, 0x109F);
67 TestSpecificUCharRange(0x1100, 0x11FF); 67 TestSpecificUCharRange(0x1100, 0x11FF);
68 TestSpecificUCharRange(0x135D, 0x135F); 68 TestSpecificUCharRange(0x135D, 0x135F);
69 TestSpecificUCharRange(0x1700, 0x18AF); 69 TestSpecificUCharRange(0x1700, 0x18AF);
70 TestSpecificUCharRange(0x1900, 0x194F); 70 TestSpecificUCharRange(0x1900, 0x194F);
71 TestSpecificUCharRange(0x1980, 0x19DF); 71 TestSpecificUCharRange(0x1980, 0x19DF);
72 TestSpecificUCharRange(0x1A00, 0x1CFF); 72 TestSpecificUCharRange(0x1A00, 0x1CFF);
73 73
74 static UChar c2[] = { 0x1DBF }; 74 static UChar c2[] = { 0x1DBF };
75 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c2, 1)); 75 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c2, 1));
76 static UChar c3[] = { 0x1DC0 }; 76 static UChar c3[] = { 0x1DC0 };
77 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c3, 1)); 77 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c3, 1));
78 static UChar c4[] = { 0x1DD0 }; 78 static UChar c4[] = { 0x1DD0 };
79 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c4, 1)); 79 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c4, 1));
80 static UChar c5[] = { 0x1DFF }; 80 static UChar c5[] = { 0x1DFF };
81 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c5, 1)); 81 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c5, 1));
82 static UChar c6[] = { 0x1E00 }; 82 static UChar c6[] = { 0x1E00 };
83 EXPECT_EQ(Font::SimpleWithGlyphOverflow, Font::characterRangeCodePath(c6, 1) ); 83 EXPECT_EQ(SimpleWithGlyphOverflowPath, Font::characterRangeCodePath(c6, 1));
84 static UChar c7[] = { 0x2000 }; 84 static UChar c7[] = { 0x2000 };
85 EXPECT_EQ(Font::SimpleWithGlyphOverflow, Font::characterRangeCodePath(c7, 1) ); 85 EXPECT_EQ(SimpleWithGlyphOverflowPath, Font::characterRangeCodePath(c7, 1));
86 static UChar c8[] = { 0x2001 }; 86 static UChar c8[] = { 0x2001 };
87 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c8, 1)); 87 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c8, 1));
88 88
89 TestSpecificUCharRange(0x20D0, 0x20FF); 89 TestSpecificUCharRange(0x20D0, 0x20FF);
90 TestSpecificUCharRange(0x2CEF, 0x2CF1); 90 TestSpecificUCharRange(0x2CEF, 0x2CF1);
91 TestSpecificUCharRange(0x302A, 0x302F); 91 TestSpecificUCharRange(0x302A, 0x302F);
92 92
93 TestSpecificUCharRange(0xA67C, 0xA67D); 93 TestSpecificUCharRange(0xA67C, 0xA67D);
94 TestSpecificUCharRange(0xA6F0, 0xA6F1); 94 TestSpecificUCharRange(0xA6F0, 0xA6F1);
95 TestSpecificUCharRange(0xA800, 0xABFF); 95 TestSpecificUCharRange(0xA800, 0xABFF);
96 96
97 TestSpecificUCharRange(0xD7B0, 0xD7FF); 97 TestSpecificUCharRange(0xD7B0, 0xD7FF);
98 TestSpecificUCharRange(0xFE00, 0xFE0F); 98 TestSpecificUCharRange(0xFE00, 0xFE0F);
99 TestSpecificUCharRange(0xFE20, 0xFE2F); 99 TestSpecificUCharRange(0xFE20, 0xFE2F);
100 } 100 }
101 101
102 TEST(FontTest, TestCharacterRangeCodePathSurrogate1) 102 TEST(FontTest, TestCharacterRangeCodePathSurrogate1)
103 { 103 {
104 /* To be surrogate ... */ 104 /* To be surrogate ... */
105 /* 1st character must be 0xD800 .. 0xDBFF */ 105 /* 1st character must be 0xD800 .. 0xDBFF */
106 /* 2nd character must be 0xdc00 .. 0xdfff */ 106 /* 2nd character must be 0xdc00 .. 0xdfff */
107 107
108 /* The following 5 should all be Simple because they are not surrogate. */ 108 /* The following 5 should all be Simple because they are not surrogate. */
109 static UChar c1[] = { 0xD800, 0xDBFE }; 109 static UChar c1[] = { 0xD800, 0xDBFE };
110 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c1, 2)); 110 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c1, 2));
111 static UChar c2[] = { 0xD800, 0xE000 }; 111 static UChar c2[] = { 0xD800, 0xE000 };
112 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c2, 2)); 112 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c2, 2));
113 static UChar c3[] = { 0xDBFF, 0xDBFE }; 113 static UChar c3[] = { 0xDBFF, 0xDBFE };
114 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c3, 2)); 114 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c3, 2));
115 static UChar c4[] = { 0xDBFF, 0xE000 }; 115 static UChar c4[] = { 0xDBFF, 0xE000 };
116 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c4, 2)); 116 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c4, 2));
117 static UChar c5[] = { 0xDC00, 0xDBFF }; 117 static UChar c5[] = { 0xDC00, 0xDBFF };
118 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c5, 2)); 118 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c5, 2));
119 119
120 /* To be Complex, the Supplementary Character must be in either */ 120 /* To be Complex, the Supplementary Character must be in either */
121 /* U+1F1E6 through U+1F1FF or U+E0100 through U+E01EF. */ 121 /* U+1F1E6 through U+1F1FF or U+E0100 through U+E01EF. */
122 /* That is, a lead of 0xD83C with trail 0xDDE6 .. 0xDDFF or */ 122 /* That is, a lead of 0xD83C with trail 0xDDE6 .. 0xDDFF or */
123 /* a lead of 0xDB40 with trail 0xDD00 .. 0xDDEF. */ 123 /* a lead of 0xDB40 with trail 0xDD00 .. 0xDDEF. */
124 static UChar c6[] = { 0xD83C, 0xDDE5 }; 124 static UChar c6[] = { 0xD83C, 0xDDE5 };
125 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c6, 2)); 125 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c6, 2));
126 static UChar c7[] = { 0xD83C, 0xDDE6 }; 126 static UChar c7[] = { 0xD83C, 0xDDE6 };
127 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c7, 2)); 127 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c7, 2));
128 static UChar c8[] = { 0xD83C, 0xDDF0 }; 128 static UChar c8[] = { 0xD83C, 0xDDF0 };
129 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c8, 2)); 129 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c8, 2));
130 static UChar c9[] = { 0xD83C, 0xDDFF }; 130 static UChar c9[] = { 0xD83C, 0xDDFF };
131 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c9, 2)); 131 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c9, 2));
132 static UChar c10[] = { 0xD83C, 0xDE00 }; 132 static UChar c10[] = { 0xD83C, 0xDE00 };
133 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c10, 2)); 133 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c10, 2));
134 134
135 static UChar c11[] = { 0xDB40, 0xDCFF }; 135 static UChar c11[] = { 0xDB40, 0xDCFF };
136 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c11, 2)); 136 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c11, 2));
137 static UChar c12[] = { 0xDB40, 0xDD00 }; 137 static UChar c12[] = { 0xDB40, 0xDD00 };
138 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c12, 2)); 138 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c12, 2));
139 static UChar c13[] = { 0xDB40, 0xDDED }; 139 static UChar c13[] = { 0xDB40, 0xDDED };
140 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c13, 2)); 140 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c13, 2));
141 static UChar c14[] = { 0xDB40, 0xDDEF }; 141 static UChar c14[] = { 0xDB40, 0xDDEF };
142 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c14, 2)); 142 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c14, 2));
143 static UChar c15[] = { 0xDB40, 0xDDF0 }; 143 static UChar c15[] = { 0xDB40, 0xDDF0 };
144 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c15, 2)); 144 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c15, 2));
145 } 145 }
146 146
147 TEST(FontTest, TestCharacterRangeCodePathString) 147 TEST(FontTest, TestCharacterRangeCodePathString)
148 { 148 {
149 // Simple-Simple is still simple 149 // Simple-Simple is still simple
150 static UChar c1[] = { 0x2FF, 0x2FF }; 150 static UChar c1[] = { 0x2FF, 0x2FF };
151 EXPECT_EQ(Font::Simple, Font::characterRangeCodePath(c1, 2)); 151 EXPECT_EQ(SimplePath, Font::characterRangeCodePath(c1, 2));
152 // Complex-Simple is Complex 152 // Complex-Simple is Complex
153 static UChar c2[] = { 0x300, 0x2FF }; 153 static UChar c2[] = { 0x300, 0x2FF };
154 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c2, 2)); 154 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c2, 2));
155 // Simple-Complex is Complex 155 // Simple-Complex is Complex
156 static UChar c3[] = { 0x2FF, 0x330 }; 156 static UChar c3[] = { 0x2FF, 0x330 };
157 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c3, 2)); 157 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c3, 2));
158 // Complex-Complex is Complex 158 // Complex-Complex is Complex
159 static UChar c4[] = { 0x36F, 0x330 }; 159 static UChar c4[] = { 0x36F, 0x330 };
160 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c4, 2)); 160 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c4, 2));
161 // SimpleWithGlyphOverflow-Simple is SimpleWithGlyphOverflow 161 // SimpleWithGlyphOverflow-Simple is SimpleWithGlyphOverflow
162 static UChar c5[] = { 0x1E00, 0x2FF }; 162 static UChar c5[] = { 0x1E00, 0x2FF };
163 EXPECT_EQ(Font::SimpleWithGlyphOverflow, Font::characterRangeCodePath(c5, 2) ); 163 EXPECT_EQ(SimpleWithGlyphOverflowPath, Font::characterRangeCodePath(c5, 2));
164 // Simple-SimpleWithGlyphOverflow is SimpleWithGlyphOverflow 164 // Simple-SimpleWithGlyphOverflow is SimpleWithGlyphOverflow
165 static UChar c6[] = { 0x2FF, 0x2000 }; 165 static UChar c6[] = { 0x2FF, 0x2000 };
166 EXPECT_EQ(Font::SimpleWithGlyphOverflow, Font::characterRangeCodePath(c6, 2) ); 166 EXPECT_EQ(SimpleWithGlyphOverflowPath, Font::characterRangeCodePath(c6, 2));
167 // SimpleWithGlyphOverflow-Complex is Complex 167 // SimpleWithGlyphOverflow-Complex is Complex
168 static UChar c7[] = { 0x1E00, 0x330 }; 168 static UChar c7[] = { 0x1E00, 0x330 };
169 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c7, 2)); 169 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c7, 2));
170 // Complex-SimpleWithGlyphOverflow is Complex 170 // Complex-SimpleWithGlyphOverflow is Complex
171 static UChar c8[] = { 0x330, 0x2000 }; 171 static UChar c8[] = { 0x330, 0x2000 };
172 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c8, 2)); 172 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c8, 2));
173 // Surrogate-Complex is Complex 173 // Surrogate-Complex is Complex
174 static UChar c9[] = { 0xD83C, 0xDDE5, 0x330 }; 174 static UChar c9[] = { 0xD83C, 0xDDE5, 0x330 };
175 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c9, 3)); 175 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c9, 3));
176 // Complex-Surrogate is Complex 176 // Complex-Surrogate is Complex
177 static UChar c10[] = { 0x330, 0xD83C, 0xDDE5 }; 177 static UChar c10[] = { 0x330, 0xD83C, 0xDDE5 };
178 EXPECT_EQ(Font::Complex, Font::characterRangeCodePath(c10, 3)); 178 EXPECT_EQ(ComplexPath, Font::characterRangeCodePath(c10, 3));
179 } 179 }
180 180
181 static void TestSpecificUChar32RangeIdeograph(UChar32 rangeStart, UChar32 rangeE nd) 181 static void TestSpecificUChar32RangeIdeograph(UChar32 rangeStart, UChar32 rangeE nd)
182 { 182 {
183 EXPECT_FALSE(Font::isCJKIdeograph(rangeStart - 1)); 183 EXPECT_FALSE(Font::isCJKIdeograph(rangeStart - 1));
184 EXPECT_TRUE(Font::isCJKIdeograph(rangeStart)); 184 EXPECT_TRUE(Font::isCJKIdeograph(rangeStart));
185 EXPECT_TRUE(Font::isCJKIdeograph((UChar32)((uint64_t)rangeStart + (uint64_t) rangeEnd) / 2)); 185 EXPECT_TRUE(Font::isCJKIdeograph((UChar32)((uint64_t)rangeStart + (uint64_t) rangeEnd) / 2));
186 EXPECT_TRUE(Font::isCJKIdeograph(rangeEnd)); 186 EXPECT_TRUE(Font::isCJKIdeograph(rangeEnd));
187 EXPECT_FALSE(Font::isCJKIdeograph(rangeEnd + 1)); 187 EXPECT_FALSE(Font::isCJKIdeograph(rangeEnd + 1));
188 } 188 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 TestSpecificUChar32RangeIdeographSymbol(0x1F110, 0x1F129); 357 TestSpecificUChar32RangeIdeographSymbol(0x1F110, 0x1F129);
358 TestSpecificUChar32RangeIdeographSymbol(0x1F130, 0x1F149); 358 TestSpecificUChar32RangeIdeographSymbol(0x1F130, 0x1F149);
359 TestSpecificUChar32RangeIdeographSymbol(0x1F150, 0x1F169); 359 TestSpecificUChar32RangeIdeographSymbol(0x1F150, 0x1F169);
360 TestSpecificUChar32RangeIdeographSymbol(0x1F170, 0x1F189); 360 TestSpecificUChar32RangeIdeographSymbol(0x1F170, 0x1F189);
361 TestSpecificUChar32RangeIdeographSymbol(0x1F200, 0x1F6FF); 361 TestSpecificUChar32RangeIdeographSymbol(0x1F200, 0x1F6FF);
362 } 362 }
363 363
364 } // namespace WebCore 364 } // namespace WebCore
365 365
OLDNEW
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | Source/platform/fonts/mac/ComplexTextController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698