summaryrefslogtreecommitdiffstats
path: root/base/bind_unittest.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 00:26:37 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 00:26:37 +0000
commite8bfc31d8cbd65213951163ffc28bc6615f71670 (patch)
tree831ef87394344cc07d1035efd402c4c8a37786d7 /base/bind_unittest.cc
parent2d62310296eb3c7eb6f92d7eb699dafa5450dac8 (diff)
downloadchromium_src-e8bfc31d8cbd65213951163ffc28bc6615f71670.zip
chromium_src-e8bfc31d8cbd65213951163ffc28bc6615f71670.tar.gz
chromium_src-e8bfc31d8cbd65213951163ffc28bc6615f71670.tar.bz2
Add new helper that can adapt Callbacks with return values for Closures.
This is helpful for reducing manually written static functions that just effectively just invoke the function and ignore the return value. BUG=87287 TEST=new unittest Review URL: http://codereview.chromium.org/8048008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/bind_unittest.cc')
-rw-r--r--base/bind_unittest.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
index 8718d1d..dde2226 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -4,12 +4,6 @@
#include "base/bind.h"
-#if defined(BASE_CALLBACK_H_)
-// We explicitly do not want to include callback.h so people are not tempted
-// to use bind.h in a headerfile for getting the Callback types.
-#error "base/bind.h should avoid pulling in callback.h by default."
-#endif
-
#include "base/callback.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -317,6 +311,15 @@ TEST_F(BindTest, ReturnValues) {
EXPECT_EQ(51337, const_method_const_obj_cb.Run());
}
+// IgnoreReturn adapter test.
+// - Function with return value, and no params can be converted to Closure.
+TEST_F(BindTest, IgnoreReturn) {
+ EXPECT_CALL(static_func_mock_, IntMethod0()).WillOnce(Return(1337));
+ Callback<int(void)> normal_cb = Bind(&IntFunc0);
+ Closure c = IgnoreReturn(normal_cb);
+ c.Run();
+}
+
// Argument binding tests.
// - Argument binding to primitive.
// - Argument binding to primitive pointer.