Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/BidirectionalStreamTest.java

Issue 2422993004: Implement finished reason and exception for BidirectionalStream (Closed)
Patch Set: Change IllegalStateException to asserts Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698