Commit e6bd6af8 authored by Alex Clarke's avatar Alex Clarke Committed by Commit Bot

Fix flakes in ImageWriterWriteFromUrlOperationTest.VerifyFile

USER_VISIBLE tasks on the UI thread are now run at a lower priority
than default / USER_BLOCKING tasks.  This caused the test to become
flaky because it runs 100 USER_VISIBLE tasks to call OnProgress
but the QuitClocure task is run at USER_BLOCKING priority so
occasionally it can run too soon.  This patch fixes that by running
the Quit at USER_VISIBLE priority.

Change-Id: I93bc93c9c583b160aa1ff4326a021c432eab525a
BUG: 863341
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1697204
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676874}
parent 947c6ce5
...@@ -238,7 +238,18 @@ TEST_F(ImageWriterWriteFromUrlOperationTest, DISABLED_VerifyFile) { ...@@ -238,7 +238,18 @@ TEST_F(ImageWriterWriteFromUrlOperationTest, DISABLED_VerifyFile) {
operation->SetImagePath(test_utils_.GetImagePath()); operation->SetImagePath(test_utils_.GetImagePath());
{ {
base::RunLoop run_loop; base::RunLoop run_loop;
operation->VerifyDownload(run_loop.QuitClosure()); // The OnProgress tasks are posted with priority USER_VISIBLE priority so
// post the quit closure with the same priority to ensure it doesn't run too
// soon.
operation->VerifyDownload(base::Bind(
[](base::OnceClosure quit_closure) {
base::PostTaskWithTraits(
FROM_HERE,
{content::BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
std::move(quit_closure));
},
run_loop.QuitClosure()));
run_loop.Run(); run_loop.Run();
} }
......
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