reed@google.com | 83165a5 | 2013-04-11 18:31:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 "Test.h" |
| 9 | |
| 10 | #include "SkCommandLineFlags.h" |
| 11 | #include "SkFontMgr.h" |
| 12 | #include "SkTypeface.h" |
| 13 | |
| 14 | static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { |
| 15 | SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 16 | int count = fm->countFamilies(); |
| 17 | |
| 18 | for (int i = 0; i < count; ++i) { |
| 19 | SkString fname; |
| 20 | fm->getFamilyName(i, &fname); |
| 21 | REPORTER_ASSERT(reporter, fname.size() > 0); |
| 22 | |
| 23 | SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i)); |
| 24 | |
| 25 | if (verbose) { |
| 26 | SkDebugf("[%2d] %s\n", i, fname.c_str()); |
| 27 | } |
| 28 | |
| 29 | for (int j = 0; j < set->count(); ++j) { |
| 30 | SkString sname; |
| 31 | SkFontStyle fs; |
| 32 | set->getStyle(j, &fs, &sname); |
| 33 | REPORTER_ASSERT(reporter, sname.size() > 0); |
| 34 | |
| 35 | SkAutoTUnref<SkTypeface> face(set->createTypeface(j)); |
reed@google.com | c1ccda3 | 2013-04-19 14:28:54 +0000 | [diff] [blame^] | 36 | // REPORTER_ASSERT(reporter, face.get()); |
reed@google.com | 83165a5 | 2013-04-11 18:31:25 +0000 | [diff] [blame] | 37 | |
| 38 | if (verbose) { |
| 39 | SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(), |
| 40 | fs.weight(), fs.width(), fs.isItalic()); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
reed@google.com | 66c9f99 | 2013-04-11 19:04:34 +0000 | [diff] [blame] | 46 | DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); |
reed@google.com | 83165a5 | 2013-04-11 18:31:25 +0000 | [diff] [blame] | 47 | |
| 48 | static void TestFontMgr(skiatest::Reporter* reporter) { |
| 49 | test_fontiter(reporter, FLAGS_verboseFontMgr); |
| 50 | } |
| 51 | |
| 52 | #include "TestClassDef.h" |
| 53 | DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr) |