OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "Test.h" | 8 #include "Test.h" |
9 | 9 |
10 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
11 #include "SkFontMgr.h" | 11 #include "SkFontMgr.h" |
12 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
13 | 13 |
| 14 #if !defined(SK_BUILD_FOR_ANDROID) |
14 /* | 15 /* |
15 * If the font backend is going to "alias" some font names to other fonts | 16 * If the font backend is going to "alias" some font names to other fonts |
16 * (e.g. sans -> Arial) then we want to at least get the same typeface back | 17 * (e.g. sans -> Arial) then we want to at least get the same typeface back |
17 * if we request the alias name multiple times. | 18 * if we request the alias name multiple times. |
18 */ | 19 */ |
19 static void test_badnames(skiatest::Reporter* reporter) { | 20 static void test_badnames(skiatest::Reporter* reporter) { |
20 const char* inName = "sans"; | 21 const char* inName = "sans"; |
21 SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inName, SkTypeface
::kNormal)); | 22 SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inName, SkTypeface
::kNormal)); |
22 | 23 |
23 SkString name; | 24 SkString name; |
24 for (int i = 0; i < 10; ++i) { | 25 for (int i = 0; i < 10; ++i) { |
25 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inName, SkTypef
ace::kNormal)); | 26 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inName, SkTypef
ace::kNormal)); |
26 #if 0 | 27 #if 0 |
27 face->getFamilyName(&name); | 28 face->getFamilyName(&name); |
28 printf("request %s, received %s, first id %x received %x\n", | 29 printf("request %s, received %s, first id %x received %x\n", |
29 inName, name.c_str(), first->uniqueID(), face->uniqueID()); | 30 inName, name.c_str(), first->uniqueID(), face->uniqueID()); |
30 #endif | 31 #endif |
31 REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID()); | 32 REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID()); |
32 } | 33 } |
33 } | 34 } |
| 35 #endif |
34 | 36 |
35 static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { | 37 static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { |
36 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 38 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
37 int count = fm->countFamilies(); | 39 int count = fm->countFamilies(); |
38 | 40 |
39 for (int i = 0; i < count; ++i) { | 41 for (int i = 0; i < count; ++i) { |
40 SkString fname; | 42 SkString fname; |
41 fm->getFamilyName(i, &fname); | 43 fm->getFamilyName(i, &fname); |
42 REPORTER_ASSERT(reporter, fname.size() > 0); | 44 REPORTER_ASSERT(reporter, fname.size() > 0); |
43 | 45 |
(...skipping 27 matching lines...) Expand all Loading... |
71 static void TestFontMgr(skiatest::Reporter* reporter) { | 73 static void TestFontMgr(skiatest::Reporter* reporter) { |
72 test_fontiter(reporter, FLAGS_verboseFontMgr); | 74 test_fontiter(reporter, FLAGS_verboseFontMgr); |
73 // The badnames test fails on Android because "sans" is not a valid alias | 75 // The badnames test fails on Android because "sans" is not a valid alias |
74 #if !defined(SK_BUILD_FOR_ANDROID) | 76 #if !defined(SK_BUILD_FOR_ANDROID) |
75 test_badnames(reporter); | 77 test_badnames(reporter); |
76 #endif | 78 #endif |
77 } | 79 } |
78 | 80 |
79 #include "TestClassDef.h" | 81 #include "TestClassDef.h" |
80 DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr) | 82 DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr) |
OLD | NEW |