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

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

Issue 2572693003: Fix CronetUrlRequestTest#testFailures flake (Closed)
Patch Set: Use a conditional and not skip all CANCEL_ASYNC_WITHOUT_PAUSE Created 4 years 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 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.os.StrictMode; 8 import android.os.StrictMode;
9 import android.test.MoreAsserts; 9 import android.test.MoreAsserts;
10 import android.test.suitebuilder.annotation.SmallTest; 10 import android.test.suitebuilder.annotation.SmallTest;
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 assertEquals(1, callback.mRedirectCount); 1672 assertEquals(1, callback.mRedirectCount);
1673 if (failureType == FailureType.CANCEL_SYNC || failureType == FailureType .CANCEL_ASYNC) { 1673 if (failureType == FailureType.CANCEL_SYNC || failureType == FailureType .CANCEL_ASYNC) {
1674 assertResponseStepCanceled(callback); 1674 assertResponseStepCanceled(callback);
1675 } else if (failureType == FailureType.THROW_SYNC) { 1675 } else if (failureType == FailureType.THROW_SYNC) {
1676 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep); 1676 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep);
1677 } 1677 }
1678 assertTrue(urlRequest.isDone()); 1678 assertTrue(urlRequest.isDone());
1679 assertEquals(expectResponseInfo, callback.mResponseInfo != null); 1679 assertEquals(expectResponseInfo, callback.mResponseInfo != null);
1680 assertEquals(expectError, callback.mError != null); 1680 assertEquals(expectError, callback.mError != null);
1681 assertEquals(expectError, callback.mOnErrorCalled); 1681 assertEquals(expectError, callback.mOnErrorCalled);
1682 assertEquals(failureType == FailureType.CANCEL_SYNC 1682 // When failureType is FailureType.CANCEL_ASYNC_WITHOUT_PAUSE and failur eStep is
1683 || failureType == FailureType.CANCEL_ASYNC 1683 // ResponseStep.ON_READ_COMPLETED, there might be an onSucceeded() task already posted. If
1684 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE , 1684 // that's the case, onCanceled() will not be invoked. See crbug.com/6574 15.
1685 callback.mOnCanceledCalled); 1685 if (!(failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
1686 && failureStep == ResponseStep.ON_READ_COMPLETED)) {
1687 assertEquals(failureType == FailureType.CANCEL_SYNC
1688 || failureType == FailureType.CANCEL_ASYNC
1689 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_P AUSE,
1690 callback.mOnCanceledCalled);
1691 }
1686 } 1692 }
1687 1693
1688 @SmallTest 1694 @SmallTest
1689 @Feature({"Cronet"}) 1695 @Feature({"Cronet"})
1690 public void testFailures() throws Exception { 1696 public void testFailures() throws Exception {
1691 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT , 1697 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT ,
1692 false, false); 1698 false, false);
1693 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC T, 1699 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC T,
1694 false, false); 1700 false, false);
1695 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE CEIVED_REDIRECT, 1701 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE CEIVED_REDIRECT,
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 } 2087 }
2082 2088
2083 private void assertResponseStepCanceled(TestUrlRequestCallback callback) { 2089 private void assertResponseStepCanceled(TestUrlRequestCallback callback) {
2084 if (callback.mResponseStep == ResponseStep.ON_FAILED && callback.mError != null) { 2090 if (callback.mResponseStep == ResponseStep.ON_FAILED && callback.mError != null) {
2085 throw new Error( 2091 throw new Error(
2086 "Unexpected response state: " + ResponseStep.ON_FAILED, call back.mError); 2092 "Unexpected response state: " + ResponseStep.ON_FAILED, call back.mError);
2087 } 2093 }
2088 assertEquals(ResponseStep.ON_CANCELED, callback.mResponseStep); 2094 assertEquals(ResponseStep.ON_CANCELED, callback.mResponseStep);
2089 } 2095 }
2090 } 2096 }
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