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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/logging.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 using ::testing::Mock; | 21 using ::testing::Mock; |
21 using ::testing::Return; | 22 using ::testing::Return; |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // - Can bind a __stdcall function. | 1059 // - Can bind a __stdcall function. |
1059 TEST_F(BindTest, WindowsCallingConventions) { | 1060 TEST_F(BindTest, WindowsCallingConventions) { |
1060 Callback<int()> fastcall_cb = Bind(&FastCallFunc, 1); | 1061 Callback<int()> fastcall_cb = Bind(&FastCallFunc, 1); |
1061 EXPECT_EQ(1, fastcall_cb.Run()); | 1062 EXPECT_EQ(1, fastcall_cb.Run()); |
1062 | 1063 |
1063 Callback<int()> stdcall_cb = Bind(&StdCallFunc, 2); | 1064 Callback<int()> stdcall_cb = Bind(&StdCallFunc, 2); |
1064 EXPECT_EQ(2, stdcall_cb.Run()); | 1065 EXPECT_EQ(2, stdcall_cb.Run()); |
1065 } | 1066 } |
1066 #endif | 1067 #endif |
1067 | 1068 |
1068 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST | 1069 #if DCHECK_IS_ON() && GTEST_HAS_DEATH_TEST |
1069 | 1070 |
1070 // Test null callbacks cause a DCHECK. | 1071 // Test null callbacks cause a DCHECK. |
1071 TEST(BindDeathTest, NullCallback) { | 1072 TEST(BindDeathTest, NullCallback) { |
1072 base::Callback<void(int)> null_cb; | 1073 base::Callback<void(int)> null_cb; |
1073 ASSERT_TRUE(null_cb.is_null()); | 1074 ASSERT_TRUE(null_cb.is_null()); |
1074 EXPECT_DEATH(base::Bind(null_cb, 42), ""); | 1075 EXPECT_DEATH(base::Bind(null_cb, 42), ""); |
1075 } | 1076 } |
1076 | 1077 |
1077 #endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && | 1078 #endif // DCHECK_IS_ON() && GTEST_HAS_DEATH_TEST |
1078 // GTEST_HAS_DEATH_TEST | |
1079 | 1079 |
1080 } // namespace | 1080 } // namespace |
1081 } // namespace base | 1081 } // namespace base |
OLD | NEW |