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

Side by Side Diff: tests/FontConfigParser.cpp

Issue 439813002: Test and generalize font configuration parser (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix nit and install Android fonts.xml update 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 unified diff | Download patch
« no previous file with comments | « src/ports/SkFontConfigParser_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
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Resources.h"
9 #include "SkFontConfigParser_android.h"
10 #include "Test.h"
11
12 void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies,
13 skiatest::Reporter* reporter) {
14 REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5);
15 REPORTER_ASSERT(reporter, !strcmp(fontFamilies[0]->fNames[0].c_str(), "sans- serif"));
16 REPORTER_ASSERT(reporter,
17 !strcmp(fontFamilies[0]->fFontFiles[0].fFileName.c_str(),
18 "Roboto-Regular.ttf"));
19 REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont);
20
21 }
22
23 void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) {
24 #if SK_DEBUG_FONTS
25 for (int i = 0; i < fontFamilies.count(); ++i) {
26 SkDebugf("Family %d:\n", i);
27 for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) {
28 SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str());
29 }
30 }
31 #endif // SK_DEBUG_FONTS
32 }
33
34 DEF_TEST(FontConfigParserAndroid, reporter) {
35
36 SkTDArray<FontFamily*> preV17FontFamilies;
37 SkFontConfigParser::GetTestFontFamilies(preV17FontFamilies,
38 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(),
djsollen 2014/08/05 15:52:00 so these tests fail if you don't provide a resourc
39 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str());
40
41 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14);
42
43 DumpLoadedFonts(preV17FontFamilies);
44 ValidateLoadedFonts(preV17FontFamilies, reporter);
45
46 SkTDArray<FontFamily*> v17FontFamilies;
47 SkFontConfigParser::GetTestFontFamilies(v17FontFamilies,
48 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(),
49 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str());
50
51
52 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41);
53
54 DumpLoadedFonts(v17FontFamilies);
55 ValidateLoadedFonts(v17FontFamilies, reporter);
56
57 SkTDArray<FontFamily*> v22FontFamilies;
58 SkFontConfigParser::GetTestFontFamilies(v22FontFamilies,
59 GetResourcePath("android_fonts/v22/fonts.xml").c_str(),
60 NULL);
61
62 //REPORTER_ASSERT(reporter, v22FontFamilies.count() > 0);
63 if (v22FontFamilies.count() > 0) {
64 REPORTER_ASSERT(reporter, v22FontFamilies[0]->fNames.count() > 0);
65 }
66
67 //ValidateLoadedFonts(v22FontFamilies, reporter);
68 }
69
OLDNEW
« 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