| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/callback_internal.h" | 8 #include "base/callback_internal.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 void(FakeInvoker, FakeInvoker)> | 59 void(FakeInvoker, FakeInvoker)> |
| 60 FakeBindState2; | 60 FakeBindState2; |
| 61 | 61 |
| 62 class CallbackTest : public ::testing::Test { | 62 class CallbackTest : public ::testing::Test { |
| 63 public: | 63 public: |
| 64 CallbackTest() | 64 CallbackTest() |
| 65 : callback_a_(new FakeBindState1()), | 65 : callback_a_(new FakeBindState1()), |
| 66 callback_b_(new FakeBindState2()) { | 66 callback_b_(new FakeBindState2()) { |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual ~CallbackTest() { | 69 ~CallbackTest() override {} |
| 70 } | |
| 71 | 70 |
| 72 protected: | 71 protected: |
| 73 Callback<void(void)> callback_a_; | 72 Callback<void(void)> callback_a_; |
| 74 const Callback<void(void)> callback_b_; // Ensure APIs work with const. | 73 const Callback<void(void)> callback_b_; // Ensure APIs work with const. |
| 75 Callback<void(void)> null_callback_; | 74 Callback<void(void)> null_callback_; |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 // Ensure we can create unbound callbacks. We need this to be able to store | 77 // Ensure we can create unbound callbacks. We need this to be able to store |
| 79 // them in class members that can be initialized later. | 78 // them in class members that can be initialized later. |
| 80 TEST_F(CallbackTest, DefaultConstruction) { | 79 TEST_F(CallbackTest, DefaultConstruction) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 175 |
| 177 TEST_F(CallbackTest, CallbackHasLastRefOnContainingObject) { | 176 TEST_F(CallbackTest, CallbackHasLastRefOnContainingObject) { |
| 178 bool deleted = false; | 177 bool deleted = false; |
| 179 CallbackOwner* owner = new CallbackOwner(&deleted); | 178 CallbackOwner* owner = new CallbackOwner(&deleted); |
| 180 owner->Reset(); | 179 owner->Reset(); |
| 181 ASSERT_TRUE(deleted); | 180 ASSERT_TRUE(deleted); |
| 182 } | 181 } |
| 183 | 182 |
| 184 } // namespace | 183 } // namespace |
| 185 } // namespace base | 184 } // namespace base |
| OLD | NEW |