| OLD | NEW |
| 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 static org.chromium.base.CollectionUtil.newHashSet; | 7 import static org.chromium.base.CollectionUtil.newHashSet; |
| 8 | 8 |
| 9 import android.os.ConditionVariable; | 9 import android.os.ConditionVariable; |
| 10 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 String url = "http://example.com"; | 194 String url = "http://example.com"; |
| 195 TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCa
llback(); | 195 TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCa
llback(); |
| 196 // Create stream. | 196 // Create stream. |
| 197 BidirectionalStream stream = | 197 BidirectionalStream stream = |
| 198 mTestFramework.mCronetEngine | 198 mTestFramework.mCronetEngine |
| 199 .newBidirectionalStreamBuilder(url, callback, callback.g
etExecutor()) | 199 .newBidirectionalStreamBuilder(url, callback, callback.g
etExecutor()) |
| 200 .build(); | 200 .build(); |
| 201 stream.start(); | 201 stream.start(); |
| 202 callback.blockForDone(); | 202 callback.blockForDone(); |
| 203 assertTrue(stream.isDone()); | 203 assertTrue(stream.isDone()); |
| 204 assertEquals("Exception in BidirectionalStream: net::ERR_DISALLOWED_URL_
SCHEME", | 204 assertContains("Exception in BidirectionalStream: net::ERR_DISALLOWED_UR
L_SCHEME", |
| 205 callback.mError.getMessage()); | 205 callback.mError.getMessage()); |
| 206 assertEquals(-301, callback.mError.getCronetInternalErrorCode()); | 206 assertEquals(-301, callback.mError.getCronetInternalErrorCode()); |
| 207 } | 207 } |
| 208 | 208 |
| 209 @SmallTest | 209 @SmallTest |
| 210 @Feature({"Cronet"}) | 210 @Feature({"Cronet"}) |
| 211 @OnlyRunNativeCronet | 211 @OnlyRunNativeCronet |
| 212 public void testSimpleGet() throws Exception { | 212 public void testSimpleGet() throws Exception { |
| 213 // Since this is the first request on the connection, the expected recei
ved bytes count | 213 // Since this is the first request on the connection, the expected recei
ved bytes count |
| 214 // must account for an HPACK dynamic table size update. | 214 // must account for an HPACK dynamic table size update. |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 private static String bufferContentsToString(ByteBuffer byteBuffer, int star
t, int end) { | 1450 private static String bufferContentsToString(ByteBuffer byteBuffer, int star
t, int end) { |
| 1451 // Use a duplicate to avoid modifying byteBuffer. | 1451 // Use a duplicate to avoid modifying byteBuffer. |
| 1452 ByteBuffer duplicate = byteBuffer.duplicate(); | 1452 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1453 duplicate.position(start); | 1453 duplicate.position(start); |
| 1454 duplicate.limit(end); | 1454 duplicate.limit(end); |
| 1455 byte[] contents = new byte[duplicate.remaining()]; | 1455 byte[] contents = new byte[duplicate.remaining()]; |
| 1456 duplicate.get(contents); | 1456 duplicate.get(contents); |
| 1457 return new String(contents); | 1457 return new String(contents); |
| 1458 } | 1458 } |
| 1459 } | 1459 } |
| OLD | NEW |