Chromium Code Reviews| Index: base/callback_unittest.cc |
| diff --git a/base/callback_unittest.cc b/base/callback_unittest.cc |
| index 8527e70984a1ebb0e7e4fb16df25d24ec628e00f..06f532dddb19de545c237af02755e894f0c10f02 100644 |
| --- a/base/callback_unittest.cc |
| +++ b/base/callback_unittest.cc |
| @@ -9,6 +9,7 @@ |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace base { |
| + |
| namespace { |
| class HelperObject { |
| @@ -26,18 +27,39 @@ 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. |
| -class FakeBindState1 : public internal::BindStateBase { |
| +// comparators and emptiness APIs. Use a BindState that is specialized |
| +// based on a type we declared in this anonymous namespace to remove any chance |
|
akalin
2011/12/02 18:54:45
this anonymous namespace -> the anonymous namespac
awong
2011/12/06 00:21:12
Done.
|
| +// of colliding with another instantiation and breaking the one-definition-rule. |
| +template <> |
| +struct internal::BindState<void(void), void(void), void(FakeInvoker)> |
| + : public internal::BindStateBase { |
| public: |
| typedef FakeInvoker InvokerType; |
| }; |
| -class FakeBindState2 : public internal::BindStateBase { |
| +template <> |
| +struct internal::BindState<void(void), void(void), |
| + void(FakeInvoker, FakeInvoker)> |
| + : 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; |
| @@ -60,8 +82,8 @@ TEST(CallbackOld, ReturnValue) { |
| class CallbackTest : public ::testing::Test { |
| public: |
| CallbackTest() |
| - : callback_a_(MakeBindStateHolder(new FakeBindState1())), |
| - callback_b_(MakeBindStateHolder(new FakeBindState2())) { |
| + : callback_a_(new FakeBindState1()), |
| + callback_b_(new FakeBindState2()) { |
| } |
| virtual ~CallbackTest() { |
| @@ -105,8 +127,7 @@ TEST_F(CallbackTest, Equals) { |
| EXPECT_FALSE(callback_b_.Equals(callback_a_)); |
| // We should compare based on instance, not type. |
| - Callback<void(void)> callback_c( |
| - MakeBindStateHolder(new FakeBindState1())); |
| + Callback<void(void)> callback_c(new FakeBindState1()); |
| Callback<void(void)> callback_a2 = callback_a_; |
| EXPECT_TRUE(callback_a_.Equals(callback_a2)); |
| EXPECT_FALSE(callback_a_.Equals(callback_c)); |