Commit 503953d4 authored by Owen Min's avatar Owen Min Committed by Commit Bot

Revert "Run pending tasks in ~TestBrowserThreadBundle."

This reverts commit 1c3948d8.

Reason for revert: The patch caused multiple content_unittest flaky.
https://bugs.chromium.org/p/chromium/issues/detail?id=938126
This CL could be relanded once these flaky tests are fixed or disabled.

Original change's description:
> Run pending tasks in ~TestBrowserThreadBundle.
> 
> This makes sure we run all remaining tasks in tests. This should be the
> case even for ExecutionMode::QUEUED as documented here:
> https://cs.chromium.org/chromium/src/base/test/scoped_task_environment.h?l=42
> 
> Also lift the restriction to only flush tasks in !MOCK_TIME && !QUEUED modes
> which is unnecessary now that TestBrowserThreadBundle is-a
> ScopedTaskEnvironment (http://crrev.com/616622).
> 
> Bug: 708584
> Change-Id: I52773e27d3875bd246bb1cd7eea92c9e11fc70bf
> Reviewed-on: https://chromium-review.googlesource.com/c/1480460
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#637288}

TBR=gab@chromium.org,knollr@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 708584
Bug: 938126
Change-Id: I8b43a5c90b8f28eee2817a94cd556b2742e2f58c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1503993Reviewed-by: default avatarOwen Min <zmin@chromium.org>
Commit-Queue: Owen Min <zmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637760}
parent 3811c16d
......@@ -31,27 +31,32 @@
namespace content {
TestBrowserThreadBundle::~TestBrowserThreadBundle() {
// This is required to ensure we run all remaining MessageLoop and
// TaskScheduler tasks in an atomic step. This is a bit different than
// production where the main thread is not flushed after it's done running
// but this approach is preferred in unit tests as running more tasks can
// merely uncover more issues (e.g. if a bad tasks is posted but never
// blocked upon it could make a test flaky whereas by flushing we guarantee
// it will blow up).
RunUntilIdle();
// When REAL_IO_THREAD, we need to stop the IO thread explicitly and flush
// again.
if (real_io_thread_) {
io_thread_->Stop();
RunUntilIdle();
// To ensure a clean teardown, each thread's message loop must be flushed
// just before the thread is destroyed. But stopping a fake thread does not
// automatically flush the message loop, so we have to do it manually.
// See http://crbug.com/247525 for discussion.
base::RunLoop().RunUntilIdle();
io_thread_->Stop();
base::RunLoop().RunUntilIdle();
ui_thread_->Stop();
base::RunLoop().RunUntilIdle();
// Skip the following steps when RunAllTasksUntilIdle might result in a hang
// (ExecutionMode::QUEUED) or for MainThreadType::MOCK_TIME where we haven't
// enforced there being no pending tasks.
if (main_thread_type() != MainThreadType::MOCK_TIME &&
execution_control_mode() != ExecutionMode::QUEUED) {
// This is required to ensure we run all remaining MessageLoop and
// TaskScheduler tasks in an atomic step. This is a bit different than
// production where the main thread is not flushed after it's done running
// but this approach is preferred in unit tests as running more tasks can
// merely uncover more issues (e.g. if a bad tasks is posted but never
// blocked upon it could make a test flaky whereas by flushing we guarantee
// it will blow up).
RunAllTasksUntilIdle();
CHECK(MainThreadIsIdle()) << sequence_manager()->DescribeAllPendingTasks();
}
// The only way this check can fail after RunUntilIdle() is if a test is
// running its own base::Thread's. Such tests should make sure to coalesce
// independent threads before this point.
CHECK(MainThreadIsIdle()) << sequence_manager()->DescribeAllPendingTasks();
BrowserTaskExecutor::ResetForTesting();
// Run DestructionObservers before our fake threads go away to ensure
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment