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

Unified Diff: base/test/scoped_task_environment.h

Issue 2868093002: Add base::test::ScopedTaskEnvironment::RunUntilIdle(). (Closed)
Patch Set: Created 3 years, 7 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
Index: base/test/scoped_task_environment.h
diff --git a/base/test/scoped_task_environment.h b/base/test/scoped_task_environment.h
index 04b9c75b1bf10ff3b5c8df2b4cbcbe950f92fd30..7b7180ae83292b2ed67b47c906f4a8b257637b31 100644
--- a/base/test/scoped_task_environment.h
+++ b/base/test/scoped_task_environment.h
@@ -22,12 +22,14 @@ namespace test {
// ScopedTaskEnvironment.
//
// Tasks posted to the (Thread|Sequenced)TaskRunnerHandle run synchronously when
-// RunLoop::Run(UntilIdle) is called on the thread where the
-// ScopedTaskEnvironment lives.
+// RunLoop::Run(UntilIdle) or ScopedTaskEnvironment::RunUntilIdle is called on
robliao 2017/05/09 21:52:52 Nit: RunUntilIdle()
+// the thread where the ScopedTaskEnvironment lives.
//
// Tasks posted through base/task_scheduler/post_task.h run on dedicated threads
// as they are posted.
//
+// All methods of ScopedTaskEnvironment must be called from the same thread.
+//
// Usage:
//
// class MyTestFixture : public testing::Test {
@@ -66,6 +68,10 @@ class ScopedTaskEnvironment {
// the (Thread|Sequenced)TaskRunnerHandle.
~ScopedTaskEnvironment();
+ // Synchronously runs (Thread|Sequenced)TaskRunnerHandle tasks until no
+ // undelayed (Thread|Sequenced)TaskRunnerHandle or TaskScheduler tasks remain.
+ void RunUntilIdle();
+
private:
// Note: |message_loop_| is an implementation detail and will be replaced in
// the future, do NOT rely on the presence of a MessageLoop beyond

Powered by Google App Engine
This is Rietveld 408576698