Chromium Code Reviews| 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.ConditionVariable; | 7 import android.os.ConditionVariable; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 9 | 9 |
| 10 import org.chromium.base.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); | 547 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); |
| 548 assertEquals(0, callback.mResponseInfo.getReceivedBytesCount()); | 548 assertEquals(0, callback.mResponseInfo.getReceivedBytesCount()); |
| 549 assertNotNull(callback.mError); | 549 assertNotNull(callback.mError); |
| 550 assertEquals(arbitraryNetError, callback.mError.netError()); | 550 assertEquals(arbitraryNetError, callback.mError.netError()); |
| 551 assertEquals(0, callback.mRedirectCount); | 551 assertEquals(0, callback.mRedirectCount); |
| 552 assertTrue(callback.mOnErrorCalled); | 552 assertTrue(callback.mOnErrorCalled); |
| 553 assertEquals(callback.mResponseStep, ResponseStep.ON_RESPONSE_STARTED); | 553 assertEquals(callback.mResponseStep, ResponseStep.ON_RESPONSE_STARTED); |
| 554 } | 554 } |
| 555 | 555 |
| 556 /** | 556 /** |
| 557 * Tests that request continues when client certificate is requested and the | |
| 558 * |arbitraryNetError| is reported later. | |
| 559 */ | |
| 560 @SmallTest | |
| 561 @Feature({"Cronet"}) | |
| 562 public void testMockCertRequested() throws Exception { | |
| 563 final int arbitraryNetError = -3; | |
|
xunjieli
2015/11/20 18:59:59
It is a bit counterintuitive that we are reporting
mef
2015/11/20 20:51:49
Good point. Done.
| |
| 564 TestUrlRequestCallback callback = | |
| 565 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF ailure( | |
| 566 FailurePhase.CERT_REQUESTED, arbitraryNetError)); | |
| 567 assertNull(callback.mResponseInfo); | |
| 568 assertNotNull(callback.mError); | |
| 569 assertEquals(arbitraryNetError, callback.mError.netError()); | |
| 570 assertEquals(0, callback.mRedirectCount); | |
| 571 assertTrue(callback.mOnErrorCalled); | |
| 572 assertEquals(callback.mResponseStep, ResponseStep.NOTHING); | |
| 573 } | |
| 574 | |
| 575 /** | |
| 557 * Tests that an SSL cert error will be reported via {@link UrlRequest#onFai led}. | 576 * Tests that an SSL cert error will be reported via {@link UrlRequest#onFai led}. |
| 558 */ | 577 */ |
| 559 @SmallTest | 578 @SmallTest |
| 560 @Feature({"Cronet"}) | 579 @Feature({"Cronet"}) |
| 561 public void testMockSSLCertificateError() throws Exception { | 580 public void testMockSSLCertificateError() throws Exception { |
| 562 TestUrlRequestCallback callback = startAndWaitForComplete( | 581 TestUrlRequestCallback callback = startAndWaitForComplete( |
| 563 MockUrlRequestJobFactory.getMockUrlForSSLCertificateError()); | 582 MockUrlRequestJobFactory.getMockUrlForSSLCertificateError()); |
| 564 assertNull(callback.mResponseInfo); | 583 assertNull(callback.mResponseInfo); |
| 565 assertNotNull(callback.mError); | 584 assertNotNull(callback.mError); |
| 566 assertTrue(callback.mOnErrorCalled); | 585 assertTrue(callback.mOnErrorCalled); |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1559 int end) { | 1578 int end) { |
| 1560 // Use a duplicate to avoid modifying byteBuffer. | 1579 // Use a duplicate to avoid modifying byteBuffer. |
| 1561 ByteBuffer duplicate = byteBuffer.duplicate(); | 1580 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1562 duplicate.position(start); | 1581 duplicate.position(start); |
| 1563 duplicate.limit(end); | 1582 duplicate.limit(end); |
| 1564 byte[] contents = new byte[duplicate.remaining()]; | 1583 byte[] contents = new byte[duplicate.remaining()]; |
| 1565 duplicate.get(contents); | 1584 duplicate.get(contents); |
| 1566 return new String(contents); | 1585 return new String(contents); |
| 1567 } | 1586 } |
| 1568 } | 1587 } |
| OLD | NEW |