aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FontMgrTest.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-19 18:06:03 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-19 18:06:03 +0000
commitc1a81ebec52bc5dff8c9461570e1212afe09506f (patch)
treecfd6e0bd84ce9ae0faa52b3c308c2ca0ca9ad21f /tests/FontMgrTest.cpp
parent1da3a80d46f10b06d7fa4e90a355547f1572c65f (diff)
expand alias fontname test
BUG= R=bungeman@google.com Review URL: https://codereview.chromium.org/24198004 git-svn-id: http://skia.googlecode.com/svn/trunk@11393 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/FontMgrTest.cpp')
-rw-r--r--tests/FontMgrTest.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/tests/FontMgrTest.cpp b/tests/FontMgrTest.cpp
index 2a0c44ac2d..cffc22fa7d 100644
--- a/tests/FontMgrTest.cpp
+++ b/tests/FontMgrTest.cpp
@@ -11,28 +11,35 @@
#include "SkFontMgr.h"
#include "SkTypeface.h"
-#if !defined(SK_BUILD_FOR_ANDROID)
/*
* If the font backend is going to "alias" some font names to other fonts
* (e.g. sans -> Arial) then we want to at least get the same typeface back
* if we request the alias name multiple times.
*/
-static void test_badnames(skiatest::Reporter* reporter) {
- const char* inName = "sans";
- SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inName, SkTypeface::kNormal));
-
- SkString name;
- for (int i = 0; i < 10; ++i) {
- SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inName, SkTypeface::kNormal));
-#if 0
- face->getFamilyName(&name);
- printf("request %s, received %s, first id %x received %x\n",
- inName, name.c_str(), first->uniqueID(), face->uniqueID());
-#endif
- REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID());
+static void test_alias_names(skiatest::Reporter* reporter) {
+ const char* inNames[] = {
+ "sans", "sans-serif", "serif", "monospace", "times", "helvetica"
+ };
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(inNames); ++i) {
+ SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inNames[i],
+ SkTypeface::kNormal));
+ if (NULL == first.get()) {
+ continue;
+ }
+ for (int j = 0; j < 10; ++j) {
+ SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inNames[i],
+ SkTypeface::kNormal));
+ #if 0
+ SkString name;
+ face->getFamilyName(&name);
+ printf("request %s, received %s, first id %x received %x\n",
+ inNames[i], name.c_str(), first->uniqueID(), face->uniqueID());
+ #endif
+ REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID());
+ }
}
}
-#endif
static void test_fontiter(skiatest::Reporter* reporter, bool verbose) {
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
@@ -72,10 +79,7 @@ DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests.");
static void TestFontMgr(skiatest::Reporter* reporter) {
test_fontiter(reporter, FLAGS_verboseFontMgr);
-// The badnames test fails on Android because "sans" is not a valid alias
-#if !defined(SK_BUILD_FOR_ANDROID)
- test_badnames(reporter);
-#endif
+ test_alias_names(reporter);
}
#include "TestClassDef.h"