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

Unified Diff: base/test/scoped_task_scheduler_unittest.cc

Issue 2713513003: Use the saved task runner if TestTaskScheduler is re-entered from a task executed by RunTask. (Closed)
Patch Set: Address review comments 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/test/scoped_task_scheduler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_task_scheduler_unittest.cc
diff --git a/base/test/scoped_task_scheduler_unittest.cc b/base/test/scoped_task_scheduler_unittest.cc
index cc0ffbbe62d5625aba5e3e7d2bed934ef8c442b2..f2037e1e937b11d3649a1c994ddfcb4314f93837 100644
--- a/base/test/scoped_task_scheduler_unittest.cc
+++ b/base/test/scoped_task_scheduler_unittest.cc
@@ -297,5 +297,21 @@ TEST(ScopedTaskSchedulerTest, ReassignCurrentTaskRunner) {
EXPECT_TRUE(second_task_ran);
}
+// Verify that a task can be posted from a task running in ScopedTaskScheduler.
+TEST(ScopedTaskSchedulerTest, ReentrantTaskRunner) {
+ bool task_ran = false;
+ ScopedTaskScheduler scoped_task_scheduler;
+ PostTask(FROM_HERE, Bind(
+ [](bool* task_ran) {
+ PostTask(
+ FROM_HERE,
+ Bind([](bool* task_ran) { *task_ran = true; },
+ Unretained(task_ran)));
+ },
+ Unretained(&task_ran)));
+ RunLoop().RunUntilIdle();
+ EXPECT_TRUE(task_ran);
+}
+
} // namespace test
} // namespace base
« no previous file with comments | « base/test/scoped_task_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698