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

Unified Diff: skia/ext/refptr_unittest.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « skia/ext/platform_canvas_unittest.cc ('k') | skia/ext/skia_trace_shim.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/refptr_unittest.cc
diff --git a/skia/ext/refptr_unittest.cc b/skia/ext/refptr_unittest.cc
index 1d63ed1b1e929b1041783a24c6f3fd32a854b968..bf54b03ac54aeeb41342da5eacef180e4c765e32 100644
--- a/skia/ext/refptr_unittest.cc
+++ b/skia/ext/refptr_unittest.cc
@@ -11,13 +11,13 @@ namespace {
TEST(RefPtrTest, ReferenceCounting) {
SkRefCnt* ref = new SkRefCnt();
- EXPECT_EQ(1, ref->getRefCnt());
+ EXPECT_TRUE(ref->unique());
{
// Adopt the reference from the caller on creation.
RefPtr<SkRefCnt> refptr1 = AdoptRef(ref);
- EXPECT_EQ(1, ref->getRefCnt());
- EXPECT_EQ(1, refptr1->getRefCnt());
+ EXPECT_TRUE(ref->unique());
+ EXPECT_TRUE(refptr1->unique());
EXPECT_EQ(ref, &*refptr1);
EXPECT_EQ(ref, refptr1.get());
@@ -25,100 +25,100 @@ TEST(RefPtrTest, ReferenceCounting) {
{
// Take a second reference for the second instance.
RefPtr<SkRefCnt> refptr2(refptr1);
- EXPECT_EQ(2, ref->getRefCnt());
+ EXPECT_FALSE(ref->unique());
RefPtr<SkRefCnt> refptr3;
EXPECT_FALSE(refptr3);
// Take a third reference for the third instance.
refptr3 = refptr1;
- EXPECT_EQ(3, ref->getRefCnt());
+ EXPECT_FALSE(ref->unique());
// Same object, so should have the same refcount.
refptr2 = refptr3;
- EXPECT_EQ(3, ref->getRefCnt());
+ EXPECT_FALSE(ref->unique());
// Drop the object from refptr2, so it should lose its reference.
EXPECT_TRUE(refptr2);
refptr2.clear();
- EXPECT_EQ(2, ref->getRefCnt());
+ EXPECT_FALSE(ref->unique());
EXPECT_FALSE(refptr2);
EXPECT_EQ(NULL, refptr2.get());
EXPECT_TRUE(refptr3);
- EXPECT_EQ(2, refptr3->getRefCnt());
+ EXPECT_FALSE(refptr3->unique());
EXPECT_EQ(ref, &*refptr3);
EXPECT_EQ(ref, refptr3.get());
}
// Drop a reference when the third object is destroyed.
- EXPECT_EQ(1, ref->getRefCnt());
+ EXPECT_TRUE(ref->unique());
}
}
TEST(RefPtrTest, Construct) {
SkRefCnt* ref = new SkRefCnt();
- EXPECT_EQ(1, ref->getRefCnt());
+ EXPECT_TRUE(ref->unique());
// Adopt the reference from the caller on creation.
RefPtr<SkRefCnt> refptr1(AdoptRef(ref));
- EXPECT_EQ(1, ref->getRefCnt());
- EXPECT_EQ(1, refptr1->getRefCnt());
+ EXPECT_TRUE(ref->unique());
+ EXPECT_TRUE(refptr1->unique());
EXPECT_EQ(ref, &*refptr1);
EXPECT_EQ(ref, refptr1.get());
RefPtr<SkRefCnt> refptr2(refptr1);
- EXPECT_EQ(2, ref->getRefCnt());
+ EXPECT_FALSE(ref->unique());
}
TEST(RefPtrTest, DeclareAndAssign) {
SkRefCnt* ref = new SkRefCnt();
- EXPECT_EQ(1, ref->getRefCnt());
+ EXPECT_TRUE(ref->unique());
// Adopt the reference from the caller on creation.
RefPtr<SkRefCnt> refptr1 = AdoptRef(ref);
- EXPECT_EQ(1, ref->getRefCnt());
- EXPECT_EQ(1, refptr1->getRefCnt());
+ EXPECT_TRUE(ref->unique());
+ EXPECT_TRUE(refptr1->unique());
EXPECT_EQ(ref, &*refptr1);
EXPECT_EQ(ref, refptr1.get());
RefPtr<SkRefCnt> refptr2 = refptr1;
- EXPECT_EQ(2, ref->getRefCnt());
+ EXPECT_FALSE(ref->unique());
}
TEST(RefPtrTest, Assign) {
SkRefCnt* ref = new SkRefCnt();
- EXPECT_EQ(1, ref->getRefCnt());
+ EXPECT_TRUE(ref->unique());
// Adopt the reference from the caller on creation.
RefPtr<SkRefCnt> refptr1;
refptr1 = AdoptRef(ref);
- EXPECT_EQ(1, ref->getRefCnt());
- EXPECT_EQ(1, refptr1->getRefCnt());
+ EXPECT_TRUE(ref->unique());
+ EXPECT_TRUE(refptr1->unique());
EXPECT_EQ(ref, &*refptr1);
EXPECT_EQ(ref, refptr1.get());
RefPtr<SkRefCnt> refptr2;
refptr2 = refptr1;
- EXPECT_EQ(2, ref->getRefCnt());
+ EXPECT_FALSE(ref->unique());
}
class Subclass : public SkRefCnt {};
TEST(RefPtrTest, Upcast) {
RefPtr<Subclass> child = AdoptRef(new Subclass());
- EXPECT_EQ(1, child->getRefCnt());
+ EXPECT_TRUE(child->unique());
RefPtr<SkRefCnt> parent = child;
EXPECT_TRUE(child);
EXPECT_TRUE(parent);
- EXPECT_EQ(2, child->getRefCnt());
- EXPECT_EQ(2, parent->getRefCnt());
+ EXPECT_FALSE(child->unique());
+ EXPECT_FALSE(parent->unique());
}
} // namespace
« no previous file with comments | « skia/ext/platform_canvas_unittest.cc ('k') | skia/ext/skia_trace_shim.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698