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 = -606; | |
|
xunjieli
2015/11/20 21:04:25
nit: unused, and in comment.
mef
2015/11/20 22:01:23
Done.
| |
| 564 TestUrlRequestCallback callback = startAndWaitForComplete( | |
| 565 MockUrlRequestJobFactory.getMockUrlForClientCertificateRequest() ); | |
| 566 assertNotNull(callback.mResponseInfo); | |
|
xunjieli
2015/11/20 21:04:25
Maybe assert on getHttpStatusCode and mResponseAsS
mef
2015/11/20 22:01:23
Done.
| |
| 567 assertEquals(0, callback.mRedirectCount); | |
| 568 assertNull(callback.mError); | |
| 569 assertFalse(callback.mOnErrorCalled); | |
| 570 } | |
| 571 | |
| 572 /** | |
| 557 * Tests that an SSL cert error will be reported via {@link UrlRequest#onFai led}. | 573 * Tests that an SSL cert error will be reported via {@link UrlRequest#onFai led}. |
| 558 */ | 574 */ |
| 559 @SmallTest | 575 @SmallTest |
| 560 @Feature({"Cronet"}) | 576 @Feature({"Cronet"}) |
| 561 public void testMockSSLCertificateError() throws Exception { | 577 public void testMockSSLCertificateError() throws Exception { |
| 562 TestUrlRequestCallback callback = startAndWaitForComplete( | 578 TestUrlRequestCallback callback = startAndWaitForComplete( |
| 563 MockUrlRequestJobFactory.getMockUrlForSSLCertificateError()); | 579 MockUrlRequestJobFactory.getMockUrlForSSLCertificateError()); |
| 564 assertNull(callback.mResponseInfo); | 580 assertNull(callback.mResponseInfo); |
| 565 assertNotNull(callback.mError); | 581 assertNotNull(callback.mError); |
| 566 assertTrue(callback.mOnErrorCalled); | 582 assertTrue(callback.mOnErrorCalled); |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1559 int end) { | 1575 int end) { |
| 1560 // Use a duplicate to avoid modifying byteBuffer. | 1576 // Use a duplicate to avoid modifying byteBuffer. |
| 1561 ByteBuffer duplicate = byteBuffer.duplicate(); | 1577 ByteBuffer duplicate = byteBuffer.duplicate(); |
| 1562 duplicate.position(start); | 1578 duplicate.position(start); |
| 1563 duplicate.limit(end); | 1579 duplicate.limit(end); |
| 1564 byte[] contents = new byte[duplicate.remaining()]; | 1580 byte[] contents = new byte[duplicate.remaining()]; |
| 1565 duplicate.get(contents); | 1581 duplicate.get(contents); |
| 1566 return new String(contents); | 1582 return new String(contents); |
| 1567 } | 1583 } |
| 1568 } | 1584 } |
| OLD | NEW |