Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1999)

Unified Diff: base/callback_helpers_unittest.cc

Issue 2820993002: Introduce base::IgnoreReuse() to wrap OnceCallback into RepeatingCallback (Closed)
Patch Set: fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/callback_helpers.h ('k') | base/files/important_file_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_helpers_unittest.cc
diff --git a/base/callback_helpers_unittest.cc b/base/callback_helpers_unittest.cc
index 6c48d7ce4e52eeea056722df4cd97f8047f68292..9166d8afb46c67e556352ca5803ffd36f9c00549 100644
--- a/base/callback_helpers_unittest.cc
+++ b/base/callback_helpers_unittest.cc
@@ -109,4 +109,19 @@ TEST(CallbackHelpersTest, TestScopedClosureRunnerMoveAssignment) {
EXPECT_EQ(1, run_count_2);
}
+TEST(CallbackHelpersTest, TestAdaptCallbackForRepeating) {
+ int count = 0;
+ base::OnceCallback<void(int*)> cb =
+ base::BindOnce([](int* count) { ++*count; });
+
+ base::RepeatingCallback<void(int*)> wrapped =
+ base::AdaptCallbackForRepeating(std::move(cb));
+
+ EXPECT_EQ(0, count);
+ wrapped.Run(&count);
+ EXPECT_EQ(1, count);
+ wrapped.Run(&count);
+ EXPECT_EQ(1, count);
+}
+
} // namespace
« no previous file with comments | « base/callback_helpers.h ('k') | base/files/important_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698