Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java

Issue 1039693003: [Cronet] Add support to run quic_simple_server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Suppress fb warning Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..2e8e14c7f4c94553dad68cab72dbb5b43779f356
--- /dev/null
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java
@@ -0,0 +1,63 @@
+// Copyright 2015 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;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.base.test.util.Feature;
+
+import java.util.HashMap;
+
+/**
+ * Tests making requests using QUIC.
+ */
+public class QuicTest extends CronetTestBase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ // Loads library first since native functions are used to retrieve
+ // QuicTestServer info before config is constructed.
+ System.loadLibrary("cronet_tests");
+ }
+
+ @SmallTest
+ @Feature({"Cronet"})
+ public void testQuicLoadUrl() throws Exception {
+ HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig();
+ 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");
+
+ String[] commandLineArgs = {
+ CronetTestActivity.CONFIG_KEY, config.toString() };
+ CronetTestActivity activity =
+ launchCronetTestAppWithUrlAndCommandLineArgs(null,
+ commandLineArgs);
+ QuicTestServer.startQuicTestServer(activity.getApplicationContext());
+ activity.startNetLog();
+
+ HashMap<String, String> headers = new HashMap<String, String>();
+ TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
+
+ HttpUrlRequest request =
+ activity.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);
+ activity.stopNetLog();
+ QuicTestServer.shutdownQuicTestServer();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698