diff options
-rw-r--r-- | gyp/tests.gyp | 1 | ||||
-rw-r--r-- | tests/FontMgrTest.cpp | 53 |
2 files changed, 54 insertions, 0 deletions
diff --git a/gyp/tests.gyp b/gyp/tests.gyp index 9a05ed486d..683255eca7 100644 --- a/gyp/tests.gyp +++ b/gyp/tests.gyp @@ -50,6 +50,7 @@ '../tests/FlateTest.cpp', '../tests/FontHostStreamTest.cpp', '../tests/FontHostTest.cpp', + '../tests/FontMgrTest.cpp', '../tests/FontNamesTest.cpp', '../tests/GeometryTest.cpp', '../tests/GLInterfaceValidation.cpp', diff --git a/tests/FontMgrTest.cpp b/tests/FontMgrTest.cpp new file mode 100644 index 0000000000..556f916a6d --- /dev/null +++ b/tests/FontMgrTest.cpp @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "Test.h" + +#include "SkCommandLineFlags.h" +#include "SkFontMgr.h" +#include "SkTypeface.h" + +static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { + SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); + int count = fm->countFamilies(); + + for (int i = 0; i < count; ++i) { + SkString fname; + fm->getFamilyName(i, &fname); + REPORTER_ASSERT(reporter, fname.size() > 0); + + SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i)); + + if (verbose) { + SkDebugf("[%2d] %s\n", i, fname.c_str()); + } + + for (int j = 0; j < set->count(); ++j) { + SkString sname; + SkFontStyle fs; + set->getStyle(j, &fs, &sname); + REPORTER_ASSERT(reporter, sname.size() > 0); + + SkAutoTUnref<SkTypeface> face(set->createTypeface(j)); + REPORTER_ASSERT(reporter, face.get()); + + if (verbose) { + SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(), + fs.weight(), fs.width(), fs.isItalic()); + } + } + } +} + +DEFINE_bool2(verboseFontMgr, vfm, false, "run verbose fontmgr tests."); + +static void TestFontMgr(skiatest::Reporter* reporter) { + test_fontiter(reporter, FLAGS_verboseFontMgr); +} + +#include "TestClassDef.h" +DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr) |