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

Unified Diff: base/callback_helpers_unittest.cc

Issue 2709913002: Fix OnceCallback support of base::ResetAndReturn (Closed)
Patch Set: Created 3 years, 10 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') | no next file » | 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 82839963795fcf39e657a3d9b1cd35df5b2ae215..6c48d7ce4e52eeea056722df4cd97f8047f68292 100644
--- a/base/callback_helpers_unittest.cc
+++ b/base/callback_helpers_unittest.cc
@@ -14,6 +14,24 @@ void Increment(int* value) {
(*value)++;
}
+TEST(CallbackHelpersTest, TestResetAndReturn) {
+ int run_count = 0;
+
+ base::Closure cb = base::Bind(&Increment, &run_count);
+ EXPECT_EQ(0, run_count);
+ base::ResetAndReturn(&cb).Run();
+ EXPECT_EQ(1, run_count);
+ EXPECT_FALSE(cb);
+
+ run_count = 0;
+
+ base::OnceClosure cb2 = base::BindOnce(&Increment, &run_count);
+ EXPECT_EQ(0, run_count);
+ base::ResetAndReturn(&cb2).Run();
+ EXPECT_EQ(1, run_count);
+ EXPECT_FALSE(cb2);
+}
+
TEST(CallbackHelpersTest, TestScopedClosureRunnerExitScope) {
int run_count = 0;
{
« no previous file with comments | « base/callback_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698