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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java

Issue 2131323002: [Cronet] Check whether request is done before spinning up message loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 4 years, 5 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
Index: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
index 81eb364bb1f16e1235d0e560e051621cf8d782e8..965005051e5c1ef3714f4bac0f978af3d60e1f00 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
@@ -11,6 +11,7 @@ import org.chromium.net.CronetTestBase;
import org.chromium.net.CronetTestFramework;
import org.chromium.net.NativeTestServer;
+import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpRetryException;
import java.net.HttpURLConnection;
@@ -66,8 +67,31 @@ public class CronetFixedModeOutputStreamTest extends CronetTestBase {
@SmallTest
@Feature({"Cronet"})
@CompareDefaultWithCronet
- public void testFixedLengthStreamingModeZeroContentLength()
- throws Exception {
+ public void testWriteAfterRequestFailed() throws Exception {
+ URL url = new URL(NativeTestServer.getEchoBodyURL());
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ byte[] largeData = TestUtil.getLargeData();
+ connection.setFixedLengthStreamingMode(largeData.length);
+ OutputStream out = connection.getOutputStream();
+ out.write(largeData, 0, 10);
+ NativeTestServer.shutdownNativeTestServer();
+ try {
+ out.write(largeData, 10, largeData.length - 10);
+ connection.getResponseCode();
+ fail();
+ } catch (IOException e) {
+ // Expected.
+ }
+ // Restarting server to run the test for a second time.
+ assertTrue(NativeTestServer.startNativeTestServer(getContext()));
+ }
+
+ @SmallTest
+ @Feature({"Cronet"})
+ @CompareDefaultWithCronet
+ public void testFixedLengthStreamingModeZeroContentLength() throws Exception {
// Check content length is set.
URL echoLength = new URL(NativeTestServer.getEchoHeaderURL("Content-Length"));
HttpURLConnection connection1 =

Powered by Google App Engine
This is Rietveld 408576698