| 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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 } else if (failureStep == ResponseStep.ON_STREAM_READY) { | 1193 } else if (failureStep == ResponseStep.ON_STREAM_READY) { |
| 1194 assertNotNull(metrics.getRequestStart()); | 1194 assertNotNull(metrics.getRequestStart()); |
| 1195 MetricsTestUtil.assertAfter(metrics.getRequestStart(), startTime); | 1195 MetricsTestUtil.assertAfter(metrics.getRequestStart(), startTime); |
| 1196 assertNotNull(metrics.getRequestEnd()); | 1196 assertNotNull(metrics.getRequestEnd()); |
| 1197 MetricsTestUtil.assertAfter(endTime, metrics.getRequestEnd()); | 1197 MetricsTestUtil.assertAfter(endTime, metrics.getRequestEnd()); |
| 1198 // Entire request should take more than 0 ms | 1198 // Entire request should take more than 0 ms |
| 1199 assertTrue(metrics.getRequestEnd().getTime() - metrics.getRequestSta
rt().getTime() > 0); | 1199 assertTrue(metrics.getRequestEnd().getTime() - metrics.getRequestSta
rt().getTime() > 0); |
| 1200 } | 1200 } |
| 1201 assertEquals(expectError, callback.mError != null); | 1201 assertEquals(expectError, callback.mError != null); |
| 1202 assertEquals(expectError, callback.mOnErrorCalled); | 1202 assertEquals(expectError, callback.mOnErrorCalled); |
| 1203 if (expectError) { |
| 1204 assertNotNull(finishedInfo.getException()); |
| 1205 assertEquals(RequestFinishedInfo.FAILED, finishedInfo.getFinishedRea
son()); |
| 1206 } else { |
| 1207 assertNull(finishedInfo.getException()); |
| 1208 assertEquals(RequestFinishedInfo.CANCELED, finishedInfo.getFinishedR
eason()); |
| 1209 } |
| 1203 assertEquals(failureType == FailureType.CANCEL_SYNC | 1210 assertEquals(failureType == FailureType.CANCEL_SYNC |
| 1204 || failureType == FailureType.CANCEL_ASYNC | 1211 || failureType == FailureType.CANCEL_ASYNC |
| 1205 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, | 1212 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
, |
| 1206 callback.mOnCanceledCalled); | 1213 callback.mOnCanceledCalled); |
| 1207 mTestFramework.mCronetEngine.removeRequestFinishedListener(requestFinish
edListener); | 1214 mTestFramework.mCronetEngine.removeRequestFinishedListener(requestFinish
edListener); |
| 1208 } | 1215 } |
| 1209 | 1216 |
| 1210 @SmallTest | 1217 @SmallTest |
| 1211 @Feature({"Cronet"}) | 1218 @Feature({"Cronet"}) |
| 1212 @OnlyRunNativeCronet | 1219 @OnlyRunNativeCronet |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 private static String bufferContentsToString(ByteBuffer byteBuffer, int star
t, int end) { | 1425 private static String bufferContentsToString(ByteBuffer byteBuffer, int star
t, int end) { |
| 1419 // Use a duplicate to avoid modifying byteBuffer. | 1426 // Use a duplicate to avoid modifying byteBuffer. |
| 1420 ByteBuffer duplicate = byteBuffer.duplicate(); | 1427 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1421 duplicate.position(start); | 1428 duplicate.position(start); |
| 1422 duplicate.limit(end); | 1429 duplicate.limit(end); |
| 1423 byte[] contents = new byte[duplicate.remaining()]; | 1430 byte[] contents = new byte[duplicate.remaining()]; |
| 1424 duplicate.get(contents); | 1431 duplicate.get(contents); |
| 1425 return new String(contents); | 1432 return new String(contents); |
| 1426 } | 1433 } |
| 1427 } | 1434 } |
| OLD | NEW |