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

Unified Diff: base/callback_helpers_unittest.cc

Issue 2091503004: Add move constructor in ScopedClosureRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 6 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.cc ('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 3b17a6b754c81d8f4b0a5417b2f266f4026ee657..0e42852f67315b69bdb6e79c93d16c23ff58d448 100644
--- a/base/callback_helpers_unittest.cc
+++ b/base/callback_helpers_unittest.cc
@@ -58,4 +58,47 @@ TEST(BindHelpersTest, TestScopedClosureRunnerReset) {
EXPECT_EQ(1, run_count_3);
}
+TEST(BindHelpersTest, TestScopedClosureRunnerMoveConstructor) {
+ int run_count = 0;
+ {
+ std::unique_ptr<base::ScopedClosureRunner> runner(
+ new base::ScopedClosureRunner(base::Bind(&Increment, &run_count)));
+ base::ScopedClosureRunner runner2(std::move(*runner));
+ runner.reset();
+ EXPECT_EQ(0, run_count);
+ }
+ EXPECT_EQ(1, run_count);
+}
+
+TEST(BindHelpersTest, TestScopedClosureRunnerMoveAssignment) {
+ int run_count = 0;
+ {
+ base::ScopedClosureRunner runner;
+ {
+ base::ScopedClosureRunner runner2(base::Bind(&Increment, &run_count));
+ runner = std::move(runner2);
+ }
+ EXPECT_EQ(0, run_count);
+ }
+ EXPECT_EQ(1, run_count);
+}
+
+TEST(BindHelpersTest, TestScopedClosureRunnerRunOnReplace) {
+ int run_count1 = 0;
+ int run_count2 = 0;
+ {
+ base::ScopedClosureRunner runner1(base::Bind(&Increment, &run_count1));
+ {
+ base::ScopedClosureRunner runner2(base::Bind(&Increment, &run_count2));
+ runner1 = std::move(runner2);
+ EXPECT_EQ(1, run_count1);
+ EXPECT_EQ(0, run_count2);
+ }
+ EXPECT_EQ(1, run_count1);
+ EXPECT_EQ(0, run_count2);
+ }
+ EXPECT_EQ(1, run_count1);
+ EXPECT_EQ(1, run_count2);
+}
+
} // namespace
« no previous file with comments | « base/callback_helpers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698