blob: d1880999bd5b3eab0e9b59bac6a80bd57d9a454f [file] [log] [blame]
reed@google.com83165a52013-04-11 18:31:25 +00001/*
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
14static 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.comc1ccda32013-04-19 14:28:54 +000036// REPORTER_ASSERT(reporter, face.get());
reed@google.com83165a52013-04-11 18:31:25 +000037
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.com66c9f992013-04-11 19:04:34 +000046DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests.");
reed@google.com83165a52013-04-11 18:31:25 +000047
48static void TestFontMgr(skiatest::Reporter* reporter) {
49 test_fontiter(reporter, FLAGS_verboseFontMgr);
50}
51
52#include "TestClassDef.h"
53DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr)