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

Unified Diff: tests/FontConfigParser.cpp

Issue 439813002: Test and generalize font configuration parser (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Safety tweak to attribute comparisons 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 side-by-side diff with in-line comments
Download patch
Index: tests/FontConfigParser.cpp
diff --git a/tests/FontConfigParser.cpp b/tests/FontConfigParser.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..df2a7cdadcd662ab7181e091f24701d11967464b
--- /dev/null
+++ b/tests/FontConfigParser.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkFontConfigParser_android.h"
+#include "Test.h"
+
+void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies,
+ skiatest::Reporter* reporter) {
+SkDebugf(" .. validating:");
djsollen 2014/08/04 18:13:36 remove
tomhudson 2014/08/04 21:03:57 Done.
+ REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5);
+ REPORTER_ASSERT(reporter, !strcmp(fontFamilies[0]->fNames[0].c_str(), "sans-serif"));
+ REPORTER_ASSERT(reporter,
+ !strcmp(fontFamilies[0]->fFontFiles[0].fFileName.c_str(),
+ "Roboto-Regular.ttf"));
+ REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont);
+
+}
+
+void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) {
djsollen 2014/08/04 18:13:35 if you want to keep this function around put it be
tomhudson 2014/08/04 21:03:57 Done. Reused SK_DEBUG_FONTS instead of creating a
+SkDebugf(" .. dumping:");
+ for (int i = 0; i < fontFamilies.count(); ++i) {
+ SkDebugf("Family %d:\n", i);
+ for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) {
+ SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str());
+ }
+ }
+}
+
+DEF_TEST(FontConfigParserAndroid, reporter) {
+
+ SkTDArray<FontFamily*> preV17FontFamilies;
+ SkFontConfigParser::GetTestFontFamilies(preV17FontFamilies,
+ "/data/local/tmp/resources/android_fonts/pre_v17/system_fonts.xml",
djsollen 2014/08/04 18:13:36 I think there is some kind of GetResourceDir funct
tomhudson 2014/08/04 21:03:57 Done, after much argumentation. It is now necessa
+ "/data/local/tmp/resources/android_fonts/pre_v17/fallback_fonts.xml");
+
+ REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14);
+
+ DumpLoadedFonts(preV17FontFamilies);
+ ValidateLoadedFonts(preV17FontFamilies, reporter);
+
+ SkTDArray<FontFamily*> v17FontFamilies;
+ SkFontConfigParser::GetTestFontFamilies(v17FontFamilies,
+ "/data/local/tmp/resources/android_fonts/v17/system_fonts.xml",
+ "/data/local/tmp/resources/android_fonts/v17/fallback_fonts.xml");
+
+
+ REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41);
+
+ DumpLoadedFonts(v17FontFamilies);
+ ValidateLoadedFonts(v17FontFamilies, reporter);
+
+ SkTDArray<FontFamily*> v22FontFamilies;
+ SkFontConfigParser::GetTestFontFamilies(v22FontFamilies,
+ "/data/local/tmp/resources/android_fonts/v22/fonts.xml",
+ NULL);
+
+ //REPORTER_ASSERT(reporter, v22FontFamilies.count() > 0);
+ if (v22FontFamilies.count() > 0) {
+ REPORTER_ASSERT(reporter, v22FontFamilies[0]->fNames.count() > 0);
+ }
+
+ //ValidateLoadedFonts(v22FontFamilies, reporter);
+}
+
« src/ports/SkFontConfigParser_android.cpp ('K') | « src/ports/SkFontConfigParser_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698