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

Unified Diff: content/public/test/test_utils.cc

Issue 2750823002: Flush TaskScheduler in content::RunAllBlockingPoolTasksUntilIdle(). (Closed)
Patch Set: fix test error Created 3 years, 9 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 | « content/public/test/test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/test_utils.cc
diff --git a/content/public/test/test_utils.cc b/content/public/test/test_utils.cc
index 4afe2321e9f3f4c021831dc3857db3582e9991a7..7559e32b3652175d8ac891308925af3d59ce363f 100644
--- a/content/public/test/test_utils.cc
+++ b/content/public/test/test_utils.cc
@@ -13,6 +13,7 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/task_scheduler/task_scheduler.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
@@ -159,8 +160,16 @@ void RunAllBlockingPoolTasksUntilIdle() {
while (true) {
content::BrowserThread::GetBlockingPool()->FlushForTesting();
+ // Setup a task observer to determine if MessageLoop tasks run in the
+ // current loop iteration. This must be done before
+ // TaskScheduler::FlushForTesting() since this may spin the MessageLoop.
TaskObserver task_observer;
base::MessageLoop::current()->AddTaskObserver(&task_observer);
+
+ // Since all blocking pool call sites are being migrated to TaskScheduler,
+ // flush TaskScheduler in addition to the blocking pool.
+ base::TaskScheduler::GetInstance()->FlushForTesting();
+
base::RunLoop().RunUntilIdle();
base::MessageLoop::current()->RemoveTaskObserver(&task_observer);
« no previous file with comments | « content/public/test/test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698