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

Side by Side Diff: tests/TypefaceTest.cpp

Issue 1974783002: Revert of Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
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 "SkRefCnt.h" 8 #include "SkRefCnt.h"
9 #include "SkTypeface.h" 9 #include "SkTypeface.h"
10 #include "SkTypefaceCache.h" 10 #include "SkTypefaceCache.h"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 DEF_TEST(Typeface, reporter) { 13 DEF_TEST(Typeface, reporter) {
14 14
15 sk_sp<SkTypeface> t1(SkTypeface::MakeFromName(nullptr, SkTypeface::kNormal)) ; 15 SkAutoTUnref<SkTypeface> t1(SkTypeface::CreateFromName(nullptr, SkTypeface:: kNormal));
16 sk_sp<SkTypeface> t2(SkTypeface::MakeDefault(SkTypeface::kNormal)); 16 SkAutoTUnref<SkTypeface> t2(SkTypeface::RefDefault(SkTypeface::kNormal));
17 17
18 REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), t2.get())); 18 REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), t2.get()));
19 REPORTER_ASSERT(reporter, SkTypeface::Equal(0, t1.get())); 19 REPORTER_ASSERT(reporter, SkTypeface::Equal(0, t1.get()));
20 REPORTER_ASSERT(reporter, SkTypeface::Equal(0, t2.get())); 20 REPORTER_ASSERT(reporter, SkTypeface::Equal(0, t2.get()));
21 REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), 0)); 21 REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), 0));
22 REPORTER_ASSERT(reporter, SkTypeface::Equal(t2.get(), 0)); 22 REPORTER_ASSERT(reporter, SkTypeface::Equal(t2.get(), 0));
23 23
24 #ifdef SK_BUILD_FOR_ANDROID 24 #ifdef SK_BUILD_FOR_ANDROID
25 sk_sp<SkTypeface> t3(SkTypeface::MakeFromName("non-existent-font", SkTypefac e::kNormal)); 25 SkAutoTUnref<SkTypeface> t3(SkTypeface::CreateFromName("non-existent-font", SkTypeface::kNormal));
26 REPORTER_ASSERT(reporter, nullptr == t3); 26 REPORTER_ASSERT(reporter, nullptr == t3.get());
27 #endif 27 #endif
28 } 28 }
29 29
30 namespace { 30 namespace {
31 31
32 class SkEmptyTypeface : public SkTypeface { 32 class SkEmptyTypeface : public SkTypeface {
33 public: 33 public:
34 static sk_sp<SkTypeface> Create(SkFontID id) { return sk_sp<SkTypeface>(new SkEmptyTypeface(id)); } 34 static sk_sp<SkTypeface> Create(SkFontID id) { return sk_sp<SkTypeface>(new SkEmptyTypeface(id)); }
35 protected: 35 protected:
36 SkEmptyTypeface(SkFontID id) : SkTypeface(SkFontStyle(), id, true) { } 36 SkEmptyTypeface(SkFontID id) : SkTypeface(SkFontStyle(), id, true) { }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 REPORTER_ASSERT(reporter, count(reporter, cache) == 2); 88 REPORTER_ASSERT(reporter, count(reporter, cache) == 2);
89 cache.purgeAll(); 89 cache.purgeAll();
90 REPORTER_ASSERT(reporter, count(reporter, cache) == 2); 90 REPORTER_ASSERT(reporter, count(reporter, cache) == 2);
91 } 91 }
92 REPORTER_ASSERT(reporter, count(reporter, cache) == 2); 92 REPORTER_ASSERT(reporter, count(reporter, cache) == 2);
93 cache.purgeAll(); 93 cache.purgeAll();
94 REPORTER_ASSERT(reporter, count(reporter, cache) == 1); 94 REPORTER_ASSERT(reporter, count(reporter, cache) == 1);
95 } 95 }
96 REPORTER_ASSERT(reporter, t1->unique()); 96 REPORTER_ASSERT(reporter, t1->unique());
97 } 97 }
OLDNEW
« src/ports/SkFontMgr_android.cpp ('K') | « tests/TextBlobTest.cpp ('k') | tools/Resources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698