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.content.ContextWrapper; | 8 import android.content.ContextWrapper; |
9 import android.os.ConditionVariable; | 9 import android.os.ConditionVariable; |
10 import android.os.Handler; | 10 import android.os.Handler; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 183 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
184 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr
lRequestBuilder( | 184 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr
lRequestBuilder( |
185 NativeTestServer.getEchoHeaderURL(userAgentName), callback, call
back.getExecutor()); | 185 NativeTestServer.getEchoHeaderURL(userAgentName), callback, call
back.getExecutor()); |
186 urlRequestBuilder.build().start(); | 186 urlRequestBuilder.build().start(); |
187 callback.blockForDone(); | 187 callback.blockForDone(); |
188 assertEquals(userAgentValue, callback.mResponseAsString); | 188 assertEquals(userAgentValue, callback.mResponseAsString); |
189 } | 189 } |
190 | 190 |
191 @SmallTest | 191 @SmallTest |
192 @Feature({"Cronet"}) | 192 @Feature({"Cronet"}) |
193 @OnlyRunNativeCronet | |
194 public void testDataReductionProxyEnabled() throws Exception { | |
195 final CronetTestFramework testFramework = startCronetTestFrameworkAndSki
pLibraryInit(); | |
196 | |
197 // Ensure native code is loaded before trying to start test server. | |
198 new ExperimentalCronetEngine.Builder(getContext()).build().shutdown(); | |
199 | |
200 assertTrue(NativeTestServer.startNativeTestServer(getContext())); | |
201 if (!NativeTestServer.isDataReductionProxySupported()) { | |
202 return; | |
203 } | |
204 String serverHostPort = NativeTestServer.getHostPort(); | |
205 | |
206 // Enable the Data Reduction Proxy and configure it to use the test | |
207 // server as its primary proxy, and to check successfully that this | |
208 // proxy is OK to use. | |
209 ExperimentalCronetEngine.Builder cronetEngineBuilder = | |
210 new ExperimentalCronetEngine.Builder(getContext()); | |
211 cronetEngineBuilder.enableDataReductionProxy("test-key"); | |
212 cronetEngineBuilder.setDataReductionProxyOptions(serverHostPort, "unused
.net:9999", | |
213 NativeTestServer.getFileURL("/secureproxychecksuccess.txt")); | |
214 testFramework.mCronetEngine = (CronetEngineBase) cronetEngineBuilder.bui
ld(); | |
215 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | |
216 | |
217 // Construct and start a request that can only be returned by the test | |
218 // server. This request will fail if the configuration logic for the | |
219 // Data Reduction Proxy is not used. | |
220 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr
lRequestBuilder( | |
221 "http://DomainThatDoesnt.Resolve/datareductionproxysuccess.txt",
callback, | |
222 callback.getExecutor()); | |
223 urlRequestBuilder.build().start(); | |
224 callback.blockForDone(); | |
225 | |
226 // Verify that the request is successful and that the Data Reduction | |
227 // Proxy logic configured to use the test server as its proxy. | |
228 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); | |
229 assertEquals(serverHostPort, callback.mResponseInfo.getProxyServer()); | |
230 assertEquals("http://DomainThatDoesnt.Resolve/datareductionproxysuccess.
txt", | |
231 callback.mResponseInfo.getUrl()); | |
232 } | |
233 | |
234 @SmallTest | |
235 @Feature({"Cronet"}) | |
236 @DisabledTest(message = "Disabled due to flaky assert. See crbug.com/710626"
) | 193 @DisabledTest(message = "Disabled due to flaky assert. See crbug.com/710626"
) |
237 public void testRealTimeNetworkQualityObservationsNotEnabled() throws Except
ion { | 194 public void testRealTimeNetworkQualityObservationsNotEnabled() throws Except
ion { |
238 ExperimentalCronetEngine.Builder mCronetEngineBuilder = | 195 ExperimentalCronetEngine.Builder mCronetEngineBuilder = |
239 new ExperimentalCronetEngine.Builder(getContext()); | 196 new ExperimentalCronetEngine.Builder(getContext()); |
240 final CronetTestFramework testFramework = | 197 final CronetTestFramework testFramework = |
241 startCronetTestFrameworkWithUrlAndCronetEngineBuilder(null, mCro
netEngineBuilder); | 198 startCronetTestFrameworkWithUrlAndCronetEngineBuilder(null, mCro
netEngineBuilder); |
242 Executor networkQualityExecutor = Executors.newSingleThreadExecutor(); | 199 Executor networkQualityExecutor = Executors.newSingleThreadExecutor(); |
243 TestNetworkQualityRttListener rttListener = | 200 TestNetworkQualityRttListener rttListener = |
244 new TestNetworkQualityRttListener(networkQualityExecutor); | 201 new TestNetworkQualityRttListener(networkQualityExecutor); |
245 TestNetworkQualityThroughputListener throughputListener = | 202 TestNetworkQualityThroughputListener throughputListener = |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 startCronetTestFramework(); | 1364 startCronetTestFramework(); |
1408 // Verify CronetEngine.Builder config is passed down accurately to nativ
e code. | 1365 // Verify CronetEngine.Builder config is passed down accurately to nativ
e code. |
1409 ExperimentalCronetEngine.Builder builder = | 1366 ExperimentalCronetEngine.Builder builder = |
1410 new ExperimentalCronetEngine.Builder(getContext()); | 1367 new ExperimentalCronetEngine.Builder(getContext()); |
1411 builder.enableHttp2(false); | 1368 builder.enableHttp2(false); |
1412 builder.enableQuic(true); | 1369 builder.enableQuic(true); |
1413 builder.enableSdch(true); | 1370 builder.enableSdch(true); |
1414 builder.addQuicHint("example.com", 12, 34); | 1371 builder.addQuicHint("example.com", 12, 34); |
1415 builder.setCertVerifierData("test_cert_verifier_data"); | 1372 builder.setCertVerifierData("test_cert_verifier_data"); |
1416 builder.enableHttpCache(HTTP_CACHE_IN_MEMORY, 54321); | 1373 builder.enableHttpCache(HTTP_CACHE_IN_MEMORY, 54321); |
1417 builder.enableDataReductionProxy("abcd"); | |
1418 builder.setUserAgent("efgh"); | 1374 builder.setUserAgent("efgh"); |
1419 builder.setExperimentalOptions("ijkl"); | 1375 builder.setExperimentalOptions("ijkl"); |
1420 builder.setDataReductionProxyOptions("mnop", "qrst", "uvwx"); | |
1421 builder.setStoragePath(CronetTestFramework.getTestStorage(getContext()))
; | 1376 builder.setStoragePath(CronetTestFramework.getTestStorage(getContext()))
; |
1422 builder.enablePublicKeyPinningBypassForLocalTrustAnchors(false); | 1377 builder.enablePublicKeyPinningBypassForLocalTrustAnchors(false); |
1423 nativeVerifyUrlRequestContextConfig( | 1378 nativeVerifyUrlRequestContextConfig( |
1424 CronetUrlRequestContext.createNativeUrlRequestContextConfig( | 1379 CronetUrlRequestContext.createNativeUrlRequestContextConfig( |
1425 (CronetEngineBuilderImpl) builder.mBuilderDelegate), | 1380 (CronetEngineBuilderImpl) builder.mBuilderDelegate), |
1426 CronetTestFramework.getTestStorage(getContext())); | 1381 CronetTestFramework.getTestStorage(getContext())); |
1427 } | 1382 } |
1428 | 1383 |
1429 // Verifies that CronetEngine.Builder config from testCronetEngineBuilderCon
fig() is properly | 1384 // Verifies that CronetEngine.Builder config from testCronetEngineBuilderCon
fig() is properly |
1430 // translated to a native UrlRequestContextConfig. | 1385 // translated to a native UrlRequestContextConfig. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 1460 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
1506 URL requestUrl = | 1461 URL requestUrl = |
1507 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl
.getFile()); | 1462 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl
.getFile()); |
1508 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr
lRequestBuilder( | 1463 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr
lRequestBuilder( |
1509 requestUrl.toString(), callback, callback.getExecutor()); | 1464 requestUrl.toString(), callback, callback.getExecutor()); |
1510 urlRequestBuilder.build().start(); | 1465 urlRequestBuilder.build().start(); |
1511 callback.blockForDone(); | 1466 callback.blockForDone(); |
1512 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); | 1467 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); |
1513 } | 1468 } |
1514 } | 1469 } |
OLD | NEW |