| 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; | |
| 9 import android.test.MoreAsserts; | 8 import android.test.MoreAsserts; |
| 10 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 11 import android.util.Log; | 10 import android.util.Log; |
| 12 | 11 |
| 13 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
| 13 import org.chromium.base.test.util.FlakyTest; |
| 14 import org.chromium.net.TestUrlRequestCallback.FailureType; | 14 import org.chromium.net.TestUrlRequestCallback.FailureType; |
| 15 import org.chromium.net.TestUrlRequestCallback.ResponseStep; | 15 import org.chromium.net.TestUrlRequestCallback.ResponseStep; |
| 16 import org.chromium.net.test.FailurePhase; | 16 import org.chromium.net.test.FailurePhase; |
| 17 | 17 |
| 18 import java.io.IOException; | 18 import java.io.IOException; |
| 19 import java.net.ConnectException; | 19 import java.net.ConnectException; |
| 20 import java.nio.ByteBuffer; | 20 import java.nio.ByteBuffer; |
| 21 import java.util.AbstractMap; | 21 import java.util.AbstractMap; |
| 22 import java.util.ArrayList; | 22 import java.util.ArrayList; |
| 23 import java.util.Arrays; | 23 import java.util.Arrays; |
| (...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1512 assertEquals(expectError, callback.mOnErrorCalled); | 1512 assertEquals(expectError, callback.mOnErrorCalled); |
| 1513 assertEquals(failureType == FailureType.CANCEL_SYNC | 1513 assertEquals(failureType == FailureType.CANCEL_SYNC |
| 1514 || failureType == FailureType.CANCEL_ASYNC | 1514 || failureType == FailureType.CANCEL_ASYNC |
| 1515 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, | 1515 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, |
| 1516 callback.mOnCanceledCalled); | 1516 callback.mOnCanceledCalled); |
| 1517 } | 1517 } |
| 1518 | 1518 |
| 1519 /* | 1519 /* |
| 1520 @SmallTest | 1520 @SmallTest |
| 1521 @Feature({"Cronet"}) | 1521 @Feature({"Cronet"}) |
| 1522 https://crbug.com/592444 | |
| 1523 */ | 1522 */ |
| 1524 @FlakyTest | 1523 @FlakyTest(message = "https://crbug.com/592444") |
| 1525 public void testFailures() throws Exception { | 1524 public void testFailures() throws Exception { |
| 1526 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT
, | 1525 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT
, |
| 1527 false, false); | 1526 false, false); |
| 1528 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC
T, | 1527 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC
T, |
| 1529 false, false); | 1528 false, false); |
| 1530 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE
CEIVED_REDIRECT, | 1529 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE
CEIVED_REDIRECT, |
| 1531 false, false); | 1530 false, false); |
| 1532 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_RECEIVED_REDIRECT, | 1531 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_RECEIVED_REDIRECT, |
| 1533 false, true); | 1532 false, true); |
| 1534 | 1533 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int
end) { | 1763 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int
end) { |
| 1765 // Use a duplicate to avoid modifying byteBuffer. | 1764 // Use a duplicate to avoid modifying byteBuffer. |
| 1766 ByteBuffer duplicate = byteBuffer.duplicate(); | 1765 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1767 duplicate.position(start); | 1766 duplicate.position(start); |
| 1768 duplicate.limit(end); | 1767 duplicate.limit(end); |
| 1769 byte[] contents = new byte[duplicate.remaining()]; | 1768 byte[] contents = new byte[duplicate.remaining()]; |
| 1770 duplicate.get(contents); | 1769 duplicate.get(contents); |
| 1771 return new String(contents); | 1770 return new String(contents); |
| 1772 } | 1771 } |
| 1773 } | 1772 } |
| OLD | NEW |