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

Unified Diff: core/fxcrt/cfx_retain_ptr_unittest.cpp

Issue 2583093003: Add CFX_RetainPtr Leak() and Unleak() methods (Closed)
Patch Set: Reduce scope of change Created 4 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
« core/fxcrt/cfx_retain_ptr.h ('K') | « core/fxcrt/cfx_retain_ptr.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcrt/cfx_retain_ptr_unittest.cpp
diff --git a/core/fxcrt/cfx_retain_ptr_unittest.cpp b/core/fxcrt/cfx_retain_ptr_unittest.cpp
index 692beb82ffdf3eadd21d408007a2617ea31a5d85..f9a4ecb74ffb6446209ebfa8644f2b7459859618 100644
--- a/core/fxcrt/cfx_retain_ptr_unittest.cpp
+++ b/core/fxcrt/cfx_retain_ptr_unittest.cpp
@@ -128,6 +128,27 @@ TEST(fxcrt, RetainPtrSwap) {
EXPECT_EQ(1, obj2.release_count());
}
+TEST(fxcrt, RetainPtrLeak) {
+ PseudoRetainable obj;
+ PseudoRetainable* leak;
+ {
+ CFX_RetainPtr<PseudoRetainable> ptr(&obj);
+ leak = ptr.Leak();
+ EXPECT_EQ(1, obj.retain_count());
+ EXPECT_EQ(0, obj.release_count());
+ }
+ EXPECT_EQ(1, obj.retain_count());
+ EXPECT_EQ(0, obj.release_count());
+ {
+ CFX_RetainPtr<PseudoRetainable> ptr;
+ ptr.Unleak(leak);
+ EXPECT_EQ(1, obj.retain_count());
+ EXPECT_EQ(0, obj.release_count());
+ }
+ EXPECT_EQ(1, obj.retain_count());
+ EXPECT_EQ(1, obj.release_count());
+}
+
TEST(fxcrt, RetainPtrSwapNull) {
PseudoRetainable obj1;
{
« core/fxcrt/cfx_retain_ptr.h ('K') | « core/fxcrt/cfx_retain_ptr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698