| 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 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 copies = 0; | 771 copies = 0; |
| 772 assigns = 0; | 772 assigns = 0; |
| 773 Callback<void(CopyCounter)> forward_cb = | 773 Callback<void(CopyCounter)> forward_cb = |
| 774 Bind(&VoidPolymorphic1<CopyCounter>); | 774 Bind(&VoidPolymorphic1<CopyCounter>); |
| 775 forward_cb.Run(counter); | 775 forward_cb.Run(counter); |
| 776 EXPECT_GE(1, copies); | 776 EXPECT_GE(1, copies); |
| 777 EXPECT_EQ(0, assigns); | 777 EXPECT_EQ(0, assigns); |
| 778 | 778 |
| 779 copies = 0; | 779 copies = 0; |
| 780 assigns = 0; | 780 assigns = 0; |
| 781 DerivedCopyCounter dervied(&copies, &assigns); | 781 DerivedCopyCounter derived(&copies, &assigns); |
| 782 Callback<void(CopyCounter)> coerce_cb = | 782 Callback<void(CopyCounter)> coerce_cb = |
| 783 Bind(&VoidPolymorphic1<CopyCounter>); | 783 Bind(&VoidPolymorphic1<CopyCounter>); |
| 784 coerce_cb.Run(CopyCounter(dervied)); | 784 coerce_cb.Run(CopyCounter(derived)); |
| 785 EXPECT_GE(2, copies); | 785 EXPECT_GE(2, copies); |
| 786 EXPECT_EQ(0, assigns); | 786 EXPECT_EQ(0, assigns); |
| 787 } | 787 } |
| 788 | 788 |
| 789 // Callback construction and assignment tests. | 789 // Callback construction and assignment tests. |
| 790 // - Construction from an InvokerStorageHolder should not cause ref/deref. | 790 // - Construction from an InvokerStorageHolder should not cause ref/deref. |
| 791 // - Assignment from other callback should only cause one ref | 791 // - Assignment from other callback should only cause one ref |
| 792 // | 792 // |
| 793 // TODO(ajwong): Is there actually a way to test this? | 793 // TODO(ajwong): Is there actually a way to test this? |
| 794 | 794 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 820 base::Callback<void(int)> null_cb; | 820 base::Callback<void(int)> null_cb; |
| 821 ASSERT_TRUE(null_cb.is_null()); | 821 ASSERT_TRUE(null_cb.is_null()); |
| 822 EXPECT_DEATH(base::Bind(null_cb, 42), ""); | 822 EXPECT_DEATH(base::Bind(null_cb, 42), ""); |
| 823 } | 823 } |
| 824 | 824 |
| 825 #endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && | 825 #endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && |
| 826 // GTEST_HAS_DEATH_TEST | 826 // GTEST_HAS_DEATH_TEST |
| 827 | 827 |
| 828 } // namespace | 828 } // namespace |
| 829 } // namespace base | 829 } // namespace base |
| OLD | NEW |