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

Unified Diff: skia/ext/refptr_unittest.cc

Issue 19267024: cc: Don't leak a ref to SkColorFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: filterleak: better Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« skia/ext/refptr.h ('K') | « skia/ext/refptr.h ('k') | no next file » | 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..0b512a2a70a3aca7bfe7b1758fd27f3d73aca5e4 100644
--- a/skia/ext/refptr_unittest.cc
+++ b/skia/ext/refptr_unittest.cc
@@ -9,6 +9,11 @@
namespace skia {
namespace {
+TEST(RefPtrTest, EmptyContruction) {
+ RefPtr<SkRefCnt> refptr;
+ EXPECT_FALSE(refptr);
+}
+
TEST(RefPtrTest, ReferenceCounting) {
SkRefCnt* ref = new SkRefCnt();
EXPECT_EQ(1, ref->getRefCnt());
@@ -121,5 +126,24 @@ TEST(RefPtrTest, Upcast) {
EXPECT_EQ(2, parent->getRefCnt());
}
+bool Factory(SkRefCnt** refcnt) {
+ *refcnt = new SkRefCnt;
+ return true;
+}
+
+TEST(RefPtrTest, Receive) {
+ RefPtr<SkRefCnt> refptr;
+ Factory(refptr.ReceiveAndAdoptRef());
+ EXPECT_EQ(1, refptr->getRefCnt());
+}
+
+TEST(RefPtrTest, ReceiveAndUseInSameExpression) {
+ // This should assert, but only in debug mode.
+#ifndef NDEBUG
+ RefPtr<SkRefCnt> refptr;
+ EXPECT_DEATH({ Factory(refptr.ReceiveAndAdoptRef()) && refptr.get(); }, "");
+#endif
+}
+
} // namespace
} // namespace skia
« skia/ext/refptr.h ('K') | « skia/ext/refptr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698