Index: base/task_unittest.cc |
diff --git a/base/task_unittest.cc b/base/task_unittest.cc |
index e0cb659cf094c01db34730189989efef07a243d2..d7d31fa47b2eace0011df618f4ed34c3b7d01a45 100644 |
--- a/base/task_unittest.cc |
+++ b/base/task_unittest.cc |
@@ -2,6 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/bind.h" |
#include "base/memory/ref_counted.h" |
#include "base/task.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -107,4 +108,30 @@ TEST(TaskTest, TestScopedTaskRunnerManualRun) { |
EXPECT_TRUE(was_deleted); |
} |
+void Increment(int* value) { |
+ (*value)++; |
+} |
+ |
+TEST(TaskTest, TestScopedClosureRunnerExitScope) { |
+ int run_count = 0; |
+ { |
+ base::ScopedClosureRunner runner(base::Bind(Increment, &run_count)); |
+ EXPECT_EQ(0, run_count); |
+ } |
+ EXPECT_EQ(1, run_count); |
+} |
+ |
+TEST(TaskTest, TestScopedClosureRunnerRelease) { |
+ int run_count = 0; |
+ base::Closure c; |
+ { |
+ base::ScopedClosureRunner runner(base::Bind(Increment, &run_count)); |
+ c = runner.Release(); |
+ EXPECT_EQ(0, run_count); |
+ } |
+ EXPECT_EQ(0, run_count); |
+ c.Run(); |
+ EXPECT_EQ(1, run_count); |
+} |
+ |
} // namespace |