From 2ed49a492bd7cfcfe1380476d270ce0afe0c8305 Mon Sep 17 00:00:00 2001 From: tomhudson Date: Wed, 13 Aug 2014 07:53:48 -0700 Subject: Mark fallback fonts in new Android font config parser The new Android fonts.xml format doesn't explicitly tag fallback fonts, or separate them from system fonts by putting them in a separate file. We're assuming that any nameless font is a fallback font. Adds a unit test to track that we see as many fallback fonts as expected when parsing a file. BUG=chromium:400801 R=bungeman@google.com, djsollen@google.com, tomhudson@google.com Author: tomhudson@chromium.org Review URL: https://codereview.chromium.org/468893002 --- tests/FontConfigParser.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/FontConfigParser.cpp b/tests/FontConfigParser.cpp index 8ca7556df1..86b2b1db90 100644 --- a/tests/FontConfigParser.cpp +++ b/tests/FontConfigParser.cpp @@ -9,6 +9,16 @@ #include "SkFontConfigParser_android.h" #include "Test.h" +int CountFallbacks(SkTDArray fontFamilies) { + int countOfFallbackFonts = 0; + for (int i = 0; i < fontFamilies.count(); i++) { + if (fontFamilies[i]->fIsFallbackFont) { + countOfFallbackFonts++; + } + } + return countOfFallbackFonts; +} + void ValidateLoadedFonts(SkTDArray fontFamilies, skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5); @@ -17,7 +27,6 @@ void ValidateLoadedFonts(SkTDArray fontFamilies, !strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(), "Roboto-Regular.ttf")); REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont); - } void DumpLoadedFonts(SkTDArray fontFamilies) { @@ -59,6 +68,7 @@ DEF_TEST(FontConfigParserAndroid, reporter) { if (preV17FontFamilies.count() > 0) { REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14); + REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10); DumpLoadedFonts(preV17FontFamilies); ValidateLoadedFonts(preV17FontFamilies, reporter); @@ -74,6 +84,7 @@ DEF_TEST(FontConfigParserAndroid, reporter) { if (v17FontFamilies.count() > 0) { REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41); + REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 31); DumpLoadedFonts(v17FontFamilies); ValidateLoadedFonts(v17FontFamilies, reporter); @@ -89,6 +100,7 @@ DEF_TEST(FontConfigParserAndroid, reporter) { if (v22FontFamilies.count() > 0) { REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53); + REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42); DumpLoadedFonts(v22FontFamilies); ValidateLoadedFonts(v22FontFamilies, reporter); -- cgit v1.2.3