| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 | 8 |
| 9 import org.chromium.base.test.util.Feature; | 9 import org.chromium.base.test.util.Feature; |
| 10 import org.chromium.net.test.util.CertTestUtil; | 10 import org.chromium.net.test.util.CertTestUtil; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 /** | 310 /** |
| 311 * Asserts that the response from the server contains an PKP error. | 311 * Asserts that the response from the server contains an PKP error. |
| 312 * TODO(kapishnikov): currently QUIC returns ERR_QUIC_PROTOCOL_ERROR instead
of expected | 312 * TODO(kapishnikov): currently QUIC returns ERR_QUIC_PROTOCOL_ERROR instead
of expected |
| 313 * ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN error code when the pin doesn't matc
h. | 313 * ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN error code when the pin doesn't matc
h. |
| 314 * This method should be changed when the bug is resolved. | 314 * This method should be changed when the bug is resolved. |
| 315 * See http://crbug.com/548378 | 315 * See http://crbug.com/548378 |
| 316 * See http://crbug.com/568669 | 316 * See http://crbug.com/568669 |
| 317 */ | 317 */ |
| 318 private void assertErrorResponse() { | 318 private void assertErrorResponse() { |
| 319 assertNotNull("Expected an error", mListener.mError); | 319 assertNotNull("Expected an error", mListener.mError); |
| 320 int errorCode = mListener.mError.netError(); | 320 int errorCode = mListener.mError.getCronetInternalErrorCode(); |
| 321 Set<Integer> expectedErrors = new HashSet<>(); | 321 Set<Integer> expectedErrors = new HashSet<>(); |
| 322 expectedErrors.add(NetError.ERR_QUIC_PROTOCOL_ERROR); | 322 expectedErrors.add(NetError.ERR_QUIC_PROTOCOL_ERROR); |
| 323 expectedErrors.add(NetError.ERR_CONNECTION_REFUSED); | 323 expectedErrors.add(NetError.ERR_CONNECTION_REFUSED); |
| 324 expectedErrors.add(NetError.ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); | 324 expectedErrors.add(NetError.ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); |
| 325 assertTrue(String.format("Incorrect error code. Expected one of %s but r
eceived %s", | 325 assertTrue(String.format("Incorrect error code. Expected one of %s but r
eceived %s", |
| 326 expectedErrors, errorCode), | 326 expectedErrors, errorCode), |
| 327 expectedErrors.contains(errorCode)); | 327 expectedErrors.contains(errorCode)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 /** | 330 /** |
| 331 * Asserts a successful response with response code 200. | 331 * Asserts a successful response with response code 200. |
| 332 */ | 332 */ |
| 333 private void assertSuccessfulResponse() { | 333 private void assertSuccessfulResponse() { |
| 334 if (mListener.mError != null) { | 334 if (mListener.mError != null) { |
| 335 fail("Did not expect an error but got error code " + mListener.mErro
r.mNetError); | 335 fail("Did not expect an error but got error code " |
| 336 + mListener.mError.getCronetInternalErrorCode()); |
| 336 } | 337 } |
| 337 assertNotNull("Expected non-null response from the server", mListener.mR
esponseInfo); | 338 assertNotNull("Expected non-null response from the server", mListener.mR
esponseInfo); |
| 338 assertEquals(200, mListener.mResponseInfo.getHttpStatusCode()); | 339 assertEquals(200, mListener.mResponseInfo.getHttpStatusCode()); |
| 339 } | 340 } |
| 340 | 341 |
| 341 private void createCronetEngineBuilder() throws Exception { | 342 private void createCronetEngineBuilder() throws Exception { |
| 342 // Set common CronetEngine parameters | 343 // Set common CronetEngine parameters |
| 343 mBuilder = new CronetEngine.Builder(getContext()); | 344 mBuilder = new CronetEngine.Builder(getContext()); |
| 344 mBuilder.enableQUIC(true); | 345 mBuilder.enableQUIC(true); |
| 345 mBuilder.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getS
erverPort(), | 346 mBuilder.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getS
erverPort(), |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 if (!shouldThrowNpe) { | 430 if (!shouldThrowNpe) { |
| 430 fail("Null pointer exception was not expected: " + ex.toString()
); | 431 fail("Null pointer exception was not expected: " + ex.toString()
); |
| 431 } | 432 } |
| 432 return; | 433 return; |
| 433 } | 434 } |
| 434 if (shouldThrowNpe) { | 435 if (shouldThrowNpe) { |
| 435 fail("NullPointerException was expected"); | 436 fail("NullPointerException was expected"); |
| 436 } | 437 } |
| 437 } | 438 } |
| 438 } | 439 } |
| OLD | NEW |