| 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.MoreAsserts; | 8 import android.test.MoreAsserts; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 10 import android.util.Log; | 10 import android.util.Log; |
| 11 | 11 |
| 12 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; | 13 import org.chromium.net.TestUrlRequestCallback.FailureType; |
| 15 import org.chromium.net.TestUrlRequestCallback.ResponseStep; | 14 import org.chromium.net.TestUrlRequestCallback.ResponseStep; |
| 16 import org.chromium.net.impl.CronetUrlRequest; | 15 import org.chromium.net.impl.CronetUrlRequest; |
| 17 import org.chromium.net.test.FailurePhase; | 16 import org.chromium.net.test.FailurePhase; |
| 18 | 17 |
| 19 import java.io.IOException; | 18 import java.io.IOException; |
| 20 import java.net.ConnectException; | 19 import java.net.ConnectException; |
| 21 import java.nio.ByteBuffer; | 20 import java.nio.ByteBuffer; |
| 22 import java.util.AbstractMap; | 21 import java.util.AbstractMap; |
| 23 import java.util.ArrayList; | 22 import java.util.ArrayList; |
| (...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 assertTrue(urlRequest.isDone()); | 1545 assertTrue(urlRequest.isDone()); |
| 1547 assertEquals(expectResponseInfo, callback.mResponseInfo != null); | 1546 assertEquals(expectResponseInfo, callback.mResponseInfo != null); |
| 1548 assertEquals(expectError, callback.mError != null); | 1547 assertEquals(expectError, callback.mError != null); |
| 1549 assertEquals(expectError, callback.mOnErrorCalled); | 1548 assertEquals(expectError, callback.mOnErrorCalled); |
| 1550 assertEquals(failureType == FailureType.CANCEL_SYNC | 1549 assertEquals(failureType == FailureType.CANCEL_SYNC |
| 1551 || failureType == FailureType.CANCEL_ASYNC | 1550 || failureType == FailureType.CANCEL_ASYNC |
| 1552 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, | 1551 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, |
| 1553 callback.mOnCanceledCalled); | 1552 callback.mOnCanceledCalled); |
| 1554 } | 1553 } |
| 1555 | 1554 |
| 1556 /* | |
| 1557 @SmallTest | 1555 @SmallTest |
| 1558 @Feature({"Cronet"}) | 1556 @Feature({"Cronet"}) |
| 1559 */ | |
| 1560 @FlakyTest(message = "https://crbug.com/592444") | |
| 1561 public void testFailures() throws Exception { | 1557 public void testFailures() throws Exception { |
| 1562 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT
, | 1558 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT
, |
| 1563 false, false); | 1559 false, false); |
| 1564 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC
T, | 1560 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC
T, |
| 1565 false, false); | 1561 false, false); |
| 1566 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE
CEIVED_REDIRECT, | 1562 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE
CEIVED_REDIRECT, |
| 1567 false, false); | 1563 false, false); |
| 1568 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_RECEIVED_REDIRECT, | 1564 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_RECEIVED_REDIRECT, |
| 1569 false, true); | 1565 false, true); |
| 1570 | 1566 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int
end) { | 1813 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int
end) { |
| 1818 // Use a duplicate to avoid modifying byteBuffer. | 1814 // Use a duplicate to avoid modifying byteBuffer. |
| 1819 ByteBuffer duplicate = byteBuffer.duplicate(); | 1815 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1820 duplicate.position(start); | 1816 duplicate.position(start); |
| 1821 duplicate.limit(end); | 1817 duplicate.limit(end); |
| 1822 byte[] contents = new byte[duplicate.remaining()]; | 1818 byte[] contents = new byte[duplicate.remaining()]; |
| 1823 duplicate.get(contents); | 1819 duplicate.get(contents); |
| 1824 return new String(contents); | 1820 return new String(contents); |
| 1825 } | 1821 } |
| 1826 } | 1822 } |
| OLD | NEW |