aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2017-11-13 11:14:36 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-13 17:00:31 +0000
commitf1729a79379d65d7d373594e4f0d713d99beb1f2 (patch)
tree4e04e21c85b9cadf93dca3cc9e48394066050459 /tests
parentf44754a42b9d5ced2e6f075b4bd058a498488d3a (diff)
Extract Android FontMgr part of Typeface test.
Part of the Typeface test is Android specific and tests that the Android legacyMakeTypeface returns nullptr when called with a non-null family name and there is no match. A new FontMgrAndroidLegacyMakeTypeface test is introduced to test this and also properly test creating one with SkFontMgr_Android_CustomFonts. Change-Id: Iceb8b9b5490f5eeeaeac30a68daf2c4daac53c86 Reviewed-on: https://skia-review.googlesource.com/70660 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/FontMgrAndroidParserTest.cpp18
-rw-r--r--tests/TypefaceTest.cpp6
2 files changed, 18 insertions, 6 deletions
diff --git a/tests/FontMgrAndroidParserTest.cpp b/tests/FontMgrAndroidParserTest.cpp
index b5346ef5b6..cd10d04dc6 100644
--- a/tests/FontMgrAndroidParserTest.cpp
+++ b/tests/FontMgrAndroidParserTest.cpp
@@ -8,7 +8,9 @@
#include "Resources.h"
#include "SkCommandLineFlags.h"
#include "SkFixed.h"
+#include "SkFontMgr_android.h"
#include "SkFontMgr_android_parser.h"
+#include "SkTypeface.h"
#include "Test.h"
#include <cmath>
@@ -220,3 +222,19 @@ DEF_TEST(FontMgrAndroidParser, reporter) {
SkDebugf("---- Resource files missing for FontConfigParser test\n");
}
}
+
+DEF_TEST(FontMgrAndroidLegacyMakeTypeface, reporter) {
+ SkString basePath = GetResourcePath("fonts/");
+ SkString fontsXml = GetResourcePath("fonts/fonts.xml");
+
+ SkFontMgr_Android_CustomFonts custom;
+ custom.fSystemFontUse = SkFontMgr_Android_CustomFonts::kOnlyCustom;
+ custom.fBasePath = basePath.c_str();
+ custom.fFontsXml = fontsXml.c_str();
+ custom.fFallbackFontsXml = nullptr;
+ custom.fIsolated = false;
+
+ sk_sp<SkFontMgr> fm(SkFontMgr_New_Android(&custom));
+ sk_sp<SkTypeface> t(fm->legacyMakeTypeface("non-existent-font", SkFontStyle()));
+ REPORTER_ASSERT(reporter, nullptr == t);
+}
diff --git a/tests/TypefaceTest.cpp b/tests/TypefaceTest.cpp
index 4ab8c5eec6..591b437ca5 100644
--- a/tests/TypefaceTest.cpp
+++ b/tests/TypefaceTest.cpp
@@ -184,12 +184,6 @@ DEF_TEST(Typeface, reporter) {
REPORTER_ASSERT(reporter, SkTypeface::Equal(nullptr, t2.get()));
REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), nullptr));
REPORTER_ASSERT(reporter, SkTypeface::Equal(t2.get(), nullptr));
-
- // Disabled temporarily. TODO(mtklein): test Android SkFontMgr directly?
-#if 0 && defined(SK_BUILD_FOR_ANDROID)
- sk_sp<SkTypeface> t3(SkTypeface::MakeFromName("non-existent-font", SkFontStyle()));
- REPORTER_ASSERT(reporter, nullptr == t3);
-#endif
}
namespace {