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

Side by Side Diff: tests/FontConfigParser.cpp

Issue 468893002: Mark fallback fonts in new Android font config parser (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 | « src/ports/SkFontConfigParser_android.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 2014 Google Inc. 2 * Copyright 2014 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 "Resources.h" 8 #include "Resources.h"
9 #include "SkFontConfigParser_android.h" 9 #include "SkFontConfigParser_android.h"
10 #include "Test.h" 10 #include "Test.h"
11 11
12 int CountFallbacks(SkTDArray<FontFamily*> fontFamilies) {
13 int countOfFallbackFonts = 0;
14 for (int i = 0; i < fontFamilies.count(); i++) {
15 if (fontFamilies[i]->fIsFallbackFont) {
16 countOfFallbackFonts++;
17 }
18 }
19 return countOfFallbackFonts;
20 }
21
12 void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies, 22 void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies,
13 skiatest::Reporter* reporter) { 23 skiatest::Reporter* reporter) {
14 REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5); 24 REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5);
15 REPORTER_ASSERT(reporter, !strcmp(fontFamilies[0]->fNames[0].c_str(), "sans- serif")); 25 REPORTER_ASSERT(reporter, !strcmp(fontFamilies[0]->fNames[0].c_str(), "sans- serif"));
16 REPORTER_ASSERT(reporter, 26 REPORTER_ASSERT(reporter,
17 !strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(), 27 !strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(),
18 "Roboto-Regular.ttf")); 28 "Roboto-Regular.ttf"));
19 REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont); 29 REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont);
20
21 } 30 }
22 31
23 void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) { 32 void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) {
24 #if SK_DEBUG_FONTS 33 #if SK_DEBUG_FONTS
25 for (int i = 0; i < fontFamilies.count(); ++i) { 34 for (int i = 0; i < fontFamilies.count(); ++i) {
26 SkDebugf("Family %d:\n", i); 35 SkDebugf("Family %d:\n", i);
27 switch(fontFamilies[i]->fVariant) { 36 switch(fontFamilies[i]->fVariant) {
28 case SkPaintOptionsAndroid::kElegant_Variant: SkDebugf(" elegant"); break; 37 case SkPaintOptionsAndroid::kElegant_Variant: SkDebugf(" elegant"); break;
29 case SkPaintOptionsAndroid::kCompact_Variant: SkDebugf(" compact"); break; 38 case SkPaintOptionsAndroid::kCompact_Variant: SkDebugf(" compact"); break;
30 default: break; 39 default: break;
(...skipping 21 matching lines...) Expand all
52 61
53 bool resourcesMissing = false; 62 bool resourcesMissing = false;
54 63
55 SkTDArray<FontFamily*> preV17FontFamilies; 64 SkTDArray<FontFamily*> preV17FontFamilies;
56 SkFontConfigParser::GetTestFontFamilies(preV17FontFamilies, 65 SkFontConfigParser::GetTestFontFamilies(preV17FontFamilies,
57 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(), 66 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(),
58 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str()); 67 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str());
59 68
60 if (preV17FontFamilies.count() > 0) { 69 if (preV17FontFamilies.count() > 0) {
61 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14); 70 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14);
71 REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10);
62 72
63 DumpLoadedFonts(preV17FontFamilies); 73 DumpLoadedFonts(preV17FontFamilies);
64 ValidateLoadedFonts(preV17FontFamilies, reporter); 74 ValidateLoadedFonts(preV17FontFamilies, reporter);
65 } else { 75 } else {
66 resourcesMissing = true; 76 resourcesMissing = true;
67 } 77 }
68 78
69 79
70 SkTDArray<FontFamily*> v17FontFamilies; 80 SkTDArray<FontFamily*> v17FontFamilies;
71 SkFontConfigParser::GetTestFontFamilies(v17FontFamilies, 81 SkFontConfigParser::GetTestFontFamilies(v17FontFamilies,
72 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(), 82 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(),
73 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str()); 83 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str());
74 84
75 if (v17FontFamilies.count() > 0) { 85 if (v17FontFamilies.count() > 0) {
76 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41); 86 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41);
87 REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 31);
77 88
78 DumpLoadedFonts(v17FontFamilies); 89 DumpLoadedFonts(v17FontFamilies);
79 ValidateLoadedFonts(v17FontFamilies, reporter); 90 ValidateLoadedFonts(v17FontFamilies, reporter);
80 } else { 91 } else {
81 resourcesMissing = true; 92 resourcesMissing = true;
82 } 93 }
83 94
84 95
85 SkTDArray<FontFamily*> v22FontFamilies; 96 SkTDArray<FontFamily*> v22FontFamilies;
86 SkFontConfigParser::GetTestFontFamilies(v22FontFamilies, 97 SkFontConfigParser::GetTestFontFamilies(v22FontFamilies,
87 GetResourcePath("android_fonts/v22/fonts.xml").c_str(), 98 GetResourcePath("android_fonts/v22/fonts.xml").c_str(),
88 NULL); 99 NULL);
89 100
90 if (v22FontFamilies.count() > 0) { 101 if (v22FontFamilies.count() > 0) {
91 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53); 102 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53);
103 REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42);
92 104
93 DumpLoadedFonts(v22FontFamilies); 105 DumpLoadedFonts(v22FontFamilies);
94 ValidateLoadedFonts(v22FontFamilies, reporter); 106 ValidateLoadedFonts(v22FontFamilies, reporter);
95 } else { 107 } else {
96 resourcesMissing = true; 108 resourcesMissing = true;
97 } 109 }
98 110
99 if (resourcesMissing) { 111 if (resourcesMissing) {
100 SkDebugf("---- Resource files missing for FontConfigParser test\n"); 112 SkDebugf("---- Resource files missing for FontConfigParser test\n");
101 } 113 }
102 } 114 }
103 115
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigParser_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698