Chromium Code Reviews| 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 /* | |
| 15 * 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 * if we request the alias name multiple times. | |
| 18 */ | |
| 19 static void test_badnames(skiatest::Reporter* reporter) { | |
| 20 const char* inName = "sans"; | |
|
bungeman-skia
2013/09/18 20:31:02
Just for the sake of testing aliases on all platfo
| |
| 21 SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inName, SkTypeface ::kNormal)); | |
| 22 | |
| 23 SkString name; | |
| 24 for (int i = 0; i < 10; ++i) { | |
| 25 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inName, SkTypef ace::kNormal)); | |
| 26 #if 0 | |
| 27 face->getFamilyName(&name); | |
| 28 printf("request %s, received %s, first id %x received %x\n", | |
| 29 inName, name.c_str(), first->uniqueID(), face->uniqueID()); | |
| 30 #endif | |
| 31 REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID()); | |
| 32 } | |
| 33 } | |
| 34 | |
| 14 static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { | 35 static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { |
| 15 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 36 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 16 int count = fm->countFamilies(); | 37 int count = fm->countFamilies(); |
| 17 | 38 |
| 18 for (int i = 0; i < count; ++i) { | 39 for (int i = 0; i < count; ++i) { |
| 19 SkString fname; | 40 SkString fname; |
| 20 fm->getFamilyName(i, &fname); | 41 fm->getFamilyName(i, &fname); |
| 21 REPORTER_ASSERT(reporter, fname.size() > 0); | 42 REPORTER_ASSERT(reporter, fname.size() > 0); |
| 22 | 43 |
| 23 SkAutoTUnref<SkFontStyleSet> fnset(fm->matchFamily(fname.c_str())); | 44 SkAutoTUnref<SkFontStyleSet> fnset(fm->matchFamily(fname.c_str())); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 42 fs.weight(), fs.width(), fs.isItalic()); | 63 fs.weight(), fs.width(), fs.isItalic()); |
| 43 } | 64 } |
| 44 } | 65 } |
| 45 } | 66 } |
| 46 } | 67 } |
| 47 | 68 |
| 48 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); | 69 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); |
| 49 | 70 |
| 50 static void TestFontMgr(skiatest::Reporter* reporter) { | 71 static void TestFontMgr(skiatest::Reporter* reporter) { |
| 51 test_fontiter(reporter, FLAGS_verboseFontMgr); | 72 test_fontiter(reporter, FLAGS_verboseFontMgr); |
| 73 test_badnames(reporter); | |
| 52 } | 74 } |
| 53 | 75 |
| 54 #include "TestClassDef.h" | 76 #include "TestClassDef.h" |
| 55 DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr) | 77 DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr) |
| OLD | NEW |