OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |