OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Resources.h" | 8 #include "Resources.h" |
9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
10 #include "SkFontConfigParser_android.h" | 10 #include "SkFontMgr_android_parser.h" |
11 #include "Test.h" | 11 #include "Test.h" |
12 | 12 |
13 #include <cmath> | 13 #include <cmath> |
14 #include <cstdio> | 14 #include <cstdio> |
15 | 15 |
16 DECLARE_bool(verboseFontMgr); | 16 DECLARE_bool(verboseFontMgr); |
17 | 17 |
18 int CountFallbacks(SkTDArray<FontFamily*> fontFamilies) { | 18 int CountFallbacks(SkTDArray<FontFamily*> fontFamilies) { |
19 int countOfFallbackFonts = 0; | 19 int countOfFallbackFonts = 0; |
20 for (int i = 0; i < fontFamilies.count(); i++) { | 20 for (int i = 0; i < fontFamilies.count(); i++) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 SkFixed fix; | 134 SkFixed fix; |
135 REPORTER_ASSERT(reporter, !parse_fixed<27>("-17.1", &fix)); | 135 REPORTER_ASSERT(reporter, !parse_fixed<27>("-17.1", &fix)); |
136 REPORTER_ASSERT(reporter, !parse_fixed<16>("32768", &fix)); | 136 REPORTER_ASSERT(reporter, !parse_fixed<16>("32768", &fix)); |
137 REPORTER_ASSERT(reporter, !parse_fixed<16>("", &fix)); | 137 REPORTER_ASSERT(reporter, !parse_fixed<16>("", &fix)); |
138 REPORTER_ASSERT(reporter, !parse_fixed<16>(".", &fix)); | 138 REPORTER_ASSERT(reporter, !parse_fixed<16>(".", &fix)); |
139 REPORTER_ASSERT(reporter, !parse_fixed<16>("123.", &fix)); | 139 REPORTER_ASSERT(reporter, !parse_fixed<16>("123.", &fix)); |
140 REPORTER_ASSERT(reporter, !parse_fixed<16>("a", &fix)); | 140 REPORTER_ASSERT(reporter, !parse_fixed<16>("a", &fix)); |
141 REPORTER_ASSERT(reporter, !parse_fixed<16>(".123a", &fix)); | 141 REPORTER_ASSERT(reporter, !parse_fixed<16>(".123a", &fix)); |
142 } | 142 } |
143 | 143 |
144 DEF_TEST(FontConfigParserAndroid, reporter) { | 144 DEF_TEST(FontMgrAndroidParser, reporter) { |
145 test_parse_fixed(reporter); | 145 test_parse_fixed(reporter); |
146 | 146 |
147 bool resourcesMissing = false; | 147 bool resourcesMissing = false; |
148 | 148 |
149 SkTDArray<FontFamily*> preV17FontFamilies; | 149 SkTDArray<FontFamily*> preV17FontFamilies; |
150 SkFontConfigParser::GetCustomFontFamilies(preV17FontFamilies, | 150 SkFontMgr_Android_Parser::GetCustomFontFamilies(preV17FontFamilies, |
151 SkString("/custom/font/path/"), | 151 SkString("/custom/font/path/"), |
152 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(), | 152 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(), |
153 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str()); | 153 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str()); |
154 | 154 |
155 if (preV17FontFamilies.count() > 0) { | 155 if (preV17FontFamilies.count() > 0) { |
156 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14); | 156 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14); |
157 REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10); | 157 REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10); |
158 | 158 |
159 DumpLoadedFonts(preV17FontFamilies, "pre version 17"); | 159 DumpLoadedFonts(preV17FontFamilies, "pre version 17"); |
160 ValidateLoadedFonts(preV17FontFamilies, "Roboto-Regular.ttf", reporter); | 160 ValidateLoadedFonts(preV17FontFamilies, "Roboto-Regular.ttf", reporter); |
161 } else { | 161 } else { |
162 resourcesMissing = true; | 162 resourcesMissing = true; |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 SkTDArray<FontFamily*> v17FontFamilies; | 166 SkTDArray<FontFamily*> v17FontFamilies; |
167 SkFontConfigParser::GetCustomFontFamilies(v17FontFamilies, | 167 SkFontMgr_Android_Parser::GetCustomFontFamilies(v17FontFamilies, |
168 SkString("/custom/font/path/"), | 168 SkString("/custom/font/path/"), |
169 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(), | 169 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(), |
170 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str(), | 170 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str(), |
171 GetResourcePath("android_fonts/v17").c_str()); | 171 GetResourcePath("android_fonts/v17").c_str()); |
172 | 172 |
173 if (v17FontFamilies.count() > 0) { | 173 if (v17FontFamilies.count() > 0) { |
174 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 56); | 174 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 56); |
175 REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 46); | 175 REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 46); |
176 | 176 |
177 DumpLoadedFonts(v17FontFamilies, "version 17"); | 177 DumpLoadedFonts(v17FontFamilies, "version 17"); |
178 ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter); | 178 ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter); |
179 } else { | 179 } else { |
180 resourcesMissing = true; | 180 resourcesMissing = true; |
181 } | 181 } |
182 | 182 |
183 | 183 |
184 SkTDArray<FontFamily*> v22FontFamilies; | 184 SkTDArray<FontFamily*> v22FontFamilies; |
185 SkFontConfigParser::GetCustomFontFamilies(v22FontFamilies, | 185 SkFontMgr_Android_Parser::GetCustomFontFamilies(v22FontFamilies, |
186 SkString("/custom/font/path/"), | 186 SkString("/custom/font/path/"), |
187 GetResourcePath("android_fonts/v22/fonts.xml").c_str(), | 187 GetResourcePath("android_fonts/v22/fonts.xml").c_str(), |
188 NULL); | 188 NULL); |
189 | 189 |
190 if (v22FontFamilies.count() > 0) { | 190 if (v22FontFamilies.count() > 0) { |
191 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 54); | 191 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 54); |
192 REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42); | 192 REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42); |
193 | 193 |
194 DumpLoadedFonts(v22FontFamilies, "version 22"); | 194 DumpLoadedFonts(v22FontFamilies, "version 22"); |
195 ValidateLoadedFonts(v22FontFamilies, "Roboto-Thin.ttf", reporter); | 195 ValidateLoadedFonts(v22FontFamilies, "Roboto-Thin.ttf", reporter); |
196 } else { | 196 } else { |
197 resourcesMissing = true; | 197 resourcesMissing = true; |
198 } | 198 } |
199 | 199 |
200 if (resourcesMissing) { | 200 if (resourcesMissing) { |
201 SkDebugf("---- Resource files missing for FontConfigParser test\n"); | 201 SkDebugf("---- Resource files missing for FontConfigParser test\n"); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
OLD | NEW |