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

Side by Side Diff: tests/RefCntTest.cpp

Issue 1773943004: Add sk_ref_sp helper function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « include/core/SkRefCnt.h ('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 2012 Google Inc. 2 * Copyright 2012 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 "SkThreadUtils.h" 9 #include "SkThreadUtils.h"
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 sp.reset(rc); 378 sp.reset(rc);
379 // We have transfered our ownership over to sp 379 // We have transfered our ownership over to sp
380 REPORTER_ASSERT(r, rc->unique()); 380 REPORTER_ASSERT(r, rc->unique());
381 381
382 rc->ref(); // now "rc" is also an owner 382 rc->ref(); // now "rc" is also an owner
383 REPORTER_ASSERT(r, !rc->unique()); 383 REPORTER_ASSERT(r, !rc->unique());
384 384
385 sp.reset(rc); // this should transfer our ownership over to sp 385 sp.reset(rc); // this should transfer our ownership over to sp
386 REPORTER_ASSERT(r, rc->unique()); 386 REPORTER_ASSERT(r, rc->unique());
387 } 387 }
388
389 DEF_TEST(sk_sp_ref, r) {
390 SkRefCnt* rc = new SkRefCnt;
391 REPORTER_ASSERT(r, rc->unique());
392
393 {
394 sk_sp<SkRefCnt> sp = sk_ref_sp(rc);
395 REPORTER_ASSERT(r, !rc->unique());
396 }
397
398 REPORTER_ASSERT(r, rc->unique());
399 rc->unref();
400 }
OLDNEW
« no previous file with comments | « include/core/SkRefCnt.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698