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

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

Issue 2572693003: Fix CronetUrlRequestTest#testFailures flake (Closed)
Patch Set: 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 assertEquals(
1683 || failureType == FailureType.CANCEL_ASYNC 1683 failureType == FailureType.CANCEL_SYNC || failureType == Failure Type.CANCEL_ASYNC,
1684 || failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE ,
1685 callback.mOnCanceledCalled); 1684 callback.mOnCanceledCalled);
1685 // When failureType is FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, there
1686 // might be an onSucceeded() task already posted. If that's the case,
1687 // onCanceled() will not be invoked. See crbug.com/657415.
pauljensen 2016/12/14 14:40:31 I'm confused, we waited for the callback to get ei
pauljensen 2016/12/14 15:17:32 I was confused because mResponseInfo is set in onR
xunjieli 2016/12/14 15:35:39 After talking to you, I realize that we should onl
1686 } 1688 }
1687 1689
1688 @SmallTest 1690 @SmallTest
1689 @Feature({"Cronet"}) 1691 @Feature({"Cronet"})
1690 public void testFailures() throws Exception { 1692 public void testFailures() throws Exception {
1691 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT , 1693 throwOrCancel(FailureType.CANCEL_SYNC, ResponseStep.ON_RECEIVED_REDIRECT ,
1692 false, false); 1694 false, false);
1693 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC T, 1695 throwOrCancel(FailureType.CANCEL_ASYNC, ResponseStep.ON_RECEIVED_REDIREC T,
1694 false, false); 1696 false, false);
1695 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE CEIVED_REDIRECT, 1697 throwOrCancel(FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, ResponseStep.ON_RE CEIVED_REDIRECT,
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 } 2083 }
2082 2084
2083 private void assertResponseStepCanceled(TestUrlRequestCallback callback) { 2085 private void assertResponseStepCanceled(TestUrlRequestCallback callback) {
2084 if (callback.mResponseStep == ResponseStep.ON_FAILED && callback.mError != null) { 2086 if (callback.mResponseStep == ResponseStep.ON_FAILED && callback.mError != null) {
2085 throw new Error( 2087 throw new Error(
2086 "Unexpected response state: " + ResponseStep.ON_FAILED, call back.mError); 2088 "Unexpected response state: " + ResponseStep.ON_FAILED, call back.mError);
2087 } 2089 }
2088 assertEquals(ResponseStep.ON_CANCELED, callback.mResponseStep); 2090 assertEquals(ResponseStep.ON_CANCELED, callback.mResponseStep);
2089 } 2091 }
2090 } 2092 }
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