| Index: components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java
|
| diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java
|
| index 85400f364f5f094b78cea1e8128103340474ed0b..ae2cf2fd9aa9b332ce1ef3efbe37e233f6885cf0 100644
|
| --- a/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java
|
| +++ b/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java
|
| @@ -20,8 +20,18 @@ public class QuicTest extends CronetTestBase {
|
| @Override
|
| protected void setUp() throws Exception {
|
| super.setUp();
|
| - mActivity = launchCronetTestApp();
|
| - QuicTestServer.startQuicTestServer(mActivity.getApplicationContext());
|
| + // Load library first, since we need the Quic test server's URL.
|
| + System.loadLibrary("cronet_tests");
|
| + QuicTestServer.startQuicTestServer(getInstrumentation().getTargetContext());
|
| + UrlRequestContextConfig config = new UrlRequestContextConfig();
|
| + config.enableQUIC(true);
|
| + config.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getServerPort(),
|
| + QuicTestServer.getServerPort());
|
| + config.setExperimentalQuicConnectionOptions("PACE,IW10,FOO,DEADBEEF");
|
| +
|
| + String[] commandLineArgs = {CronetTestActivity.CONFIG_KEY, config.toString(),
|
| + CronetTestActivity.CACHE_KEY, CronetTestActivity.CACHE_DISK_NO_HTTP};
|
| + mActivity = launchCronetTestAppWithUrlAndCommandLineArgs(null, commandLineArgs);
|
| }
|
|
|
| @Override
|
| @@ -32,38 +42,44 @@ public class QuicTest extends CronetTestBase {
|
|
|
| @SmallTest
|
| @Feature({"Cronet"})
|
| - public void testQuicLoadUrl() throws Exception {
|
| - HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig();
|
| + public void testQuicLoadUrl_LegacyAPI() throws Exception {
|
| String quicURL = QuicTestServer.getServerURL() + "/simple.txt";
|
| - config.enableQUIC(true);
|
| - config.setLibraryName("cronet_tests");
|
| - config.addQuicHint(QuicTestServer.getServerHost(),
|
| - QuicTestServer.getServerPort(), QuicTestServer.getServerPort());
|
| - config.setExperimentalQuicConnectionOptions("PACE,IW10,FOO,DEADBEEF");
|
| -
|
| - HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
|
| - mActivity.getApplicationContext(), config);
|
|
|
| HashMap<String, String> headers = new HashMap<String, String>();
|
| TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
|
|
|
| - // Quic always races the first request with SPDY, but the second request
|
| - // should go through Quic.
|
| - for (int i = 0; i < 2; i++) {
|
| - HttpUrlRequest request =
|
| - factory.createRequest(
|
| - quicURL,
|
| - HttpUrlRequest.REQUEST_PRIORITY_MEDIUM,
|
| - headers,
|
| - listener);
|
| - request.start();
|
| - listener.blockForComplete();
|
| - if (listener.mHttpStatusCode == 200) break;
|
| - }
|
| + // Although the native stack races QUIC and SPDY for the first request,
|
| + // since there is no http server running on the corresponding TCP port,
|
| + // QUIC will always succeed with a 200 (see
|
| + // net::HttpStreamFactoryImpl::Request::OnStreamFailed).
|
| + HttpUrlRequest request = mActivity.mRequestFactory.createRequest(
|
| + quicURL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener);
|
| + request.start();
|
| + listener.blockForComplete();
|
| assertEquals(200, listener.mHttpStatusCode);
|
| assertEquals(
|
| "This is a simple text file served by QUIC.\n",
|
| listener.mResponseAsString);
|
| assertEquals("quic/1+spdy/3", listener.mNegotiatedProtocol);
|
| }
|
| +
|
| + @SmallTest
|
| + @Feature({"Cronet"})
|
| + public void testQuicLoadUrl() throws Exception {
|
| + String quicURL = QuicTestServer.getServerURL() + "/simple.txt";
|
| + TestUrlRequestListener listener = new TestUrlRequestListener();
|
| +
|
| + // Although the native stack races QUIC and SPDY for the first request,
|
| + // since there is no http server running on the corresponding TCP port,
|
| + // QUIC will always succeed with a 200 (see
|
| + // net::HttpStreamFactoryImpl::Request::OnStreamFailed).
|
| + UrlRequest request = mActivity.mUrlRequestContext.createRequest(
|
| + quicURL, listener, listener.getExecutor());
|
| + request.start();
|
| + listener.blockForDone();
|
| +
|
| + assertEquals(200, listener.mResponseInfo.getHttpStatusCode());
|
| + assertEquals("This is a simple text file served by QUIC.\n", listener.mResponseAsString);
|
| + assertEquals("quic/1+spdy/3", listener.mResponseInfo.getNegotiatedProtocol());
|
| + }
|
| }
|
|
|