[net] Fix URLRequestTestHTTP.TestPostChunkedDataAfterStart
The test was calling TestDelegate.RunUntilComplete() after writing some
data to a ChunkedUploadDataStream::Writer. However, the final write may
itself result in the request being completed. The resulting
TestDelegate::OnResponseCompleted() doesn't have a message loop to kill.
Therefore, we now create a RunLoop and set the OnResponseCompleted
closure so that an early completion will correctly mark the RunLoop as
done.
Bug: 873851
Change-Id: If67eaa1d141b0b3ee046d428a778106aa2287214
Reviewed-on: https://chromium-review.googlesource.com/1176632
Reviewed-by: Matt Menke <[email protected]>
Commit-Queue: Asanka Herath <[email protected]>
Cr-Commit-Position: refs/heads/master@{#583712}
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 03702a71..4a58166e 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -6706,14 +6706,7 @@
}
}
-#if defined(OS_CHROMEOS)
-// https://crbug.com/873851.
-#define MAYBE_TestPostChunkedDataAfterStart \
- DISABLED_TestPostChunkedDataAfterStart
-#else
-#define MAYBE_TestPostChunkedDataAfterStart TestPostChunkedDataAfterStart
-#endif
-TEST_F(URLRequestTestHTTP, MAYBE_TestPostChunkedDataAfterStart) {
+TEST_F(URLRequestTestHTTP, TestPostChunkedDataAfterStart) {
ASSERT_TRUE(http_test_server()->Start());
TestDelegate d;
@@ -6730,9 +6723,14 @@
r->Start();
EXPECT_TRUE(r->is_pending());
+ // Pump messages until we start sending headers..
base::RunLoop().RunUntilIdle();
+
+ // And now wait for completion.
+ base::RunLoop run_loop;
+ d.set_on_complete(run_loop.QuitClosure());
AddDataToUpload(writer.get());
- d.RunUntilComplete();
+ run_loop.Run();
VerifyReceivedDataMatchesChunks(r.get(), &d);
}