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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 // - Normal function bound with non-refcounted first argument. | 327 // - Normal function bound with non-refcounted first argument. |
328 // - Method bound to non-const object. | 328 // - Method bound to non-const object. |
329 // - Method bound to scoped_refptr. | 329 // - Method bound to scoped_refptr. |
330 // - Const method bound to non-const object. | 330 // - Const method bound to non-const object. |
331 // - Const method bound to const object. | 331 // - Const method bound to const object. |
332 // - Derived classes can be used with pointers to non-virtual base functions. | 332 // - Derived classes can be used with pointers to non-virtual base functions. |
333 // - Derived classes can be used with pointers to virtual base functions (and | 333 // - Derived classes can be used with pointers to virtual base functions (and |
334 // preserve virtual dispatch). | 334 // preserve virtual dispatch). |
335 TEST_F(BindTest, FunctionTypeSupport) { | 335 TEST_F(BindTest, FunctionTypeSupport) { |
336 EXPECT_CALL(static_func_mock_, VoidMethod0()); | 336 EXPECT_CALL(static_func_mock_, VoidMethod0()); |
337 EXPECT_CALL(has_ref_, AddRef()).Times(5); | 337 EXPECT_CALL(has_ref_, AddRef()).Times(4); |
338 EXPECT_CALL(has_ref_, Release()).Times(5); | 338 EXPECT_CALL(has_ref_, Release()).Times(4); |
339 EXPECT_CALL(has_ref_, VoidMethod0()).Times(2); | 339 EXPECT_CALL(has_ref_, VoidMethod0()).Times(2); |
340 EXPECT_CALL(has_ref_, VoidConstMethod0()).Times(2); | 340 EXPECT_CALL(has_ref_, VoidConstMethod0()).Times(2); |
341 | 341 |
342 Closure normal_cb = Bind(&VoidFunc0); | 342 Closure normal_cb = Bind(&VoidFunc0); |
343 Callback<NoRef*()> normal_non_refcounted_cb = | 343 Callback<NoRef*()> normal_non_refcounted_cb = |
344 Bind(&PolymorphicIdentity<NoRef*>, &no_ref_); | 344 Bind(&PolymorphicIdentity<NoRef*>, &no_ref_); |
345 normal_cb.Run(); | 345 normal_cb.Run(); |
346 EXPECT_EQ(&no_ref_, normal_non_refcounted_cb.Run()); | 346 EXPECT_EQ(&no_ref_, normal_non_refcounted_cb.Run()); |
347 | 347 |
348 Closure method_cb = Bind(&HasRef::VoidMethod0, &has_ref_); | 348 Closure method_cb = Bind(&HasRef::VoidMethod0, &has_ref_); |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 base::Callback<void(int)> null_cb; | 884 base::Callback<void(int)> null_cb; |
885 ASSERT_TRUE(null_cb.is_null()); | 885 ASSERT_TRUE(null_cb.is_null()); |
886 EXPECT_DEATH(base::Bind(null_cb, 42), ""); | 886 EXPECT_DEATH(base::Bind(null_cb, 42), ""); |
887 } | 887 } |
888 | 888 |
889 #endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && | 889 #endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && |
890 // GTEST_HAS_DEATH_TEST | 890 // GTEST_HAS_DEATH_TEST |
891 | 891 |
892 } // namespace | 892 } // namespace |
893 } // namespace base | 893 } // namespace base |
OLD | NEW |