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; |
11 import android.os.Looper; | 11 import android.os.Looper; |
12 import android.test.suitebuilder.annotation.SmallTest; | 12 import android.test.suitebuilder.annotation.SmallTest; |
13 | 13 |
14 import org.chromium.base.PathUtils; | 14 import org.chromium.base.PathUtils; |
| 15 import org.chromium.base.annotations.JNINamespace; |
15 import org.chromium.base.test.util.Feature; | 16 import org.chromium.base.test.util.Feature; |
16 import org.chromium.net.TestUrlRequestCallback.ResponseStep; | 17 import org.chromium.net.TestUrlRequestCallback.ResponseStep; |
17 | 18 |
18 import java.io.BufferedReader; | 19 import java.io.BufferedReader; |
19 import java.io.File; | 20 import java.io.File; |
20 import java.io.FileReader; | 21 import java.io.FileReader; |
21 import java.util.LinkedList; | 22 import java.util.LinkedList; |
22 import java.util.NoSuchElementException; | 23 import java.util.NoSuchElementException; |
23 import java.util.concurrent.Executor; | 24 import java.util.concurrent.Executor; |
24 | 25 |
25 /** | 26 /** |
26 * Test CronetEngine. | 27 * Test CronetEngine. |
27 */ | 28 */ |
| 29 @JNINamespace("cronet") |
28 public class CronetUrlRequestContextTest extends CronetTestBase { | 30 public class CronetUrlRequestContextTest extends CronetTestBase { |
29 // URLs used for tests. | 31 // URLs used for tests. |
30 private static final String TEST_URL = "http://127.0.0.1:8000"; | 32 private static final String TEST_URL = "http://127.0.0.1:8000"; |
31 private static final String URL_404 = "http://127.0.0.1:8000/notfound404"; | 33 private static final String URL_404 = "http://127.0.0.1:8000/notfound404"; |
32 private static final String MOCK_CRONET_TEST_FAILED_URL = | 34 private static final String MOCK_CRONET_TEST_FAILED_URL = |
33 "http://mock.failed.request/-2"; | 35 "http://mock.failed.request/-2"; |
34 private static final String MOCK_CRONET_TEST_SUCCESS_URL = | 36 private static final String MOCK_CRONET_TEST_SUCCESS_URL = |
35 "http://mock.http/success.txt"; | 37 "http://mock.http/success.txt"; |
36 | 38 |
37 CronetTestFramework mTestFramework; | 39 CronetTestFramework mTestFramework; |
(...skipping 728 matching lines...) Loading... |
766 CronetEngine firstEngine = | 768 CronetEngine firstEngine = |
767 new CronetUrlRequestContext(mTestFramework.createCronetEngineBui
lder(getContext())); | 769 new CronetUrlRequestContext(mTestFramework.createCronetEngineBui
lder(getContext())); |
768 CronetEngine secondEngine = new CronetUrlRequestContext( | 770 CronetEngine secondEngine = new CronetUrlRequestContext( |
769 mTestFramework.createCronetEngineBuilder(getContext().getApplica
tionContext())); | 771 mTestFramework.createCronetEngineBuilder(getContext().getApplica
tionContext())); |
770 CronetEngine thirdEngine = new CronetUrlRequestContext( | 772 CronetEngine thirdEngine = new CronetUrlRequestContext( |
771 mTestFramework.createCronetEngineBuilder(new ContextWrapper(getC
ontext()))); | 773 mTestFramework.createCronetEngineBuilder(new ContextWrapper(getC
ontext()))); |
772 firstEngine.shutdown(); | 774 firstEngine.shutdown(); |
773 secondEngine.shutdown(); | 775 secondEngine.shutdown(); |
774 thirdEngine.shutdown(); | 776 thirdEngine.shutdown(); |
775 } | 777 } |
| 778 |
| 779 @SmallTest |
| 780 @Feature({"Cronet"}) |
| 781 public void testCronetEngineBuilderConfig() throws Exception { |
| 782 // This is to prompt load of native library. |
| 783 startCronetTestFramework(); |
| 784 // Verify CronetEngine.Builder config is passed down accurately to nativ
e code. |
| 785 CronetEngine.Builder builder = new CronetEngine.Builder(getContext()); |
| 786 builder.enableHTTP2(false); |
| 787 builder.enableQUIC(true); |
| 788 builder.enableSDCH(true); |
| 789 builder.addQuicHint("example.com", 12, 34); |
| 790 builder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 54321
); |
| 791 builder.enableDataReductionProxy("abcd"); |
| 792 builder.setUserAgent("efgh"); |
| 793 builder.setExperimentalQuicConnectionOptions("ijkl"); |
| 794 builder.setDataReductionProxyOptions("mnop", "qrst", "uvwx"); |
| 795 builder.setStoragePath(CronetTestFramework.getTestStorage(getContext()))
; |
| 796 nativeVerifyUrlRequestContextConfig( |
| 797 CronetUrlRequestContext.createNativeUrlRequestContextConfig(buil
der), |
| 798 CronetTestFramework.getTestStorage(getContext())); |
| 799 } |
| 800 |
| 801 // Verifies that CronetEngine.Builder config from testCronetEngineBuilderCon
fig() is properly |
| 802 // translated to a native UrlRequestContextConfig. |
| 803 private static native void nativeVerifyUrlRequestContextConfig(long config,
String storagePath); |
776 } | 804 } |
OLD | NEW |