| Index: components/cronet/android/test/smoketests/src/org/chromium/net/smoke/QuicTest.java
|
| diff --git a/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/QuicTest.java b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/QuicTest.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f722c4c679118324e46cb1f0da0a34646c4e70af
|
| --- /dev/null
|
| +++ b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/QuicTest.java
|
| @@ -0,0 +1,62 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.net.smoke;
|
| +
|
| +import android.annotation.TargetApi;
|
| +import android.test.suitebuilder.annotation.Smoke;
|
| +
|
| +import org.json.JSONObject;
|
| +
|
| +import static org.chromium.net.smoke.TestSupport.Protocol.QUIC;
|
| +
|
| +import org.chromium.net.UrlRequest;
|
| +
|
| +import java.net.URL;
|
| +
|
| +/**
|
| + * QUIC Tests.
|
| + */
|
| +@TargetApi(19)
|
| +public class QuicTest extends NativeCronetTestBase {
|
| + @Smoke
|
| + public void testQuic() throws Exception {
|
| + try (TestSupport.TestServer server = mTestSupport.createTestServer(getContext(), QUIC)) {
|
| + assertTrue(server.start());
|
| + final String urlString = server.getSuccessURL();
|
| + final URL url = new URL(urlString);
|
| +
|
| + mCronetEngineBuilder.enableQuic(true);
|
| + mCronetEngineBuilder.addQuicHint(url.getHost(), url.getPort(), url.getPort());
|
| + mTestSupport.installMockCertVerifierForTesting(mCronetEngineBuilder);
|
| +
|
| + JSONObject quicParams = new JSONObject().put("delay_tcp_race", true);
|
| + JSONObject experimentalOptions = new JSONObject().put("QUIC", quicParams);
|
| + mTestSupport.addHostResolverRules(experimentalOptions);
|
| + experimentalOptions.put("host_whitelist", url.getHost());
|
| +
|
| + mCronetEngineBuilder.setExperimentalOptions(experimentalOptions.toString());
|
| +
|
| + initCronetEngine();
|
| +
|
| + // QUIC is not guaranteed to win the race even with |delay_tcp_race| set, so try
|
| + // multiple times.
|
| + boolean quicNegotiated = false;
|
| +
|
| + for (int i = 0; i < 5; i++) {
|
| + TestUrlRequestCallback callback = new TestUrlRequestCallback();
|
| + UrlRequest.Builder requestBuilder = mCronetEngine.newUrlRequestBuilder(
|
| + urlString, callback, callback.getExecutor());
|
| + requestBuilder.build().start();
|
| + callback.blockForDone();
|
| + assertSuccessfulNonEmptyResponse(callback.mResponseInfo, urlString);
|
| + if (callback.mResponseInfo.getNegotiatedProtocol().startsWith("http/2+quic/")) {
|
| + quicNegotiated = true;
|
| + break;
|
| + }
|
| + }
|
| + assertTrue(quicNegotiated);
|
| + }
|
| + }
|
| +}
|
|
|