Speculative fix for flakiness in ImageWriterWriteFromUrlOperationTest.VerifyFile.

Bug: 983061
Change-Id: Ic1060829f3eb5efb17055e16890c037b85750be8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1699129
Reviewed-by: Toni Baržić <tbarzic@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676981}
diff --git a/chrome/browser/extensions/api/image_writer_private/write_from_url_operation_unittest.cc b/chrome/browser/extensions/api/image_writer_private/write_from_url_operation_unittest.cc
index e934dea6..bcb23055 100644
--- a/chrome/browser/extensions/api/image_writer_private/write_from_url_operation_unittest.cc
+++ b/chrome/browser/extensions/api/image_writer_private/write_from_url_operation_unittest.cc
@@ -212,7 +212,7 @@
   operation->Cancel();
 }
 
-TEST_F(ImageWriterWriteFromUrlOperationTest, DISABLED_VerifyFile) {
+TEST_F(ImageWriterWriteFromUrlOperationTest, VerifyFile) {
   std::unique_ptr<char[]> data_buffer(new char[kTestFileSize]);
   base::ReadFile(test_utils_.GetImagePath(), data_buffer.get(), kTestFileSize);
   base::MD5Digest expected_digest;
@@ -254,6 +254,14 @@
   }
 
   operation->Cancel();
+
+  // The OnProgress calls we're expecting are posted to the Operation's
+  // SequencedTaskRunner. Flush it before the mock's expectations are checked.
+  {
+    base::RunLoop run_loop;
+    operation->PostTask(run_loop.QuitClosure());
+    run_loop.Run();
+  }
 }
 
 }  // namespace image_writer