OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.content.Context; | 7 import android.content.Context; |
8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 | 9 |
10 import org.chromium.base.PathUtils; | 10 import org.chromium.base.PathUtils; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 try { | 127 try { |
128 request.setUploadData(null, uploadData); | 128 request.setUploadData(null, uploadData); |
129 fail("setUploadData should throw on null content type"); | 129 fail("setUploadData should throw on null content type"); |
130 } catch (NullPointerException e) { | 130 } catch (NullPointerException e) { |
131 // Nothing to do here. | 131 // Nothing to do here. |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 @SmallTest | 135 @SmallTest |
136 @Feature({"Cronet"}) | 136 @Feature({"Cronet"}) |
137 public void disabled_testQuicLoadUrl() throws Exception { | |
138 HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig(); | |
139 // TODO(mef): Test Quic end-to-end using local QUIC server. | |
140 String quicURL = "https://www.google.com:443"; | |
141 String quicNegotiatedProtocol = "quic/1+spdy/3"; | |
142 config.enableQUIC(true); | |
143 config.addQuicHint("www.google.com", 443, 443); | |
144 config.setExperimentalQuicConnectionOptions("PACE,IW10,FOO,DEADBEEF"); | |
145 | |
146 String[] commandLineArgs = { | |
147 CronetTestActivity.CONFIG_KEY, config.toString() }; | |
148 CronetTestActivity activity = | |
149 launchCronetTestAppWithUrlAndCommandLineArgs(null, | |
150 commandLineArgs); | |
151 activity.startNetLog(); | |
152 | |
153 HashMap<String, String> headers = new HashMap<String, String>(); | |
154 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener(); | |
155 | |
156 // Try several times as first request may not use QUIC. | |
157 // TODO(mef): Remove loop after adding http server properties manager. | |
158 for (int i = 0; i < 10; ++i) { | |
159 HttpUrlRequest request = | |
160 activity.mRequestFactory.createRequest( | |
161 quicURL, | |
162 HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, | |
163 headers, | |
164 listener); | |
165 request.start(); | |
166 listener.blockForComplete(); | |
167 assertEquals(200, listener.mHttpStatusCode); | |
168 if (listener.mNegotiatedProtocol.equals(quicNegotiatedProtocol)) { | |
169 break; | |
170 } | |
171 Thread.sleep(1000); | |
172 listener.resetComplete(); | |
173 } | |
174 | |
175 assertEquals(quicNegotiatedProtocol, listener.mNegotiatedProtocol); | |
176 activity.stopNetLog(); | |
177 } | |
178 | |
179 @SmallTest | |
180 @Feature({"Cronet"}) | |
181 public void testLegacyLoadUrl() throws Exception { | 137 public void testLegacyLoadUrl() throws Exception { |
182 HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig(); | 138 HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig(); |
183 config.enableLegacyMode(true); | 139 config.enableLegacyMode(true); |
184 // TODO(mef) fix tests so that library isn't loaded for legacy stack | 140 // TODO(mef) fix tests so that library isn't loaded for legacy stack |
185 config.setLibraryName("cronet_tests"); | 141 config.setLibraryName("cronet_tests"); |
186 | 142 |
187 String[] commandLineArgs = { | 143 String[] commandLineArgs = { |
188 CronetTestActivity.CONFIG_KEY, config.toString() }; | 144 CronetTestActivity.CONFIG_KEY, config.toString() }; |
189 CronetTestActivity activity = | 145 CronetTestActivity activity = |
190 launchCronetTestAppWithUrlAndCommandLineArgs(URL, | 146 launchCronetTestAppWithUrlAndCommandLineArgs(URL, |
(...skipping 17 matching lines...) Expand all Loading... |
208 URL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener); | 164 URL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener); |
209 request.setHttpMethod("HEAD"); | 165 request.setHttpMethod("HEAD"); |
210 request.start(); | 166 request.start(); |
211 listener.blockForComplete(); | 167 listener.blockForComplete(); |
212 assertEquals(200, listener.mHttpStatusCode); | 168 assertEquals(200, listener.mHttpStatusCode); |
213 // HEAD requests do not get any response data and Content-Length must be | 169 // HEAD requests do not get any response data and Content-Length must be |
214 // ignored. | 170 // ignored. |
215 assertEquals(0, listener.mResponseAsBytes.length); | 171 assertEquals(0, listener.mResponseAsBytes.length); |
216 } | 172 } |
217 } | 173 } |
OLD | NEW |