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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.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: Address comment 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/CronetChunkedOutputStreamTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java
index a7df1c01f2a3dea60c23d53761d1f5080fb7438f..8cff9ddfc33c73b47f6dca7209a7c3d2f1b498c8 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java
@@ -10,6 +10,7 @@ import org.chromium.base.test.util.Feature;
import org.chromium.net.CronetTestBase;
import org.chromium.net.CronetTestFramework;
import org.chromium.net.NativeTestServer;
+import org.chromium.net.UrlRequestException;
import java.io.IOException;
import java.io.OutputStream;
@@ -87,6 +88,33 @@ public class CronetChunkedOutputStreamTest extends CronetTestBase {
@SmallTest
@Feature({"Cronet"})
@CompareDefaultWithCronet
+ public void testWriteAfterRequestFailed() throws Exception {
+ URL url = new URL(NativeTestServer.getEchoBodyURL());
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ connection.setChunkedStreamingMode(0);
+ OutputStream out = connection.getOutputStream();
+ out.write(UPLOAD_DATA);
+ NativeTestServer.shutdownNativeTestServer();
+ try {
+ out.write(TestUtil.getLargeData());
+ connection.getResponseCode();
+ fail();
+ } catch (IOException e) {
+ if (!testingSystemHttpURLConnection()) {
+ UrlRequestException requestException = (UrlRequestException) e;
+ assertEquals(UrlRequestException.ERROR_CONNECTION_REFUSED,
+ requestException.getErrorCode());
+ }
+ }
+ // Restarting server to run the test for a second time.
+ assertTrue(NativeTestServer.startNativeTestServer(getContext()));
+ }
+
+ @SmallTest
+ @Feature({"Cronet"})
+ @CompareDefaultWithCronet
public void testPost() throws Exception {
URL url = new URL(NativeTestServer.getEchoBodyURL());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

Powered by Google App Engine
This is Rietveld 408576698