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

Unified Diff: base/bind_unittest.cc

Issue 2401623002: Fix base::Callback<>::IsCancelled handling on nested base::Callback (Closed)
Patch Set: fix Created 4 years, 2 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 | « base/bind_internal.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bind_unittest.cc
diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
index 285a20d52698b33a8ac49e507784493d789c9b4c..b58feac2c39e9505352f1c8cfd5a6ffe35916d8e 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -24,6 +24,14 @@ using ::testing::Return;
using ::testing::StrictMock;
namespace base {
+
+using internal::OnceCallback;
+using internal::RepeatingCallback;
+using internal::OnceClosure;
+using internal::RepeatingClosure;
+using internal::BindOnce;
+using internal::BindRepeating;
+
namespace {
class IncompleteType;
@@ -1041,12 +1049,21 @@ TEST_F(BindTest, Cancellation) {
EXPECT_CALL(no_ref_, VoidMethodWithIntArg(_)).Times(2);
WeakPtrFactory<NoRef> weak_factory(&no_ref_);
- base::Callback<void(int)> cb =
- Bind(&NoRef::VoidMethodWithIntArg, weak_factory.GetWeakPtr());
- Closure cb2 = Bind(cb, 8);
+ RepeatingCallback<void(int)> cb =
+ BindRepeating(&NoRef::VoidMethodWithIntArg, weak_factory.GetWeakPtr());
+ RepeatingClosure cb2 = BindRepeating(cb, 8);
+ OnceClosure cb3 = BindOnce(cb, 8);
+
+ OnceCallback<void(int)> cb4 =
+ BindOnce(&NoRef::VoidMethodWithIntArg, weak_factory.GetWeakPtr());
+ EXPECT_FALSE(cb4.IsCancelled());
+
+ OnceClosure cb5 = BindOnce(std::move(cb4), 8);
EXPECT_FALSE(cb.IsCancelled());
EXPECT_FALSE(cb2.IsCancelled());
+ EXPECT_FALSE(cb3.IsCancelled());
+ EXPECT_FALSE(cb5.IsCancelled());
cb.Run(6);
cb2.Run();
@@ -1055,9 +1072,13 @@ TEST_F(BindTest, Cancellation) {
EXPECT_TRUE(cb.IsCancelled());
EXPECT_TRUE(cb2.IsCancelled());
+ EXPECT_TRUE(cb3.IsCancelled());
+ EXPECT_TRUE(cb5.IsCancelled());
cb.Run(6);
cb2.Run();
+ std::move(cb3).Run();
+ std::move(cb5).Run();
}
TEST_F(BindTest, OnceCallback) {
« no previous file with comments | « base/bind_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698