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

Unified Diff: third_party/WebKit/Source/wtf/MakeCancellableTest.cpp

Issue 2322253002: Use WTF::WeakPtr in WTF::makeCancellable (Closed)
Patch Set: +test Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/wtf/MakeCancellable.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/MakeCancellableTest.cpp
diff --git a/third_party/WebKit/Source/wtf/MakeCancellableTest.cpp b/third_party/WebKit/Source/wtf/MakeCancellableTest.cpp
index 9202d443a30bdf396d0d4bc13e0dc44f9e2e5443..cba22eb3356485b8c047c5b6e5febfb1cfc4f584 100644
--- a/third_party/WebKit/Source/wtf/MakeCancellableTest.cpp
+++ b/third_party/WebKit/Source/wtf/MakeCancellableTest.cpp
@@ -43,6 +43,7 @@ TEST(MakeCancellableTest, NotCancelled)
auto f = bind(&add, unretained(&v));
auto result = makeCancellable(std::move(f));
+ EXPECT_FALSE(result.function->isCancelled());
EXPECT_EQ(0, v);
(*result.function)(3);
EXPECT_EQ(3, v);
@@ -54,8 +55,10 @@ TEST(MakeCancellableTest, ExplicitCancel)
auto f = bind(&add, unretained(&v));
auto result = makeCancellable(std::move(f));
+ EXPECT_FALSE(result.function->isCancelled());
EXPECT_TRUE(result.canceller.isActive());
result.canceller.cancel();
+ EXPECT_TRUE(result.function->isCancelled());
EXPECT_FALSE(result.canceller.isActive());
EXPECT_EQ(0, v);
@@ -73,8 +76,10 @@ TEST(MakeCancellableTest, ScopeOutCancel)
ScopedFunctionCanceller scopedCanceller = std::move(result.canceller);
EXPECT_TRUE(scopedCanceller.isActive());
+ EXPECT_FALSE(f->isCancelled());
}
+ EXPECT_TRUE(f->isCancelled());
EXPECT_EQ(0, v);
(*f)(3);
EXPECT_EQ(0, v);
@@ -92,8 +97,10 @@ TEST(MakeCancellableTest, Detach)
EXPECT_TRUE(scopedCanceller.isActive());
scopedCanceller.detach();
EXPECT_FALSE(scopedCanceller.isActive());
+ EXPECT_FALSE(f->isCancelled());
}
+ EXPECT_FALSE(f->isCancelled());
EXPECT_EQ(0, v);
(*f)(3);
EXPECT_EQ(3, v);
@@ -105,11 +112,13 @@ TEST(MakeCancellableTest, MultiCall)
auto f = bind(&add, unretained(&v));
auto result = makeCancellable(std::move(f));
+ EXPECT_FALSE(result.function->isCancelled());
EXPECT_EQ(0, v);
(*result.function)(2);
EXPECT_EQ(2, v);
(*result.function)(3);
EXPECT_EQ(5, v);
+ EXPECT_FALSE(result.function->isCancelled());
}
TEST(MakeCancellableTest, DestroyOnCancel)
@@ -118,8 +127,10 @@ TEST(MakeCancellableTest, DestroyOnCancel)
auto f = bind([](const DestructionCounter&) {}, DestructionCounter(&counter));
auto result = makeCancellable(std::move(f));
+ EXPECT_FALSE(result.function->isCancelled());
EXPECT_EQ(0, counter);
result.canceller.cancel();
+ EXPECT_TRUE(result.function->isCancelled());
EXPECT_EQ(1, counter);
}
@@ -130,6 +141,7 @@ TEST(MakeCancellableTest, DestroyOnWrapperDestruction)
auto result = makeCancellable(std::move(f));
EXPECT_TRUE(result.canceller.isActive());
+ EXPECT_FALSE(result.function->isCancelled());
EXPECT_EQ(0, counter);
result.function = nullptr;
@@ -157,6 +169,7 @@ TEST(MakeCancellableTest, SelfAssignment)
#endif
EXPECT_TRUE(scopedCanceller.isActive());
+ EXPECT_FALSE(result.function->isCancelled());
EXPECT_EQ(0, v);
(*result.function)(1);
EXPECT_EQ(1, v);
« no previous file with comments | « third_party/WebKit/Source/wtf/MakeCancellable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698