aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar tomhudson <tomhudson@chromium.org>2014-08-13 07:53:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-13 07:53:49 -0700
commit2ed49a492bd7cfcfe1380476d270ce0afe0c8305 (patch)
treef89f5c1fbc5d913bea1a5f5b50e5156064b03286 /tests
parentc30aaa0e40a2957b847910f80665616e0d103d50 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/FontConfigParser.cpp14
1 files changed, 13 insertions, 1 deletions
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<FontFamily*> fontFamilies) {
+ int countOfFallbackFonts = 0;
+ for (int i = 0; i < fontFamilies.count(); i++) {
+ if (fontFamilies[i]->fIsFallbackFont) {
+ countOfFallbackFonts++;
+ }
+ }
+ return countOfFallbackFonts;
+}
+
void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies,
skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5);
@@ -17,7 +27,6 @@ void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies,
!strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(),
"Roboto-Regular.ttf"));
REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont);
-
}
void DumpLoadedFonts(SkTDArray<FontFamily*> 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);