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

Unified Diff: tests/FontConfigParser.cpp

Issue 912053003: Fix append_fallback_font_families_for_locale. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Full test and address comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontConfigParser_android.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/FontConfigParser.cpp
diff --git a/tests/FontConfigParser.cpp b/tests/FontConfigParser.cpp
index dfc8093f2a0077526e9e7ed68596b6d3ddc434d9..dc1fac0547ba44b0eb09fac6dd7ee99b5aecf34b 100644
--- a/tests/FontConfigParser.cpp
+++ b/tests/FontConfigParser.cpp
@@ -22,6 +22,16 @@ int CountFallbacks(SkTDArray<FontFamily*> fontFamilies) {
return countOfFallbackFonts;
}
+//https://tools.ietf.org/html/rfc5234#appendix-B.1
+static bool isALPHA(int c) {
+ return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
+}
+
+//https://tools.ietf.org/html/rfc5234#appendix-B.1
+static bool isDIGIT(int c) {
+ return ('0' <= c && c <= '9');
+}
+
void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies, const char* firstExpectedFile,
skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5);
@@ -29,6 +39,15 @@ void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies, const char* firstE
REPORTER_ASSERT(reporter,
!strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(), firstExpectedFile));
REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont);
+
+ // Check that the languages are all sane.
+ for (int i = 0; i < fontFamilies.count(); ++i) {
+ const SkString& lang = fontFamilies[i]->fLanguage.getTag();
+ for (size_t j = 0; j < lang.size(); ++j) {
+ int c = lang[j];
+ REPORTER_ASSERT(reporter, isALPHA(c) || isDIGIT(c) || '-' == c);
+ }
+ }
}
void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) {
@@ -55,6 +74,7 @@ void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) {
SkDebugf(" file (%d) %s#%d\n", ffi.fWeight, ffi.fFileName.c_str(), ffi.fIndex);
}
}
+ SkDebugf("\n\n");
}
DEF_TEST(FontConfigParserAndroid, reporter) {
@@ -82,11 +102,12 @@ DEF_TEST(FontConfigParserAndroid, reporter) {
SkFontConfigParser::GetCustomFontFamilies(v17FontFamilies,
SkString("/custom/font/path/"),
GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(),
- GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str());
+ GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str(),
+ GetResourcePath("android_fonts/v17").c_str());
if (v17FontFamilies.count() > 0) {
- REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41);
- REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 31);
+ REPORTER_ASSERT(reporter, v17FontFamilies.count() == 56);
+ REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 46);
DumpLoadedFonts(v17FontFamilies);
ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter);
« 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