OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.net; |
| 6 |
| 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 |
| 9 import org.chromium.base.test.util.Feature; |
| 10 |
| 11 import java.util.HashMap; |
| 12 |
| 13 /** |
| 14 * Tests making requests using QUIC. |
| 15 */ |
| 16 public class QuicTest extends CronetTestBase { |
| 17 |
| 18 @Override |
| 19 protected void setUp() throws Exception { |
| 20 super.setUp(); |
| 21 // Loads library first since native functions are used to retrieve |
| 22 // QuicTestServer info before config is constructed. |
| 23 System.loadLibrary("cronet_tests"); |
| 24 } |
| 25 |
| 26 @SmallTest |
| 27 @Feature({"Cronet"}) |
| 28 public void testQuicLoadUrl() throws Exception { |
| 29 HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig(); |
| 30 String quicURL = QuicTestServer.getServerURL() + "/simple.txt"; |
| 31 config.enableQUIC(true); |
| 32 config.setLibraryName("cronet_tests"); |
| 33 config.addQuicHint(QuicTestServer.getServerHost(), |
| 34 QuicTestServer.getServerPort(), QuicTestServer.getServerPort()); |
| 35 config.setExperimentalQuicConnectionOptions("PACE,IW10,FOO,DEADBEEF"); |
| 36 |
| 37 String[] commandLineArgs = { |
| 38 CronetTestActivity.CONFIG_KEY, config.toString() }; |
| 39 CronetTestActivity activity = |
| 40 launchCronetTestAppWithUrlAndCommandLineArgs(null, |
| 41 commandLineArgs); |
| 42 QuicTestServer.startQuicTestServer(activity.getApplicationContext()); |
| 43 activity.startNetLog(); |
| 44 |
| 45 HashMap<String, String> headers = new HashMap<String, String>(); |
| 46 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener(); |
| 47 |
| 48 HttpUrlRequest request = |
| 49 activity.mRequestFactory.createRequest( |
| 50 quicURL, |
| 51 HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, |
| 52 headers, |
| 53 listener); |
| 54 request.start(); |
| 55 listener.blockForComplete(); |
| 56 assertEquals(200, listener.mHttpStatusCode); |
| 57 assertEquals( |
| 58 "This is a simple text file served by QUIC.\n", listener.mRespon
seAsString); |
| 59 assertEquals("quic/1+spdy/3", listener.mNegotiatedProtocol); |
| 60 activity.stopNetLog(); |
| 61 QuicTestServer.shutdownQuicTestServer(); |
| 62 } |
| 63 } |
OLD | NEW |