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

Side by Side Diff: tests/FontMgrTest.cpp

Issue 1438113002: Factor CSS3 matching rules. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Tests can use C++11. Created 5 years, 1 month 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 | « src/ports/SkFontHost_win.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 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCommandLineFlags.h" 8 #include "SkCommandLineFlags.h"
9 #include "SkFontMgr.h" 9 #include "SkFontMgr.h"
10 #include "SkTypeface.h" 10 #include "SkTypeface.h"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 #include "SkFont.h" 13 #include "SkFont.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15
16 #include <initializer_list>
17 #include <limits>
18 #include <vector>
19
15 static void test_font(skiatest::Reporter* reporter) { 20 static void test_font(skiatest::Reporter* reporter) {
16 uint32_t flags = 0; 21 uint32_t flags = 0;
17 SkAutoTUnref<SkFont> font(SkFont::Create(nullptr, 24, SkFont::kA8_MaskType, flags)); 22 SkAutoTUnref<SkFont> font(SkFont::Create(nullptr, 24, SkFont::kA8_MaskType, flags));
18 23
19 REPORTER_ASSERT(reporter, font->getTypeface()); 24 REPORTER_ASSERT(reporter, font->getTypeface());
20 REPORTER_ASSERT(reporter, 24 == font->getSize()); 25 REPORTER_ASSERT(reporter, 24 == font->getSize());
21 REPORTER_ASSERT(reporter, 1 == font->getScaleX()); 26 REPORTER_ASSERT(reporter, 1 == font->getScaleX());
22 REPORTER_ASSERT(reporter, 0 == font->getSkewX()); 27 REPORTER_ASSERT(reporter, 0 == font->getSkewX());
23 REPORTER_ASSERT(reporter, SkFont::kA8_MaskType == font->getMaskType()); 28 REPORTER_ASSERT(reporter, SkFont::kA8_MaskType == font->getMaskType());
24 29
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // REPORTER_ASSERT(reporter, face.get()); 109 // REPORTER_ASSERT(reporter, face.get());
105 110
106 if (verbose) { 111 if (verbose) {
107 SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(), 112 SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(),
108 fs.weight(), fs.width(), fs.isItalic()); 113 fs.weight(), fs.width(), fs.isItalic());
109 } 114 }
110 } 115 }
111 } 116 }
112 } 117 }
113 118
119 static void test_matchStyleCSS3(skiatest::Reporter* reporter) {
120 static const SkFontID invalidFontID = std::numeric_limits<SkFontID>::max();
121 static const SkFontStyle invalidFontStyle(101, SkFontStyle::kNormal_Width, S kFontStyle::kUpright_Slant);
122
123 class TestTypeface : public SkTypeface {
124 public:
125 TestTypeface(const SkFontStyle& fontStyle, SkFontID id) : SkTypeface(fon tStyle, id, false){}
126 protected:
127 SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullp tr; }
128 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const overri de {
129 return nullptr;
130 }
131 void onFilterRec(SkScalerContextRec*) const override { }
132 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
133 PerGlyphInfo,
134 const uint32_t*, uint32_t) const override { return nullptr; }
135 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override { }
136 virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
137 uint16_t glyphs[], int glyphCount) const override {
138 if (glyphs && glyphCount > 0) {
139 sk_bzero(glyphs, glyphCount * sizeof(glyphs[0]));
140 }
141 return 0;
142 }
143 int onCountGlyphs() const override { return 0; };
144 int onGetUPEM() const override { return 0; };
145 class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings {
146 public:
147 bool next(SkTypeface::LocalizedString*) override { return false; }
148 };
149 void onGetFamilyName(SkString* familyName) const override {
150 familyName->reset();
151 }
152 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const overrid e {
153 return new EmptyLocalizedStrings;
154 };
155 int onGetTableTags(SkFontTableTag tags[]) const override { return 0; }
156 size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const overr ide {
157 return 0;
158 }
159 };
160
161 class TestFontStyleSet : public SkFontStyleSet {
162 public:
163 TestFontStyleSet(std::initializer_list<SkFontStyle> styles) : fStyles(st yles) {}
164 int count() override { return static_cast<int>(fStyles.size()); }
165 void getStyle(int index, SkFontStyle* style, SkString*) override {
166 if (style) {
167 *style = fStyles[index];
168 }
169 }
170 SkTypeface* createTypeface(int index) override {
171 if (index < 0 || this->count() <= index) {
172 return new TestTypeface(invalidFontStyle, invalidFontID);
173 }
174 return new TestTypeface(fStyles[index], index);
175 }
176 SkTypeface* matchStyle(const SkFontStyle& pattern) override {
177 return this->matchStyleCSS3(pattern);
178 }
179 private:
180 std::vector<SkFontStyle> fStyles;
181 };
182
183 SkFontStyle condensed_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kUpright_Slant);
184 SkFontStyle condensed_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kUpright_Slant);
185 SkFontStyle condensed_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kItalic_Slant);
186 SkFontStyle condensed_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kItalic_Slant);
187 SkFontStyle expanded_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kE xpanded_Width, SkFontStyle::kUpright_Slant);
188 SkFontStyle expanded_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kE xpanded_Width, SkFontStyle::kUpright_Slant);
189 SkFontStyle expanded_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kE xpanded_Width, SkFontStyle::kItalic_Slant);
190 SkFontStyle expanded_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kE xpanded_Width, SkFontStyle::kItalic_Slant);
191
192 SkFontStyle normal_normal_100(SkFontStyle::kThin_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
193 SkFontStyle normal_normal_200(SkFontStyle::kExtraLight_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
194 SkFontStyle normal_normal_300(SkFontStyle::kLight_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
195 SkFontStyle normal_normal_400(SkFontStyle::kNormal_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
196 SkFontStyle normal_normal_500(SkFontStyle::kMedium_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
197 SkFontStyle normal_normal_600(SkFontStyle::kSemiBold_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
198 SkFontStyle normal_normal_700(SkFontStyle::kBold_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
199 SkFontStyle normal_normal_800(SkFontStyle::kExtraBold_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
200 SkFontStyle normal_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle:: kNormal_Width, SkFontStyle::kUpright_Slant);
201
202 struct StyleSetTest {
203 TestFontStyleSet styleSet;
204 struct Case {
205 SkFontStyle pattern;
206 SkFontStyle expectedResult;
207 };
208 std::vector<Case> cases;
209 } tests[] = {
210 {
211 { condensed_normal_100,condensed_normal_900,condensed_italic_100,con densed_italic_900,
212 expanded_normal_100, expanded_normal_900, expanded_italic_100, ex panded_italic_900 },
213 {
214 { condensed_normal_100, condensed_normal_100 },
215 { condensed_normal_900, condensed_normal_900 },
216 { condensed_italic_100, condensed_italic_100 },
217 { condensed_italic_900, condensed_italic_900 },
218 { expanded_normal_100, expanded_normal_100 },
219 { expanded_normal_900, expanded_normal_900 },
220 { expanded_italic_100, expanded_italic_100 },
221 { expanded_italic_900, expanded_italic_900 },
222 },
223 },
224
225 {
226 { condensed_normal_100,condensed_italic_100,expanded_normal_100,expa nded_italic_100 },
227 {
228 { condensed_normal_100, condensed_normal_100 },
229 { condensed_normal_900, condensed_normal_100 },
230 { condensed_italic_100, condensed_italic_100 },
231 { condensed_italic_900, condensed_italic_100 },
232 { expanded_normal_100, expanded_normal_100 },
233 { expanded_normal_900, expanded_normal_100 },
234 { expanded_italic_100, expanded_italic_100 },
235 { expanded_italic_900, expanded_italic_100 },
236 },
237 },
238
239 {
240 { condensed_normal_900,condensed_italic_900,expanded_normal_900,expa nded_italic_900 },
241 {
242 { condensed_normal_100, condensed_normal_900 },
243 { condensed_normal_900, condensed_normal_900 },
244 { condensed_italic_100, condensed_italic_900 },
245 { condensed_italic_900, condensed_italic_900 },
246 { expanded_normal_100, expanded_normal_900 },
247 { expanded_normal_900, expanded_normal_900 },
248 { expanded_italic_100, expanded_italic_900 },
249 { expanded_italic_900, expanded_italic_900 },
250 },
251 },
252
253 {
254 { condensed_normal_100,condensed_normal_900,expanded_normal_100,expa nded_normal_900 },
255 {
256 { condensed_normal_100, condensed_normal_100 },
257 { condensed_normal_900, condensed_normal_900 },
258 { condensed_italic_100, condensed_normal_100 },
259 { condensed_italic_900, condensed_normal_900 },
260 { expanded_normal_100, expanded_normal_100 },
261 { expanded_normal_900, expanded_normal_900 },
262 { expanded_italic_100, expanded_normal_100 },
263 { expanded_italic_900, expanded_normal_900 },
264 },
265 },
266
267 {
268 { condensed_normal_100,expanded_normal_100 },
269 {
270 { condensed_normal_100, condensed_normal_100 },
271 { condensed_normal_900, condensed_normal_100 },
272 { condensed_italic_100, condensed_normal_100 },
273 { condensed_italic_900, condensed_normal_100 },
274 { expanded_normal_100, expanded_normal_100 },
275 { expanded_normal_900, expanded_normal_100 },
276 { expanded_italic_100, expanded_normal_100 },
277 { expanded_italic_900, expanded_normal_100 },
278 },
279 },
280
281 {
282 { condensed_normal_900,expanded_normal_900 },
283 {
284 { condensed_normal_100, condensed_normal_900 },
285 { condensed_normal_900, condensed_normal_900 },
286 { condensed_italic_100, condensed_normal_900 },
287 { condensed_italic_900, condensed_normal_900 },
288 { expanded_normal_100, expanded_normal_900 },
289 { expanded_normal_900, expanded_normal_900 },
290 { expanded_italic_100, expanded_normal_900 },
291 { expanded_italic_900, expanded_normal_900 },
292 },
293 },
294
295 {
296 { condensed_italic_100,condensed_italic_900,expanded_italic_100,expa nded_italic_900 },
297 {
298 { condensed_normal_100, condensed_italic_100 },
299 { condensed_normal_900, condensed_italic_900 },
300 { condensed_italic_100, condensed_italic_100 },
301 { condensed_italic_900, condensed_italic_900 },
302 { expanded_normal_100, expanded_italic_100 },
303 { expanded_normal_900, expanded_italic_900 },
304 { expanded_italic_100, expanded_italic_100 },
305 { expanded_italic_900, expanded_italic_900 },
306 },
307 },
308
309 {
310 { condensed_italic_100,expanded_italic_100 },
311 {
312 { condensed_normal_100, condensed_italic_100 },
313 { condensed_normal_900, condensed_italic_100 },
314 { condensed_italic_100, condensed_italic_100 },
315 { condensed_italic_900, condensed_italic_100 },
316 { expanded_normal_100, expanded_italic_100 },
317 { expanded_normal_900, expanded_italic_100 },
318 { expanded_italic_100, expanded_italic_100 },
319 { expanded_italic_900, expanded_italic_100 },
320 },
321 },
322
323 {
324 { condensed_italic_900,expanded_italic_900 },
325 {
326 { condensed_normal_100, condensed_italic_900 },
327 { condensed_normal_900, condensed_italic_900 },
328 { condensed_italic_100, condensed_italic_900 },
329 { condensed_italic_900, condensed_italic_900 },
330 { expanded_normal_100, expanded_italic_900 },
331 { expanded_normal_900, expanded_italic_900 },
332 { expanded_italic_100, expanded_italic_900 },
333 { expanded_italic_900, expanded_italic_900 },
334 },
335 },
336
337 {
338 { condensed_normal_100,condensed_normal_900,condensed_italic_100,con densed_italic_900 },
339 {
340 { condensed_normal_100, condensed_normal_100 },
341 { condensed_normal_900, condensed_normal_900 },
342 { condensed_italic_100, condensed_italic_100 },
343 { condensed_italic_900, condensed_italic_900 },
344 { expanded_normal_100, condensed_normal_100 },
345 { expanded_normal_900, condensed_normal_900 },
346 { expanded_italic_100, condensed_italic_100 },
347 { expanded_italic_900, condensed_italic_900 },
348 },
349 },
350
351 {
352 { condensed_normal_100,condensed_italic_100 },
353 {
354 { condensed_normal_100, condensed_normal_100 },
355 { condensed_normal_900, condensed_normal_100 },
356 { condensed_italic_100, condensed_italic_100 },
357 { condensed_italic_900, condensed_italic_100 },
358 { expanded_normal_100, condensed_normal_100 },
359 { expanded_normal_900, condensed_normal_100 },
360 { expanded_italic_100, condensed_italic_100 },
361 { expanded_italic_900, condensed_italic_100 },
362 },
363 },
364
365 {
366 { condensed_normal_900,condensed_italic_900 },
367 {
368 { condensed_normal_100, condensed_normal_900 },
369 { condensed_normal_900, condensed_normal_900 },
370 { condensed_italic_100, condensed_italic_900 },
371 { condensed_italic_900, condensed_italic_900 },
372 { expanded_normal_100, condensed_normal_900 },
373 { expanded_normal_900, condensed_normal_900 },
374 { expanded_italic_100, condensed_italic_900 },
375 { expanded_italic_900, condensed_italic_900 },
376 },
377 },
378
379 {
380 { condensed_normal_100,condensed_normal_900 },
381 {
382 { condensed_normal_100, condensed_normal_100 },
383 { condensed_normal_900, condensed_normal_900 },
384 { condensed_italic_100, condensed_normal_100 },
385 { condensed_italic_900, condensed_normal_900 },
386 { expanded_normal_100, condensed_normal_100 },
387 { expanded_normal_900, condensed_normal_900 },
388 { expanded_italic_100, condensed_normal_100 },
389 { expanded_italic_900, condensed_normal_900 },
390 },
391 },
392
393 {
394 { condensed_normal_100 },
395 {
396 { condensed_normal_100, condensed_normal_100 },
397 { condensed_normal_900, condensed_normal_100 },
398 { condensed_italic_100, condensed_normal_100 },
399 { condensed_italic_900, condensed_normal_100 },
400 { expanded_normal_100, condensed_normal_100 },
401 { expanded_normal_900, condensed_normal_100 },
402 { expanded_italic_100, condensed_normal_100 },
403 { expanded_italic_900, condensed_normal_100 },
404 },
405 },
406
407 {
408 { condensed_normal_900 },
409 {
410 { condensed_normal_100, condensed_normal_900 },
411 { condensed_normal_900, condensed_normal_900 },
412 { condensed_italic_100, condensed_normal_900 },
413 { condensed_italic_900, condensed_normal_900 },
414 { expanded_normal_100, condensed_normal_900 },
415 { expanded_normal_900, condensed_normal_900 },
416 { expanded_italic_100, condensed_normal_900 },
417 { expanded_italic_900, condensed_normal_900 },
418 },
419 },
420
421 {
422 { condensed_italic_100,condensed_italic_900 },
423 {
424 { condensed_normal_100, condensed_italic_100 },
425 { condensed_normal_900, condensed_italic_900 },
426 { condensed_italic_100, condensed_italic_100 },
427 { condensed_italic_900, condensed_italic_900 },
428 { expanded_normal_100, condensed_italic_100 },
429 { expanded_normal_900, condensed_italic_900 },
430 { expanded_italic_100, condensed_italic_100 },
431 { expanded_italic_900, condensed_italic_900 },
432 },
433 },
434
435 {
436 { condensed_italic_100 },
437 {
438 { condensed_normal_100, condensed_italic_100 },
439 { condensed_normal_900, condensed_italic_100 },
440 { condensed_italic_100, condensed_italic_100 },
441 { condensed_italic_900, condensed_italic_100 },
442 { expanded_normal_100, condensed_italic_100 },
443 { expanded_normal_900, condensed_italic_100 },
444 { expanded_italic_100, condensed_italic_100 },
445 { expanded_italic_900, condensed_italic_100 },
446 },
447 },
448
449 {
450 { condensed_italic_900 },
451 {
452 { condensed_normal_100, condensed_italic_900 },
453 { condensed_normal_900, condensed_italic_900 },
454 { condensed_italic_100, condensed_italic_900 },
455 { condensed_italic_900, condensed_italic_900 },
456 { expanded_normal_100, condensed_italic_900 },
457 { expanded_normal_900, condensed_italic_900 },
458 { expanded_italic_100, condensed_italic_900 },
459 { expanded_italic_900, condensed_italic_900 },
460 },
461 },
462
463 {
464 { expanded_normal_100,expanded_normal_900,expanded_italic_100,expand ed_italic_900 },
465 {
466 { condensed_normal_100, expanded_normal_100 },
467 { condensed_normal_900, expanded_normal_900 },
468 { condensed_italic_100, expanded_italic_100 },
469 { condensed_italic_900, expanded_italic_900 },
470 { expanded_normal_100, expanded_normal_100 },
471 { expanded_normal_900, expanded_normal_900 },
472 { expanded_italic_100, expanded_italic_100 },
473 { expanded_italic_900, expanded_italic_900 },
474 },
475 },
476
477 {
478 { expanded_normal_100,expanded_italic_100 },
479 {
480 { condensed_normal_100, expanded_normal_100 },
481 { condensed_normal_900, expanded_normal_100 },
482 { condensed_italic_100, expanded_italic_100 },
483 { condensed_italic_900, expanded_italic_100 },
484 { expanded_normal_100, expanded_normal_100 },
485 { expanded_normal_900, expanded_normal_100 },
486 { expanded_italic_100, expanded_italic_100 },
487 { expanded_italic_900, expanded_italic_100 },
488 },
489 },
490
491 {
492 { expanded_normal_900,expanded_italic_900 },
493 {
494 { condensed_normal_100, expanded_normal_900 },
495 { condensed_normal_900, expanded_normal_900 },
496 { condensed_italic_100, expanded_italic_900 },
497 { condensed_italic_900, expanded_italic_900 },
498 { expanded_normal_100, expanded_normal_900 },
499 { expanded_normal_900, expanded_normal_900 },
500 { expanded_italic_100, expanded_italic_900 },
501 { expanded_italic_900, expanded_italic_900 },
502 },
503 },
504
505 {
506 { expanded_normal_100,expanded_normal_900 },
507 {
508 { condensed_normal_100, expanded_normal_100 },
509 { condensed_normal_900, expanded_normal_900 },
510 { condensed_italic_100, expanded_normal_100 },
511 { condensed_italic_900, expanded_normal_900 },
512 { expanded_normal_100, expanded_normal_100 },
513 { expanded_normal_900, expanded_normal_900 },
514 { expanded_italic_100, expanded_normal_100 },
515 { expanded_italic_900, expanded_normal_900 },
516 },
517 },
518
519 {
520 { expanded_normal_100 },
521 {
522 { condensed_normal_100, expanded_normal_100 },
523 { condensed_normal_900, expanded_normal_100 },
524 { condensed_italic_100, expanded_normal_100 },
525 { condensed_italic_900, expanded_normal_100 },
526 { expanded_normal_100, expanded_normal_100 },
527 { expanded_normal_900, expanded_normal_100 },
528 { expanded_italic_100, expanded_normal_100 },
529 { expanded_italic_900, expanded_normal_100 },
530 },
531 },
532
533 {
534 { expanded_normal_900 },
535 {
536 { condensed_normal_100, expanded_normal_900 },
537 { condensed_normal_900, expanded_normal_900 },
538 { condensed_italic_100, expanded_normal_900 },
539 { condensed_italic_900, expanded_normal_900 },
540 { expanded_normal_100, expanded_normal_900 },
541 { expanded_normal_900, expanded_normal_900 },
542 { expanded_italic_100, expanded_normal_900 },
543 { expanded_italic_900, expanded_normal_900 },
544 },
545 },
546
547 {
548 { expanded_italic_100,expanded_italic_900 },
549 {
550 { condensed_normal_100, expanded_italic_100 },
551 { condensed_normal_900, expanded_italic_900 },
552 { condensed_italic_100, expanded_italic_100 },
553 { condensed_italic_900, expanded_italic_900 },
554 { expanded_normal_100, expanded_italic_100 },
555 { expanded_normal_900, expanded_italic_900 },
556 { expanded_italic_100, expanded_italic_100 },
557 { expanded_italic_900, expanded_italic_900 },
558 },
559 },
560
561 {
562 { expanded_italic_100 },
563 {
564 { condensed_normal_100, expanded_italic_100 },
565 { condensed_normal_900, expanded_italic_100 },
566 { condensed_italic_100, expanded_italic_100 },
567 { condensed_italic_900, expanded_italic_100 },
568 { expanded_normal_100, expanded_italic_100 },
569 { expanded_normal_900, expanded_italic_100 },
570 { expanded_italic_100, expanded_italic_100 },
571 { expanded_italic_900, expanded_italic_100 },
572 },
573 },
574
575 {
576 { expanded_italic_900 },
577 {
578 { condensed_normal_100, expanded_italic_900 },
579 { condensed_normal_900, expanded_italic_900 },
580 { condensed_italic_100, expanded_italic_900 },
581 { condensed_italic_900, expanded_italic_900 },
582 { expanded_normal_100, expanded_italic_900 },
583 { expanded_normal_900, expanded_italic_900 },
584 { expanded_italic_100, expanded_italic_900 },
585 { expanded_italic_900, expanded_italic_900 },
586 },
587 },
588
589 {
590 { normal_normal_100, normal_normal_900 },
591 {
592 { normal_normal_300, normal_normal_100 },
593 { normal_normal_400, normal_normal_100 },
594 { normal_normal_500, normal_normal_100 },
595 { normal_normal_600, normal_normal_900 },
596 },
597 },
598
599 {
600 { normal_normal_100, normal_normal_400, normal_normal_900 },
601 {
602 { normal_normal_300, normal_normal_100 },
603 { normal_normal_400, normal_normal_400 },
604 { normal_normal_500, normal_normal_400 },
605 { normal_normal_600, normal_normal_900 },
606 },
607 },
608
609 {
610 { normal_normal_100, normal_normal_500, normal_normal_900 },
611 {
612 { normal_normal_300, normal_normal_100 },
613 { normal_normal_400, normal_normal_500 },
614 { normal_normal_500, normal_normal_500 },
615 { normal_normal_600, normal_normal_900 },
616 },
617 },
618
619 {
620 { },
621 {
622 { normal_normal_300, invalidFontStyle },
623 { normal_normal_400, invalidFontStyle },
624 { normal_normal_500, invalidFontStyle },
625 { normal_normal_600, invalidFontStyle },
626 },
627 },
628 };
629
630 for (StyleSetTest& test : tests) {
631 for (const StyleSetTest::Case testCase : test.cases) {
632 SkAutoTUnref<SkTypeface> typeface(test.styleSet.matchStyle(testCase. pattern));
633 if (typeface) {
634 REPORTER_ASSERT(reporter, typeface->fontStyle() == testCase.expe ctedResult);
635 } else {
636 REPORTER_ASSERT(reporter, invalidFontStyle == testCase.expectedR esult);
637 }
638 }
639 }
640 }
641
114 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); 642 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests.");
115 643
116 DEF_TEST(FontMgr, reporter) { 644 DEF_TEST(FontMgr, reporter) {
645 test_matchStyleCSS3(reporter);
117 test_fontiter(reporter, FLAGS_verboseFontMgr); 646 test_fontiter(reporter, FLAGS_verboseFontMgr);
118 test_alias_names(reporter); 647 test_alias_names(reporter);
119 test_font(reporter); 648 test_font(reporter);
120 } 649 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_win.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698