Commit 674e1123 authored by xunjieli's avatar xunjieli Committed by Commit bot

Fix CronetUrlRequestTest#testFailures flake

When CronetUrlRequest is canceled asynchronously in a callback without
being paused, we might already have a onSucceeded() callback in the
executor's queue. If that is the case, we won't have a onCanceled()
callback. This led to test flake. This CL adjusts the test expectation
and adds a comment.

R=pauljensen@chromium.org

BUG=657415
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_cronet_tester

Review-Url: https://codereview.chromium.org/2572693003
Cr-Commit-Position: refs/heads/master@{#438526}
parent e6a3fc3e
...@@ -1679,10 +1679,16 @@ public class CronetUrlRequestTest extends CronetTestBase { ...@@ -1679,10 +1679,16 @@ public class CronetUrlRequestTest extends CronetTestBase {
assertEquals(expectResponseInfo, callback.mResponseInfo != null); assertEquals(expectResponseInfo, callback.mResponseInfo != null);
assertEquals(expectError, callback.mError != null); assertEquals(expectError, callback.mError != null);
assertEquals(expectError, callback.mOnErrorCalled); assertEquals(expectError, callback.mOnErrorCalled);
assertEquals(failureType == FailureType.CANCEL_SYNC // When failureType is FailureType.CANCEL_ASYNC_WITHOUT_PAUSE and failureStep is
|| failureType == FailureType.CANCEL_ASYNC // ResponseStep.ON_READ_COMPLETED, there might be an onSucceeded() task already posted. If
|| failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE, // that's the case, onCanceled() will not be invoked. See crbug.com/657415.
callback.mOnCanceledCalled); if (!(failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE
&& failureStep == ResponseStep.ON_READ_COMPLETED)) {
assertEquals(failureType == FailureType.CANCEL_SYNC
|| failureType == FailureType.CANCEL_ASYNC
|| failureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE,
callback.mOnCanceledCalled);
}
} }
@SmallTest @SmallTest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment