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

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

Issue 2361413002: Obliterate legacy cronet API. All of its users have been migrated. (Closed)
Patch Set: Created 4 years, 2 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 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.os.ConditionVariable; 7 import android.os.ConditionVariable;
8 import android.test.suitebuilder.annotation.LargeTest; 8 import android.test.suitebuilder.annotation.LargeTest;
9 import android.test.suitebuilder.annotation.SmallTest;
10 9
11 import org.chromium.base.Log; 10 import org.chromium.base.Log;
12 import org.chromium.base.annotations.SuppressFBWarnings; 11 import org.chromium.base.annotations.SuppressFBWarnings;
13 import org.chromium.base.test.util.Feature; 12 import org.chromium.base.test.util.Feature;
14 import org.chromium.net.CronetTestBase.OnlyRunNativeCronet; 13 import org.chromium.net.CronetTestBase.OnlyRunNativeCronet;
15 import org.json.JSONObject; 14 import org.json.JSONObject;
16 15
17 import java.io.File; 16 import java.io.File;
18 import java.io.FileInputStream; 17 import java.io.FileInputStream;
19 import java.io.FileNotFoundException; 18 import java.io.FileNotFoundException;
20 import java.io.IOException; 19 import java.io.IOException;
21 import java.util.HashMap;
22 import java.util.concurrent.Executors; 20 import java.util.concurrent.Executors;
23 21
24 /** 22 /**
25 * Tests making requests using QUIC. 23 * Tests making requests using QUIC.
26 */ 24 */
27 public class QuicTest extends CronetTestBase { 25 public class QuicTest extends CronetTestBase {
28 private static final String TAG = "cr.QuicTest"; 26 private static final String TAG = "cr.QuicTest";
29 private CronetTestFramework mTestFramework; 27 private CronetTestFramework mTestFramework;
30 private CronetEngine.Builder mBuilder; 28 private CronetEngine.Builder mBuilder;
31 29
(...skipping 29 matching lines...) Expand all
61 mBuilder.setStoragePath(CronetTestFramework.getTestStorage(getContext()) ); 59 mBuilder.setStoragePath(CronetTestFramework.getTestStorage(getContext()) );
62 mBuilder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 1 000 * 1024); 60 mBuilder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 1 000 * 1024);
63 } 61 }
64 62
65 @Override 63 @Override
66 protected void tearDown() throws Exception { 64 protected void tearDown() throws Exception {
67 QuicTestServer.shutdownQuicTestServer(); 65 QuicTestServer.shutdownQuicTestServer();
68 super.tearDown(); 66 super.tearDown();
69 } 67 }
70 68
71 @SmallTest
72 @Feature({"Cronet"})
73 @SuppressWarnings("deprecation")
74 @OnlyRunNativeCronet
75 public void testQuicLoadUrl_LegacyAPI() throws Exception {
76 String[] commandLineArgs = {
77 CronetTestFramework.LIBRARY_INIT_KEY, CronetTestFramework.Librar yInitType.LEGACY};
78 mTestFramework = new CronetTestFramework(null, commandLineArgs, getConte xt(), mBuilder);
79 String quicURL = QuicTestServer.getServerURL() + "/simple.txt";
80
81 HashMap<String, String> headers = new HashMap<String, String>();
82 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
83
84 // Although the native stack races QUIC and SPDY for the first request,
85 // since there is no http server running on the corresponding TCP port,
86 // QUIC will always succeed with a 200 (see
87 // net::HttpStreamFactoryImpl::Request::OnStreamFailed).
88 HttpUrlRequest request = mTestFramework.mRequestFactory.createRequest(
89 quicURL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listen er);
90 request.start();
91 listener.blockForComplete();
92 assertEquals(200, listener.mHttpStatusCode);
93 assertEquals(
94 "This is a simple text file served by QUIC.\n",
95 listener.mResponseAsString);
96 assertEquals("quic/1+spdy/3", listener.mNegotiatedProtocol);
97 }
98
99 @LargeTest 69 @LargeTest
100 @Feature({"Cronet"}) 70 @Feature({"Cronet"})
101 @OnlyRunNativeCronet 71 @OnlyRunNativeCronet
102 public void testQuicLoadUrl() throws Exception { 72 public void testQuicLoadUrl() throws Exception {
103 mTestFramework = startCronetTestFrameworkWithUrlAndCronetEngineBuilder(n ull, mBuilder); 73 mTestFramework = startCronetTestFrameworkWithUrlAndCronetEngineBuilder(n ull, mBuilder);
104 String quicURL = QuicTestServer.getServerURL() + "/simple.txt"; 74 String quicURL = QuicTestServer.getServerURL() + "/simple.txt";
105 TestUrlRequestCallback callback = new TestUrlRequestCallback(); 75 TestUrlRequestCallback callback = new TestUrlRequestCallback();
106 76
107 // Although the native stack races QUIC and SPDY for the first request, 77 // Although the native stack races QUIC and SPDY for the first request,
108 // since there is no http server running on the corresponding TCP port, 78 // since there is no http server running on the corresponding TCP port,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 assertTrue(rttListener.rttObservationCount(2) > 0); 195 assertTrue(rttListener.rttObservationCount(2) > 0);
226 196
227 // Verify that effective connection type callback is received and 197 // Verify that effective connection type callback is received and
228 // effective connection type is correctly set. 198 // effective connection type is correctly set.
229 assertTrue(mTestFramework.mCronetEngine.getEffectiveConnectionType() 199 assertTrue(mTestFramework.mCronetEngine.getEffectiveConnectionType()
230 != EffectiveConnectionType.TYPE_UNKNOWN); 200 != EffectiveConnectionType.TYPE_UNKNOWN);
231 201
232 mTestFramework.mCronetEngine.shutdown(); 202 mTestFramework.mCronetEngine.shutdown();
233 } 203 }
234 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698