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

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

Issue 2514713002: Send encoded_body_length to renderer when response completed (1/3) (Closed)
Patch Set: merge https://codereview.chromium.org/2526653002/ 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 | content/browser/loader/async_resource_handler.cc » ('j') | 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 @SmallTest 630 @SmallTest
631 @Feature({"Cronet"}) 631 @Feature({"Cronet"})
632 @OnlyRunNativeCronet // Java impl doesn't support MockUrlRequestJobFactory 632 @OnlyRunNativeCronet // Java impl doesn't support MockUrlRequestJobFactory
633 public void testMockReadDataSyncError() throws Exception { 633 public void testMockReadDataSyncError() throws Exception {
634 final int arbitraryNetError = -4; 634 final int arbitraryNetError = -4;
635 TestUrlRequestCallback callback = 635 TestUrlRequestCallback callback =
636 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF ailure( 636 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF ailure(
637 FailurePhase.READ_SYNC, arbitraryNetError)); 637 FailurePhase.READ_SYNC, arbitraryNetError));
638 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); 638 assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
639 assertEquals(0, callback.mResponseInfo.getReceivedBytesCount()); 639 assertEquals(15, callback.mResponseInfo.getReceivedBytesCount());
640 assertNotNull(callback.mError); 640 assertNotNull(callback.mError);
641 assertEquals(arbitraryNetError, callback.mError.getCronetInternalErrorCo de()); 641 assertEquals(arbitraryNetError, callback.mError.getCronetInternalErrorCo de());
642 assertEquals(0, callback.mRedirectCount); 642 assertEquals(0, callback.mRedirectCount);
643 assertTrue(callback.mOnErrorCalled); 643 assertTrue(callback.mOnErrorCalled);
644 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep); 644 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep);
645 } 645 }
646 646
647 @SmallTest 647 @SmallTest
648 @Feature({"Cronet"}) 648 @Feature({"Cronet"})
649 @OnlyRunNativeCronet // Java impl doesn't support MockUrlRequestJobFactory 649 @OnlyRunNativeCronet // Java impl doesn't support MockUrlRequestJobFactory
650 public void testMockReadDataAsyncError() throws Exception { 650 public void testMockReadDataAsyncError() throws Exception {
651 final int arbitraryNetError = -5; 651 final int arbitraryNetError = -5;
652 TestUrlRequestCallback callback = 652 TestUrlRequestCallback callback =
653 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF ailure( 653 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF ailure(
654 FailurePhase.READ_ASYNC, arbitraryNetError)); 654 FailurePhase.READ_ASYNC, arbitraryNetError));
655 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); 655 assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
656 assertEquals(0, callback.mResponseInfo.getReceivedBytesCount()); 656 assertEquals(15, callback.mResponseInfo.getReceivedBytesCount());
657 assertNotNull(callback.mError); 657 assertNotNull(callback.mError);
658 assertEquals(arbitraryNetError, callback.mError.getCronetInternalErrorCo de()); 658 assertEquals(arbitraryNetError, callback.mError.getCronetInternalErrorCo de());
659 assertEquals(0, callback.mRedirectCount); 659 assertEquals(0, callback.mRedirectCount);
660 assertTrue(callback.mOnErrorCalled); 660 assertTrue(callback.mOnErrorCalled);
661 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep); 661 assertEquals(ResponseStep.ON_FAILED, callback.mResponseStep);
662 } 662 }
663 663
664 /** 664 /**
665 * Tests that request continues when client certificate is requested. 665 * Tests that request continues when client certificate is requested.
666 */ 666 */
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 } 2016 }
2017 2017
2018 private void assertResponseStepCanceled(TestUrlRequestCallback callback) { 2018 private void assertResponseStepCanceled(TestUrlRequestCallback callback) {
2019 if (callback.mResponseStep == ResponseStep.ON_FAILED && callback.mError != null) { 2019 if (callback.mResponseStep == ResponseStep.ON_FAILED && callback.mError != null) {
2020 throw new Error( 2020 throw new Error(
2021 "Unexpected response state: " + ResponseStep.ON_FAILED, call back.mError); 2021 "Unexpected response state: " + ResponseStep.ON_FAILED, call back.mError);
2022 } 2022 }
2023 assertEquals(ResponseStep.ON_CANCELED, callback.mResponseStep); 2023 assertEquals(ResponseStep.ON_CANCELED, callback.mResponseStep);
2024 } 2024 }
2025 } 2025 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698