| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.FlakyTest; |
| 8 import android.test.MoreAsserts; | 9 import android.test.MoreAsserts; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
| 10 import android.util.Log; | 11 import android.util.Log; |
| 11 | 12 |
| 12 import org.chromium.base.test.util.Feature; | 13 import org.chromium.base.test.util.Feature; |
| 13 import org.chromium.net.TestUrlRequestCallback.FailureType; | 14 import org.chromium.net.TestUrlRequestCallback.FailureType; |
| 14 import org.chromium.net.TestUrlRequestCallback.ResponseStep; | 15 import org.chromium.net.TestUrlRequestCallback.ResponseStep; |
| 15 import org.chromium.net.test.FailurePhase; | 16 import org.chromium.net.test.FailurePhase; |
| 16 | 17 |
| 17 import java.net.ConnectException; | 18 import java.net.ConnectException; |
| (...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 assertTrue(urlRequest.isDone()); | 1442 assertTrue(urlRequest.isDone()); |
| 1442 assertEquals(expectResponseInfo, callback.mResponseInfo != null); | 1443 assertEquals(expectResponseInfo, callback.mResponseInfo != null); |
| 1443 assertEquals(expectError, callback.mError != null); | 1444 assertEquals(expectError, callback.mError != null); |
| 1444 assertEquals(expectError, callback.mOnErrorCalled); | 1445 assertEquals(expectError, callback.mOnErrorCalled); |
| 1445 assertEquals(failureType == FailureType.CANCEL_SYNC | 1446 assertEquals(failureType == FailureType.CANCEL_SYNC |
| 1446 || failureType == FailureType.CANCEL_ASYNC | 1447 || failureType == FailureType.CANCEL_ASYNC |
| 1447 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, | 1448 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, |
| 1448 callback.mOnCanceledCalled); | 1449 callback.mOnCanceledCalled); |
| 1449 } | 1450 } |
| 1450 | 1451 |
| 1452 /* |
| 1451 @SmallTest | 1453 @SmallTest |
| 1452 @Feature({"Cronet"}) | 1454 @Feature({"Cronet"}) |
| 1455 https://crbug.com/592444 |
| 1456 */ |
| 1457 @FlakyTest |
| 1453 public void testFailures() throws Exception { | 1458 public void testFailures() throws Exception { |
| 1454 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT
, | 1459 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT
, |
| 1455 false, false); | 1460 false, false); |
| 1456 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC
T, | 1461 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC
T, |
| 1457 false, false); | 1462 false, false); |
| 1458 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE
CEIVED_REDIRECT, | 1463 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE
CEIVED_REDIRECT, |
| 1459 false, false); | 1464 false, false); |
| 1460 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_RECEIVED_REDIRECT, | 1465 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_RECEIVED_REDIRECT, |
| 1461 false, true); | 1466 false, true); |
| 1462 | 1467 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int
end) { | 1677 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int
end) { |
| 1673 // Use a duplicate to avoid modifying byteBuffer. | 1678 // Use a duplicate to avoid modifying byteBuffer. |
| 1674 ByteBuffer duplicate = byteBuffer.duplicate(); | 1679 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1675 duplicate.position(start); | 1680 duplicate.position(start); |
| 1676 duplicate.limit(end); | 1681 duplicate.limit(end); |
| 1677 byte[] contents = new byte[duplicate.remaining()]; | 1682 byte[] contents = new byte[duplicate.remaining()]; |
| 1678 duplicate.get(contents); | 1683 duplicate.get(contents); |
| 1679 return new String(contents); | 1684 return new String(contents); |
| 1680 } | 1685 } |
| 1681 } | 1686 } |
| OLD | NEW |