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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 assertNull(callback.mResponseInfo); | 564 assertNull(callback.mResponseInfo); |
| 565 assertNotNull(callback.mError); | 565 assertNotNull(callback.mError); |
| 566 assertTrue(callback.mOnErrorCalled); | 566 assertTrue(callback.mOnErrorCalled); |
| 567 assertEquals(-201, callback.mError.netError()); | 567 assertEquals(-201, callback.mError.netError()); |
| 568 assertEquals("Exception in CronetUrlRequest: net::ERR_CERT_DATE_INVALID" , | 568 assertEquals("Exception in CronetUrlRequest: net::ERR_CERT_DATE_INVALID" , |
| 569 callback.mError.getMessage()); | 569 callback.mError.getMessage()); |
| 570 assertEquals(callback.mResponseStep, ResponseStep.NOTHING); | 570 assertEquals(callback.mResponseStep, ResponseStep.NOTHING); |
| 571 } | 571 } |
| 572 | 572 |
| 573 /** | 573 /** |
| 574 * Tests that request continues when client certificate is requested and the | |
| 575 * |arbitraryNetError| is reported later. | |
| 576 */ | |
| 577 @SmallTest | |
| 578 @Feature({"Cronet"}) | |
| 579 public void testMockCertRequested() throws Exception { | |
|
svaldez
2015/11/20 16:30:10
nit: Move above testMockSSLCertificateError to mat
mef
2015/11/20 16:44:06
Done.
| |
| 580 final int arbitraryNetError = -3; | |
| 581 TestUrlRequestCallback callback = | |
| 582 startAndWaitForComplete(MockUrlRequestJobFactory.getMockUrlWithF ailure( | |
| 583 FailurePhase.CERT_REQUESTED, arbitraryNetError)); | |
| 584 assertNull(callback.mResponseInfo); | |
| 585 assertNotNull(callback.mError); | |
| 586 assertEquals(arbitraryNetError, callback.mError.netError()); | |
| 587 assertEquals(0, callback.mRedirectCount); | |
| 588 assertTrue(callback.mOnErrorCalled); | |
| 589 assertEquals(callback.mResponseStep, ResponseStep.NOTHING); | |
| 590 } | |
| 591 | |
| 592 /** | |
| 574 * Checks that the buffer is updated correctly, when starting at an offset, | 593 * Checks that the buffer is updated correctly, when starting at an offset, |
| 575 * when using legacy read() API. | 594 * when using legacy read() API. |
| 576 */ | 595 */ |
| 577 @SmallTest | 596 @SmallTest |
| 578 @Feature({"Cronet"}) | 597 @Feature({"Cronet"}) |
| 579 @SuppressWarnings("deprecation") | 598 @SuppressWarnings("deprecation") |
| 580 public void testLegacySimpleGetBufferUpdates() throws Exception { | 599 public void testLegacySimpleGetBufferUpdates() throws Exception { |
| 581 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 600 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 582 callback.mLegacyReadByteBufferAdjustment = true; | 601 callback.mLegacyReadByteBufferAdjustment = true; |
| 583 callback.setAutoAdvance(false); | 602 callback.setAutoAdvance(false); |
| (...skipping 975 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 |