| OLD | NEW |
| 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.Build; | 7 import android.os.Build; |
| 8 import android.os.ConditionVariable; | 8 import android.os.ConditionVariable; |
| 9 import android.os.StrictMode; | 9 import android.os.StrictMode; |
| 10 import android.support.test.filters.SmallTest; | 10 import android.support.test.filters.SmallTest; |
| 11 | 11 |
| 12 import org.chromium.base.Log; | 12 import org.chromium.base.Log; |
| 13 import org.chromium.base.test.util.DisabledTest; |
| 13 import org.chromium.base.test.util.Feature; | 14 import org.chromium.base.test.util.Feature; |
| 14 import org.chromium.net.TestUrlRequestCallback.FailureType; | 15 import org.chromium.net.TestUrlRequestCallback.FailureType; |
| 15 import org.chromium.net.TestUrlRequestCallback.ResponseStep; | 16 import org.chromium.net.TestUrlRequestCallback.ResponseStep; |
| 16 import org.chromium.net.impl.CronetUrlRequest; | 17 import org.chromium.net.impl.CronetUrlRequest; |
| 17 import org.chromium.net.impl.UrlResponseInfoImpl; | 18 import org.chromium.net.impl.UrlResponseInfoImpl; |
| 18 import org.chromium.net.test.FailurePhase; | 19 import org.chromium.net.test.FailurePhase; |
| 19 | 20 |
| 20 import java.io.IOException; | 21 import java.io.IOException; |
| 21 import java.net.ConnectException; | 22 import java.net.ConnectException; |
| 22 import java.nio.ByteBuffer; | 23 import java.nio.ByteBuffer; |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); | 643 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); |
| 643 assertEquals(15, callback.mResponseInfo.getReceivedByteCount()); | 644 assertEquals(15, callback.mResponseInfo.getReceivedByteCount()); |
| 644 assertNotNull(callback.mError); | 645 assertNotNull(callback.mError); |
| 645 assertEquals(arbitraryNetError, | 646 assertEquals(arbitraryNetError, |
| 646 ((NetworkException) callback.mError).getCronetInternalErrorCode(
)); | 647 ((NetworkException) callback.mError).getCronetInternalErrorCode(
)); |
| 647 assertEquals(0, callback.mRedirectCount); | 648 assertEquals(0, callback.mRedirectCount); |
| 648 assertTrue(callback.mOnErrorCalled); | 649 assertTrue(callback.mOnErrorCalled); |
| 649 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep); | 650 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep); |
| 650 } | 651 } |
| 651 | 652 |
| 653 @DisabledTest(message = "crbug.com/738183") |
| 652 @SmallTest | 654 @SmallTest |
| 653 @Feature({"Cronet"}) | 655 @Feature({"Cronet"}) |
| 654 @OnlyRunNativeCronet // Java impl doesn't support MockUrlRequestJobFactory | 656 @OnlyRunNativeCronet // Java impl doesn't support MockUrlRequestJobFactory |
| 655 public void testMockReadDataAsyncError() throws Exception { | 657 public void testMockReadDataAsyncError() throws Exception { |
| 656 final int arbitraryNetError = -5; | 658 final int arbitraryNetError = -5; |
| 657 TestUrlRequestCallback callback = | 659 TestUrlRequestCallback callback = |
| 658 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF
ailure( | 660 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF
ailure( |
| 659 FailurePhase.READ_ASYNC, arbitraryNetError)); | 661 FailurePhase.READ_ASYNC, arbitraryNetError)); |
| 660 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); | 662 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); |
| 661 assertEquals(15, callback.mResponseInfo.getReceivedByteCount()); | 663 assertEquals(15, callback.mResponseInfo.getReceivedByteCount()); |
| (...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 // The other quirk of this is that from teardown(), JavaCronetEngine
.shutdown() is | 2149 // The other quirk of this is that from teardown(), JavaCronetEngine
.shutdown() is |
| 2148 // called which calls ExecutorService.shutdown() which doesn't wait
for the thread to | 2150 // called which calls ExecutorService.shutdown() which doesn't wait
for the thread to |
| 2149 // finish running tasks, and then teardown() calls GC looking for le
aks. One possible | 2151 // finish running tasks, and then teardown() calls GC looking for le
aks. One possible |
| 2150 // modification would be to expose the ExecutorService and then have
tests call | 2152 // modification would be to expose the ExecutorService and then have
tests call |
| 2151 // awaitTermination() but this would complicate things, and adding a
1s sleep() to | 2153 // awaitTermination() but this would complicate things, and adding a
1s sleep() to |
| 2152 // allow the ExecutorService to terminate did not increase the chanc
es of catching the | 2154 // allow the ExecutorService to terminate did not increase the chanc
es of catching the |
| 2153 // leak. | 2155 // leak. |
| 2154 } | 2156 } |
| 2155 } | 2157 } |
| 2156 } | 2158 } |
| OLD | NEW |