diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-14 21:48:54 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-14 21:48:54 +0000 |
commit | 115288648041898b6d50f7d2e17391e2d1972a76 (patch) | |
tree | eee67d927a7ebb40e87848924a8f26c5c5cb99ca /base/callback_unittest.cc | |
parent | e91ac22d99252095839ca7c82c092972bd56445e (diff) | |
download | chromium_src-115288648041898b6d50f7d2e17391e2d1972a76.zip chromium_src-115288648041898b6d50f7d2e17391e2d1972a76.tar.gz chromium_src-115288648041898b6d50f7d2e17391e2d1972a76.tar.bz2 |
Revert 114494 - Remove BindStateHolder and have Bind() return a Callback<> object directly.
This removes some complexity and also fixes a bug where if you call Bind() with the result of Bind(), the resulting Callback would only be valid during the first call. Ouch.
BUG=none
TEST=new unittests
Review URL: http://codereview.chromium.org/8738001
TBR=ajwong@chromium.org
Review URL: http://codereview.chromium.org/8914022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/callback_unittest.cc')
-rw-r--r-- | base/callback_unittest.cc | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/base/callback_unittest.cc b/base/callback_unittest.cc index e42b933..8527e70 100644 --- a/base/callback_unittest.cc +++ b/base/callback_unittest.cc @@ -9,7 +9,6 @@ #include "testing/gtest/include/gtest/gtest.h" namespace base { - namespace { class HelperObject { @@ -27,40 +26,18 @@ struct FakeInvoker { static void Run(internal::BindStateBase*) { } }; -} // namespace - -namespace internal { -template <typename Runnable, typename RunType, typename BoundArgsType> -struct BindState; // White-box testpoints to inject into a Callback<> object for checking -// comparators and emptiness APIs. Use a BindState that is specialized -// based on a type we declared in the anonymous namespace above to remove any -// chance of colliding with another instantiation and breaking the -// one-definition-rule. -template <> -struct BindState<void(void), void(void), void(FakeInvoker)> - : public BindStateBase { +// comparators and emptiness APIs. +class FakeBindState1 : public internal::BindStateBase { public: typedef FakeInvoker InvokerType; }; -template <> -struct BindState<void(void), void(void), - void(FakeInvoker, FakeInvoker)> - : public BindStateBase { +class FakeBindState2 : public internal::BindStateBase { public: typedef FakeInvoker InvokerType; }; -} // namespace internal - -namespace { - -typedef internal::BindState<void(void), void(void), void(FakeInvoker)> - FakeBindState1; -typedef internal::BindState<void(void), void(void), - void(FakeInvoker, FakeInvoker)> - FakeBindState2; TEST(CallbackOld, OneArg) { HelperObject obj; @@ -83,8 +60,8 @@ TEST(CallbackOld, ReturnValue) { class CallbackTest : public ::testing::Test { public: CallbackTest() - : callback_a_(new FakeBindState1()), - callback_b_(new FakeBindState2()) { + : callback_a_(MakeBindStateHolder(new FakeBindState1())), + callback_b_(MakeBindStateHolder(new FakeBindState2())) { } virtual ~CallbackTest() { @@ -128,7 +105,8 @@ TEST_F(CallbackTest, Equals) { EXPECT_FALSE(callback_b_.Equals(callback_a_)); // We should compare based on instance, not type. - Callback<void(void)> callback_c(new FakeBindState1()); + Callback<void(void)> callback_c( + MakeBindStateHolder(new FakeBindState1())); Callback<void(void)> callback_a2 = callback_a_; EXPECT_TRUE(callback_a_.Equals(callback_a2)); EXPECT_FALSE(callback_a_.Equals(callback_c)); |