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

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/BidirectionalStreamTest.java

Issue 1992953004: [Cronet] Make delaying sending request headers explicit in bidirectional stream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.os.ConditionVariable; 7 import android.os.ConditionVariable;
8 import android.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 9
10 import org.chromium.base.test.util.DisabledTest; 10 import org.chromium.base.test.util.DisabledTest;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 assertEquals("Test String1234567890woot!", callback.mResponseAsString); 261 assertEquals("Test String1234567890woot!", callback.mResponseAsString);
262 assertEquals("bar", callback.mResponseInfo.getAllHeaders().get("echo-foo ").get(0)); 262 assertEquals("bar", callback.mResponseInfo.getAllHeaders().get("echo-foo ").get(0));
263 assertEquals("", callback.mResponseInfo.getAllHeaders().get("echo-empty" ).get(0)); 263 assertEquals("", callback.mResponseInfo.getAllHeaders().get("echo-empty" ).get(0));
264 assertEquals( 264 assertEquals(
265 "zebra", callback.mResponseInfo.getAllHeaders().get("echo-conten t-type").get(0)); 265 "zebra", callback.mResponseInfo.getAllHeaders().get("echo-conten t-type").get(0));
266 } 266 }
267 267
268 @SmallTest 268 @SmallTest
269 @Feature({"Cronet"}) 269 @Feature({"Cronet"})
270 @OnlyRunNativeCronet 270 @OnlyRunNativeCronet
271 public void testSimplePostWithFlushAfterOneWrite() throws Exception {
272 String url = Http2TestServer.getEchoStreamUrl();
273 TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCa llback();
274 callback.addWriteData("Test String".getBytes(), true);
275 BidirectionalStream stream = new BidirectionalStream
276 .Builder(url, callback, callback.ge tExecutor(),
277 mTestFramework.mCronetEngin e)
278 .disableAutoFlush(true)
279 .addHeader("foo", "bar")
280 .addHeader("empty", "")
281 .addHeader("Content-Type", "zebra")
282 .build();
283 stream.start();
284 callback.blockForDone();
285 assertTrue(stream.isDone());
286
287 assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
288 assertEquals("Test String", callback.mResponseAsString);
289 assertEquals("bar", callback.mResponseInfo.getAllHeaders().get("echo-foo ").get(0));
290 assertEquals("", callback.mResponseInfo.getAllHeaders().get("echo-empty" ).get(0));
291 assertEquals(
292 "zebra", callback.mResponseInfo.getAllHeaders().get("echo-conten t-type").get(0));
293 }
294
295 @SmallTest
296 @Feature({"Cronet"})
297 @OnlyRunNativeCronet
271 public void testSimplePostWithFlushTwice() throws Exception { 298 public void testSimplePostWithFlushTwice() throws Exception {
272 String url = Http2TestServer.getEchoStreamUrl(); 299 String url = Http2TestServer.getEchoStreamUrl();
273 TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCa llback(); 300 TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCa llback();
274 callback.addWriteData("Test String".getBytes(), false); 301 callback.addWriteData("Test String".getBytes(), false);
275 callback.addWriteData("1234567890".getBytes(), false); 302 callback.addWriteData("1234567890".getBytes(), false);
276 callback.addWriteData("woot!".getBytes(), true); 303 callback.addWriteData("woot!".getBytes(), true);
277 callback.addWriteData("Test String".getBytes(), false); 304 callback.addWriteData("Test String".getBytes(), false);
278 callback.addWriteData("1234567890".getBytes(), false); 305 callback.addWriteData("1234567890".getBytes(), false);
279 callback.addWriteData("woot!".getBytes(), true); 306 callback.addWriteData("woot!".getBytes(), true);
280 BidirectionalStream stream = new BidirectionalStream 307 BidirectionalStream stream = new BidirectionalStream
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 private static String bufferContentsToString(ByteBuffer byteBuffer, int star t, int end) { 1215 private static String bufferContentsToString(ByteBuffer byteBuffer, int star t, int end) {
1189 // Use a duplicate to avoid modifying byteBuffer. 1216 // Use a duplicate to avoid modifying byteBuffer.
1190 ByteBuffer duplicate = byteBuffer.duplicate(); 1217 ByteBuffer duplicate = byteBuffer.duplicate();
1191 duplicate.position(start); 1218 duplicate.position(start);
1192 duplicate.limit(end); 1219 duplicate.limit(end);
1193 byte[] contents = new byte[duplicate.remaining()]; 1220 byte[] contents = new byte[duplicate.remaining()];
1194 duplicate.get(contents); 1221 duplicate.get(contents);
1195 return new String(contents); 1222 return new String(contents);
1196 } 1223 }
1197 } 1224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698