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

Side by Side Diff: tests/FontConfigParser.cpp

Issue 887113002: Add factory for Android font manager. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove no longer wanted function. Created 5 years, 10 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/SkFontMgr_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"
(...skipping 19 matching lines...) Expand all
30 30
31 void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) { 31 void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) {
32 #if SK_DEBUG_FONTS 32 #if SK_DEBUG_FONTS
33 for (int i = 0; i < fontFamilies.count(); ++i) { 33 for (int i = 0; i < fontFamilies.count(); ++i) {
34 SkDebugf("Family %d:\n", i); 34 SkDebugf("Family %d:\n", i);
35 switch(fontFamilies[i]->fVariant) { 35 switch(fontFamilies[i]->fVariant) {
36 case kElegant_FontVariant: SkDebugf(" elegant\n"); break; 36 case kElegant_FontVariant: SkDebugf(" elegant\n"); break;
37 case kCompact_FontVariant: SkDebugf(" compact\n"); break; 37 case kCompact_FontVariant: SkDebugf(" compact\n"); break;
38 default: break; 38 default: break;
39 } 39 }
40 if (fontFamilies[i]->fBasePath) {
41 SkDebugf(" basePath %s\n", fontFamilies[i]->fBasePath);
42 }
40 if (!fontFamilies[i]->fLanguage.getTag().isEmpty()) { 43 if (!fontFamilies[i]->fLanguage.getTag().isEmpty()) {
41 SkDebugf(" language %s\n", fontFamilies[i]->fLanguage.getTag().c_st r()); 44 SkDebugf(" language %s\n", fontFamilies[i]->fLanguage.getTag().c_st r());
42 } 45 }
43 for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) { 46 for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) {
44 SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str()); 47 SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str());
45 } 48 }
46 for (int j = 0; j < fontFamilies[i]->fFonts.count(); ++j) { 49 for (int j = 0; j < fontFamilies[i]->fFonts.count(); ++j) {
47 const FontFileInfo& ffi = fontFamilies[i]->fFonts[j]; 50 const FontFileInfo& ffi = fontFamilies[i]->fFonts[j];
48 SkDebugf(" file (%d) %s#%d\n", ffi.fWeight, ffi.fFileName.c_str(), ffi.fIndex); 51 SkDebugf(" file (%d) %s#%d\n", ffi.fWeight, ffi.fFileName.c_str(), ffi.fIndex);
49 } 52 }
50 } 53 }
51 #endif // SK_DEBUG_FONTS 54 #endif // SK_DEBUG_FONTS
52 } 55 }
53 56
54 DEF_TEST(FontConfigParserAndroid, reporter) { 57 DEF_TEST(FontConfigParserAndroid, reporter) {
55 58
56 bool resourcesMissing = false; 59 bool resourcesMissing = false;
57 60
58 SkTDArray<FontFamily*> preV17FontFamilies; 61 SkTDArray<FontFamily*> preV17FontFamilies;
59 SkFontConfigParser::GetTestFontFamilies(preV17FontFamilies, 62 SkFontConfigParser::GetCustomFontFamilies(preV17FontFamilies,
63 SkString("/custom/font/path/"),
60 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(), 64 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(),
61 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str()); 65 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str());
62 66
63 if (preV17FontFamilies.count() > 0) { 67 if (preV17FontFamilies.count() > 0) {
64 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14); 68 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14);
65 REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10); 69 REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10);
66 70
67 DumpLoadedFonts(preV17FontFamilies); 71 DumpLoadedFonts(preV17FontFamilies);
68 ValidateLoadedFonts(preV17FontFamilies, "Roboto-Regular.ttf", reporter); 72 ValidateLoadedFonts(preV17FontFamilies, "Roboto-Regular.ttf", reporter);
69 } else { 73 } else {
70 resourcesMissing = true; 74 resourcesMissing = true;
71 } 75 }
72 76
73 77
74 SkTDArray<FontFamily*> v17FontFamilies; 78 SkTDArray<FontFamily*> v17FontFamilies;
75 SkFontConfigParser::GetTestFontFamilies(v17FontFamilies, 79 SkFontConfigParser::GetCustomFontFamilies(v17FontFamilies,
80 SkString("/custom/font/path/"),
76 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(), 81 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(),
77 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str()); 82 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str());
78 83
79 if (v17FontFamilies.count() > 0) { 84 if (v17FontFamilies.count() > 0) {
80 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41); 85 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41);
81 REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 31); 86 REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 31);
82 87
83 DumpLoadedFonts(v17FontFamilies); 88 DumpLoadedFonts(v17FontFamilies);
84 ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter); 89 ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter);
85 } else { 90 } else {
86 resourcesMissing = true; 91 resourcesMissing = true;
87 } 92 }
88 93
89 94
90 SkTDArray<FontFamily*> v22FontFamilies; 95 SkTDArray<FontFamily*> v22FontFamilies;
91 SkFontConfigParser::GetTestFontFamilies(v22FontFamilies, 96 SkFontConfigParser::GetCustomFontFamilies(v22FontFamilies,
97 SkString("/custom/font/path/"),
92 GetResourcePath("android_fonts/v22/fonts.xml").c_str(), 98 GetResourcePath("android_fonts/v22/fonts.xml").c_str(),
93 NULL); 99 NULL);
94 100
95 if (v22FontFamilies.count() > 0) { 101 if (v22FontFamilies.count() > 0) {
96 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53); 102 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53);
97 REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42); 103 REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42);
98 104
99 DumpLoadedFonts(v22FontFamilies); 105 DumpLoadedFonts(v22FontFamilies);
100 ValidateLoadedFonts(v22FontFamilies, "Roboto-Thin.ttf", reporter); 106 ValidateLoadedFonts(v22FontFamilies, "Roboto-Thin.ttf", reporter);
101 } else { 107 } else {
102 resourcesMissing = true; 108 resourcesMissing = true;
103 } 109 }
104 110
105 if (resourcesMissing) { 111 if (resourcesMissing) {
106 SkDebugf("---- Resource files missing for FontConfigParser test\n"); 112 SkDebugf("---- Resource files missing for FontConfigParser test\n");
107 } 113 }
108 } 114 }
109 115
OLDNEW
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698