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

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

Issue 2404923002: Fix BidirectionalStreamTest#testFailures flake (Closed)
Patch Set: self review 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 | « no previous file | 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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 if (failureStep == ResponseStep.ON_RESPONSE_STARTED 1190 if (failureStep == ResponseStep.ON_RESPONSE_STARTED
1191 || failureStep == ResponseStep.ON_READ_COMPLETED 1191 || failureStep == ResponseStep.ON_READ_COMPLETED
1192 || failureStep == ResponseStep.ON_TRAILERS) { 1192 || failureStep == ResponseStep.ON_TRAILERS) {
1193 // For steps after response headers are received, there will be 1193 // For steps after response headers are received, there will be
1194 // connect timing metrics. 1194 // connect timing metrics.
1195 MetricsTestUtil.checkTimingMetrics(metrics, startTime, endTime); 1195 MetricsTestUtil.checkTimingMetrics(metrics, startTime, endTime);
1196 MetricsTestUtil.checkHasConnectTiming(metrics, startTime, endTime, t rue); 1196 MetricsTestUtil.checkHasConnectTiming(metrics, startTime, endTime, t rue);
1197 assertTrue(metrics.getSentBytesCount() > 0); 1197 assertTrue(metrics.getSentBytesCount() > 0);
1198 assertTrue(metrics.getReceivedBytesCount() > 0); 1198 assertTrue(metrics.getReceivedBytesCount() > 0);
1199 } else if (failureStep == ResponseStep.ON_STREAM_READY) { 1199 } else if (failureStep == ResponseStep.ON_STREAM_READY) {
1200 // onStreamReady() happens before response headers are received, so
1201 // there is no connect timing metrics.
1202 assertNotNull(metrics.getRequestStart()); 1200 assertNotNull(metrics.getRequestStart());
1203 MetricsTestUtil.assertAfter(metrics.getRequestStart(), startTime); 1201 MetricsTestUtil.assertAfter(metrics.getRequestStart(), startTime);
1204 MetricsTestUtil.checkNoConnectTiming(metrics);
1205 // metrics.getResponseStart() can be null or non null
1206 // TODO(xunjieli): It's weird to have a null response start but a
1207 // non-null response end.
1208 assertNotNull(metrics.getRequestEnd()); 1202 assertNotNull(metrics.getRequestEnd());
1209 MetricsTestUtil.assertAfter(endTime, metrics.getRequestEnd()); 1203 MetricsTestUtil.assertAfter(endTime, metrics.getRequestEnd());
1210 // Entire request should take more than 0 ms 1204 // Entire request should take more than 0 ms
1211 assertTrue(metrics.getRequestEnd().getTime() - metrics.getRequestSta rt().getTime() > 0); 1205 assertTrue(metrics.getRequestEnd().getTime() - metrics.getRequestSta rt().getTime() > 0);
1212 } 1206 }
1213 assertEquals(expectError, callback.mError != null); 1207 assertEquals(expectError, callback.mError != null);
1214 assertEquals(expectError, callback.mOnErrorCalled); 1208 assertEquals(expectError, callback.mOnErrorCalled);
1215 assertEquals(failureType == FailureType.CANCEL_SYNC 1209 assertEquals(failureType == FailureType.CANCEL_SYNC
1216 || failureType == FailureType.CANCEL_ASYNC 1210 || failureType == FailureType.CANCEL_ASYNC
1217 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE , 1211 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE ,
1218 callback.mOnCanceledCalled); 1212 callback.mOnCanceledCalled);
1219 mTestFramework.mCronetEngine.removeRequestFinishedListener(requestFinish edListener); 1213 mTestFramework.mCronetEngine.removeRequestFinishedListener(requestFinish edListener);
1220 } 1214 }
1221 1215
1222 /*
1223 Disabled temporarily due to http://crbug.com/653654
1224
1225 @SmallTest 1216 @SmallTest
1226 @Feature({"Cronet"}) 1217 @Feature({"Cronet"})
1227 @OnlyRunNativeCronet 1218 @OnlyRunNativeCronet
1228 */
1229 @DisabledTest
1230 public void testFailures() throws Exception { 1219 public void testFailures() throws Exception {
1231 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_STREAM_READY, fal se); 1220 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_STREAM_READY, fal se);
1232 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_STREAM_READY, fa lse); 1221 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_STREAM_READY, fa lse);
1233 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_ST REAM_READY, false); 1222 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_ST REAM_READY, false);
1234 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_STREAM_READY, true ); 1223 throwOrCancel(FailureType.THROW_SYNC, ResponseStep.ON_STREAM_READY, true );
1235 1224
1236 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RESPONSE_STARTED, false); 1225 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RESPONSE_STARTED, false);
1237 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RESPONSE_STARTED , false); 1226 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RESPONSE_STARTED , false);
1238 throwOrCancel( 1227 throwOrCancel(
1239 FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RESPONSE _STARTED, false); 1228 FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RESPONSE _STARTED, false);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 private static String bufferContentsToString(ByteBuffer byteBuffer, int star t, int end) { 1424 private static String bufferContentsToString(ByteBuffer byteBuffer, int star t, int end) {
1436 // Use a duplicate to avoid modifying byteBuffer. 1425 // Use a duplicate to avoid modifying byteBuffer.
1437 ByteBuffer duplicate = byteBuffer.duplicate(); 1426 ByteBuffer duplicate = byteBuffer.duplicate();
1438 duplicate.position(start); 1427 duplicate.position(start);
1439 duplicate.limit(end); 1428 duplicate.limit(end);
1440 byte[] contents = new byte[duplicate.remaining()]; 1429 byte[] contents = new byte[duplicate.remaining()];
1441 duplicate.get(contents); 1430 duplicate.get(contents);
1442 return new String(contents); 1431 return new String(contents);
1443 } 1432 }
1444 } 1433 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698