OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/callback_helpers.h" | 5 #include "base/callback_helpers.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 EXPECT_EQ(0, run_count_1); | 102 EXPECT_EQ(0, run_count_1); |
103 EXPECT_EQ(0, run_count_2); | 103 EXPECT_EQ(0, run_count_2); |
104 } | 104 } |
105 EXPECT_EQ(0, run_count_1); | 105 EXPECT_EQ(0, run_count_1); |
106 EXPECT_EQ(0, run_count_2); | 106 EXPECT_EQ(0, run_count_2); |
107 } | 107 } |
108 EXPECT_EQ(0, run_count_1); | 108 EXPECT_EQ(0, run_count_1); |
109 EXPECT_EQ(1, run_count_2); | 109 EXPECT_EQ(1, run_count_2); |
110 } | 110 } |
111 | 111 |
| 112 TEST(CallbackHelpersTest, TestIgnoreReuse) { |
| 113 int count = 0; |
| 114 base::OnceCallback<void(int*)> cb = |
| 115 base::BindOnce([](int* count) { ++*count; }); |
| 116 |
| 117 base::RepeatingCallback<void(int*)> wrapped = |
| 118 base::IgnoreReuse(std::move(cb)); |
| 119 |
| 120 EXPECT_EQ(0, count); |
| 121 wrapped.Run(&count); |
| 122 EXPECT_EQ(1, count); |
| 123 wrapped.Run(&count); |
| 124 EXPECT_EQ(1, count); |
| 125 } |
| 126 |
112 } // namespace | 127 } // namespace |
OLD | NEW |