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

Side by Side Diff: tests/CachedDataTest.cpp

Issue 1610823002: Consolidate SK_CRASH and sk_throw into SK_ABORT (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows fix Created 4 years, 11 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
« no previous file with comments | « src/ports/SkTypeface_win_dw.cpp ('k') | tests/PathOpsCubicLineIntersectionIdeas.cpp » ('j') | 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 2014 Google Inc. 2 * Copyright 2014 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 "SkCachedData.h" 8 #include "SkCachedData.h"
9 #include "SkDiscardableMemoryPool.h" 9 #include "SkDiscardableMemoryPool.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 12 matching lines...) Expand all
23 int refcnt, CachedState cacheState, LockedState lockedSta te) { 23 int refcnt, CachedState cacheState, LockedState lockedSta te) {
24 REPORTER_ASSERT(reporter, data->testing_only_getRefCnt() == refcnt); 24 REPORTER_ASSERT(reporter, data->testing_only_getRefCnt() == refcnt);
25 REPORTER_ASSERT(reporter, data->testing_only_isInCache() == (kInCache == cac heState)); 25 REPORTER_ASSERT(reporter, data->testing_only_isInCache() == (kInCache == cac heState));
26 REPORTER_ASSERT(reporter, data->testing_only_isLocked() == (lockedState == k Locked)); 26 REPORTER_ASSERT(reporter, data->testing_only_isLocked() == (lockedState == k Locked));
27 } 27 }
28 28
29 static SkCachedData* make_data(size_t size, SkDiscardableMemoryPool* pool) { 29 static SkCachedData* make_data(size_t size, SkDiscardableMemoryPool* pool) {
30 if (pool) { 30 if (pool) {
31 SkDiscardableMemory* dm = pool->create(size); 31 SkDiscardableMemory* dm = pool->create(size);
32 // the pool "can" return null, but it shouldn't in these controlled cond itions 32 // the pool "can" return null, but it shouldn't in these controlled cond itions
33 SK_ALWAYSBREAK(dm); 33 SkASSERT_RELEASE(dm);
34 return new SkCachedData(size, dm); 34 return new SkCachedData(size, dm);
35 } else { 35 } else {
36 return new SkCachedData(sk_malloc_throw(size), size); 36 return new SkCachedData(sk_malloc_throw(size), size);
37 } 37 }
38 } 38 }
39 39
40 // returns with the data locked by client and cache 40 // returns with the data locked by client and cache
41 static SkCachedData* test_locking(skiatest::Reporter* reporter, 41 static SkCachedData* test_locking(skiatest::Reporter* reporter,
42 size_t size, SkDiscardableMemoryPool* pool) { 42 size_t size, SkDiscardableMemoryPool* pool) {
43 SkCachedData* data = make_data(size, pool); 43 SkCachedData* data = make_data(size, pool);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // test with cache as last owner 87 // test with cache as last owner
88 data = test_locking(reporter, size, useDiscardable ? pool.get() : nullpt r); 88 data = test_locking(reporter, size, useDiscardable ? pool.get() : nullpt r);
89 check_data(reporter, data, 2, kInCache, kLocked); 89 check_data(reporter, data, 2, kInCache, kLocked);
90 data->unref(); 90 data->unref();
91 check_data(reporter, data, 1, kInCache, kUnlocked); 91 check_data(reporter, data, 1, kInCache, kUnlocked);
92 data->detachFromCacheAndUnref(); 92 data->detachFromCacheAndUnref();
93 } 93 }
94 } 94 }
95 95
OLDNEW
« no previous file with comments | « src/ports/SkTypeface_win_dw.cpp ('k') | tests/PathOpsCubicLineIntersectionIdeas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698