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

Unified Diff: base/bind_unittest.cc

Issue 2352853002: Disallow redundant Bind calls. (Closed)
Patch Set: static_assert message tweak 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 | « base/bind_internal.h ('k') | base/bind_unittest.nc » ('j') | 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 ff0400a8501a0c4c45e634e44a9965e6ed1c7582..285a20d52698b33a8ac49e507784493d789c9b4c 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -18,6 +18,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using ::testing::_;
using ::testing::Mock;
using ::testing::Return;
using ::testing::StrictMock;
@@ -37,6 +38,8 @@ class NoRef {
MOCK_METHOD0(IntMethod0, int());
MOCK_CONST_METHOD0(IntConstMethod0, int());
+ MOCK_METHOD1(VoidMethodWithIntArg, void(int));
+
private:
// Particularly important in this test to ensure no copies are made.
DISALLOW_COPY_AND_ASSIGN(NoRef);
@@ -1035,16 +1038,17 @@ TEST_F(BindTest, CapturelessLambda) {
}
TEST_F(BindTest, Cancellation) {
- EXPECT_CALL(no_ref_, VoidMethod0()).Times(2);
+ EXPECT_CALL(no_ref_, VoidMethodWithIntArg(_)).Times(2);
WeakPtrFactory<NoRef> weak_factory(&no_ref_);
- Closure cb = Bind(&NoRef::VoidMethod0, weak_factory.GetWeakPtr());
- Closure cb2 = Bind(cb);
+ base::Callback<void(int)> cb =
+ Bind(&NoRef::VoidMethodWithIntArg, weak_factory.GetWeakPtr());
+ Closure cb2 = Bind(cb, 8);
EXPECT_FALSE(cb.IsCancelled());
EXPECT_FALSE(cb2.IsCancelled());
- cb.Run();
+ cb.Run(6);
cb2.Run();
weak_factory.InvalidateWeakPtrs();
@@ -1052,7 +1056,7 @@ TEST_F(BindTest, Cancellation) {
EXPECT_TRUE(cb.IsCancelled());
EXPECT_TRUE(cb2.IsCancelled());
- cb.Run();
+ cb.Run(6);
cb2.Run();
}
« no previous file with comments | « base/bind_internal.h ('k') | base/bind_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698