| 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 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.Feature; | 11 import org.chromium.base.test.util.Feature; |
| 11 import org.chromium.net.CronetTestBase.OnlyRunNativeCronet; | 12 import org.chromium.net.CronetTestBase.OnlyRunNativeCronet; |
| 12 import org.chromium.net.TestBidirectionalStreamCallback.FailureType; | 13 import org.chromium.net.TestBidirectionalStreamCallback.FailureType; |
| 13 import org.chromium.net.TestBidirectionalStreamCallback.ResponseStep; | 14 import org.chromium.net.TestBidirectionalStreamCallback.ResponseStep; |
| 14 | 15 |
| 15 import java.nio.ByteBuffer; | 16 import java.nio.ByteBuffer; |
| 16 import java.util.AbstractMap; | 17 import java.util.AbstractMap; |
| 17 import java.util.ArrayList; | 18 import java.util.ArrayList; |
| 18 import java.util.Arrays; | 19 import java.util.Arrays; |
| 19 import java.util.List; | 20 import java.util.List; |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 stream.start(); | 544 stream.start(); |
| 544 callback.blockForDone(); | 545 callback.blockForDone(); |
| 545 assertTrue(stream.isDone()); | 546 assertTrue(stream.isDone()); |
| 546 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); | 547 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); |
| 547 assertEquals("12", callback.mResponseAsString); | 548 assertEquals("12", callback.mResponseAsString); |
| 548 } | 549 } |
| 549 | 550 |
| 550 @SmallTest | 551 @SmallTest |
| 551 @Feature({"Cronet"}) | 552 @Feature({"Cronet"}) |
| 552 @OnlyRunNativeCronet | 553 @OnlyRunNativeCronet |
| 554 // Disabled due to timeout. See crbug.com/591112 |
| 555 @DisabledTest |
| 553 public void testReadAndWrite() throws Exception { | 556 public void testReadAndWrite() throws Exception { |
| 554 String url = Http2TestServer.getEchoStreamUrl(); | 557 String url = Http2TestServer.getEchoStreamUrl(); |
| 555 TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCa
llback() { | 558 TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCa
llback() { |
| 556 @Override | 559 @Override |
| 557 public void onResponseHeadersReceived( | 560 public void onResponseHeadersReceived( |
| 558 BidirectionalStream stream, UrlResponseInfo info) { | 561 BidirectionalStream stream, UrlResponseInfo info) { |
| 559 // Start the write, that will not complete until callback comple
tion. | 562 // Start the write, that will not complete until callback comple
tion. |
| 560 startNextWrite(stream); | 563 startNextWrite(stream); |
| 561 // Start the read. It is allowed with write in flight. | 564 // Start the read. It is allowed with write in flight. |
| 562 super.onResponseHeadersReceived(stream, info); | 565 super.onResponseHeadersReceived(stream, info); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 private static String bufferContentsToString(ByteBuffer byteBuffer, int star
t, int end) { | 1044 private static String bufferContentsToString(ByteBuffer byteBuffer, int star
t, int end) { |
| 1042 // Use a duplicate to avoid modifying byteBuffer. | 1045 // Use a duplicate to avoid modifying byteBuffer. |
| 1043 ByteBuffer duplicate = byteBuffer.duplicate(); | 1046 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1044 duplicate.position(start); | 1047 duplicate.position(start); |
| 1045 duplicate.limit(end); | 1048 duplicate.limit(end); |
| 1046 byte[] contents = new byte[duplicate.remaining()]; | 1049 byte[] contents = new byte[duplicate.remaining()]; |
| 1047 duplicate.get(contents); | 1050 duplicate.get(contents); |
| 1048 return new String(contents); | 1051 return new String(contents); |
| 1049 } | 1052 } |
| 1050 } | 1053 } |
| OLD | NEW |