Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/FontMgrTest.cpp

Issue 23710072: fix fontconfig backend to only cache new fonts if their outName was unique (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_fontconfig.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 9
10 #include "SkCommandLineFlags.h" 10 #include "SkCommandLineFlags.h"
11 #include "SkFontMgr.h" 11 #include "SkFontMgr.h"
12 #include "SkTypeface.h" 12 #include "SkTypeface.h"
13 13
14 /*
15 * If the font backend is going to "alias" some font names to other fonts
16 * (e.g. sans -> Arial) then we want to at least get the same typeface back
17 * if we request the alias name multiple times.
18 */
19 static void test_badnames(skiatest::Reporter* reporter) {
20 const char* inName = "sans";
bungeman-skia 2013/09/18 20:31:02 Just for the sake of testing aliases on all platfo
21 SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inName, SkTypeface ::kNormal));
22
23 SkString name;
24 for (int i = 0; i < 10; ++i) {
25 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inName, SkTypef ace::kNormal));
26 #if 0
27 face->getFamilyName(&name);
28 printf("request %s, received %s, first id %x received %x\n",
29 inName, name.c_str(), first->uniqueID(), face->uniqueID());
30 #endif
31 REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID());
32 }
33 }
34
14 static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { 35 static void test_fontiter(skiatest::Reporter* reporter, bool verbose) {
15 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); 36 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
16 int count = fm->countFamilies(); 37 int count = fm->countFamilies();
17 38
18 for (int i = 0; i < count; ++i) { 39 for (int i = 0; i < count; ++i) {
19 SkString fname; 40 SkString fname;
20 fm->getFamilyName(i, &fname); 41 fm->getFamilyName(i, &fname);
21 REPORTER_ASSERT(reporter, fname.size() > 0); 42 REPORTER_ASSERT(reporter, fname.size() > 0);
22 43
23 SkAutoTUnref<SkFontStyleSet> fnset(fm->matchFamily(fname.c_str())); 44 SkAutoTUnref<SkFontStyleSet> fnset(fm->matchFamily(fname.c_str()));
(...skipping 18 matching lines...) Expand all
42 fs.weight(), fs.width(), fs.isItalic()); 63 fs.weight(), fs.width(), fs.isItalic());
43 } 64 }
44 } 65 }
45 } 66 }
46 } 67 }
47 68
48 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); 69 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests.");
49 70
50 static void TestFontMgr(skiatest::Reporter* reporter) { 71 static void TestFontMgr(skiatest::Reporter* reporter) {
51 test_fontiter(reporter, FLAGS_verboseFontMgr); 72 test_fontiter(reporter, FLAGS_verboseFontMgr);
73 test_badnames(reporter);
52 } 74 }
53 75
54 #include "TestClassDef.h" 76 #include "TestClassDef.h"
55 DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr) 77 DEFINE_TESTCLASS("FontMgr", FontMgrClass, TestFontMgr)
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_fontconfig.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698