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

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

Issue 1487723002: [Cronet] Replace setExperimentalQuicConnectionOptions with a more general API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
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.LargeTest; 7 import android.test.suitebuilder.annotation.LargeTest;
8 import android.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
11 import org.chromium.base.annotations.SuppressFBWarnings; 11 import org.chromium.base.annotations.SuppressFBWarnings;
12 import org.chromium.base.test.util.Feature; 12 import org.chromium.base.test.util.Feature;
13 import org.json.JSONObject;
13 14
14 import java.io.File; 15 import java.io.File;
15 import java.io.FileInputStream; 16 import java.io.FileInputStream;
16 import java.io.FileNotFoundException; 17 import java.io.FileNotFoundException;
17 import java.io.IOException; 18 import java.io.IOException;
18 import java.util.HashMap; 19 import java.util.HashMap;
19 20
20 /** 21 /**
21 * Tests making requests using QUIC. 22 * Tests making requests using QUIC.
22 */ 23 */
23 public class QuicTest extends CronetTestBase { 24 public class QuicTest extends CronetTestBase {
24 private static final String TAG = "cr.QuicTest"; 25 private static final String TAG = "cr.QuicTest";
25 private static final String[] CERTS_USED = {"quic_test.example.com.crt"}; 26 private static final String[] CERTS_USED = {"quic_test.example.com.crt"};
26 private CronetTestFramework mTestFramework; 27 private CronetTestFramework mTestFramework;
27 28
28 @Override 29 @Override
29 protected void setUp() throws Exception { 30 protected void setUp() throws Exception {
30 super.setUp(); 31 super.setUp();
31 // Load library first, since we need the Quic test server's URL. 32 // Load library first, since we need the Quic test server's URL.
32 System.loadLibrary("cronet_tests"); 33 System.loadLibrary("cronet_tests");
33 QuicTestServer.startQuicTestServer(getContext()); 34 QuicTestServer.startQuicTestServer(getContext());
34 35
35 CronetEngine.Builder builder = new CronetEngine.Builder(getContext()); 36 CronetEngine.Builder builder = new CronetEngine.Builder(getContext());
36 builder.enableQUIC(true); 37 builder.enableQUIC(true);
37 builder.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getSe rverPort(), 38 builder.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getSe rverPort(),
38 QuicTestServer.getServerPort()); 39 QuicTestServer.getServerPort());
39 builder.setExperimentalQuicConnectionOptions("PACE,IW10,FOO,DEADBEEF"); 40
41 JSONObject quicParams =
42 new JSONObject().put("connection_options", "PACE,IW10,FOO,DEADBE EF");
43 JSONObject experimentalOptions = new JSONObject().put("QUIC", quicParams );
44 builder.setExperimentalOptions(experimentalOptions.toString());
45
40 builder.setMockCertVerifierForTesting(MockCertVerifier.createMockCertVer ifier(CERTS_USED)); 46 builder.setMockCertVerifierForTesting(MockCertVerifier.createMockCertVer ifier(CERTS_USED));
41 builder.setStoragePath(CronetTestFramework.getTestStorage(getContext())) ; 47 builder.setStoragePath(CronetTestFramework.getTestStorage(getContext())) ;
42 builder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 10 00 * 1024); 48 builder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 10 00 * 1024);
43 49
44 mTestFramework = startCronetTestFrameworkWithUrlAndCronetEngineBuilder(n ull, builder); 50 mTestFramework = startCronetTestFrameworkWithUrlAndCronetEngineBuilder(n ull, builder);
45 } 51 }
46 52
47 @Override 53 @Override
48 protected void tearDown() throws Exception { 54 protected void tearDown() throws Exception {
49 QuicTestServer.shutdownQuicTestServer(); 55 QuicTestServer.shutdownQuicTestServer();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE") 155 @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE")
150 private boolean fileContainsString(String filename, String content) throws I OException { 156 private boolean fileContainsString(String filename, String content) throws I OException {
151 File file = new File(CronetTestFramework.getTestStorage(getContext()) + "/" + filename); 157 File file = new File(CronetTestFramework.getTestStorage(getContext()) + "/" + filename);
152 FileInputStream fileInputStream = new FileInputStream(file); 158 FileInputStream fileInputStream = new FileInputStream(file);
153 byte[] data = new byte[(int) file.length()]; 159 byte[] data = new byte[(int) file.length()];
154 fileInputStream.read(data); 160 fileInputStream.read(data);
155 fileInputStream.close(); 161 fileInputStream.close();
156 return new String(data, "UTF-8").contains(content); 162 return new String(data, "UTF-8").contains(content);
157 } 163 }
158 } 164 }
OLDNEW
« no previous file with comments | « components/cronet/android/api/src/org/chromium/net/CronetEngine.java ('k') | components/cronet/url_request_context_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698