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.test.AndroidTestCase; | 7 import android.test.AndroidTestCase; |
8 | 8 |
| 9 import org.chromium.base.PathUtils; |
| 10 |
9 import java.lang.annotation.ElementType; | 11 import java.lang.annotation.ElementType; |
10 import java.lang.annotation.Retention; | 12 import java.lang.annotation.Retention; |
11 import java.lang.annotation.RetentionPolicy; | 13 import java.lang.annotation.RetentionPolicy; |
12 import java.lang.annotation.Target; | 14 import java.lang.annotation.Target; |
13 import java.lang.reflect.Method; | 15 import java.lang.reflect.Method; |
14 import java.net.URL; | 16 import java.net.URL; |
15 | 17 |
16 /** | 18 /** |
17 * Base test class for all CronetTest based tests. | 19 * Base test class for all CronetTest based tests. |
18 */ | 20 */ |
19 public class CronetTestBase extends AndroidTestCase { | 21 public class CronetTestBase extends AndroidTestCase { |
| 22 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "cronet_test"; |
| 23 |
20 private CronetTestFramework mCronetTestFramework; | 24 private CronetTestFramework mCronetTestFramework; |
21 | 25 |
| 26 @Override |
| 27 protected void setUp() throws Exception { |
| 28 super.setUp(); |
| 29 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, g
etContext()); |
| 30 } |
| 31 |
22 /** | 32 /** |
23 * Starts the CronetTest framework. | 33 * Starts the CronetTest framework. |
24 */ | 34 */ |
25 protected CronetTestFramework startCronetTestFramework() { | 35 protected CronetTestFramework startCronetTestFramework() { |
26 return startCronetTestFrameworkWithUrlAndCommandLineArgs(null, null); | 36 return startCronetTestFrameworkWithUrlAndCronetEngineBuilder(null, null)
; |
27 } | 37 } |
28 | 38 |
29 /** | 39 /** |
30 * Starts the CronetTest framework and loads the given URL. The URL can be | 40 * Starts the CronetTest framework and loads the given URL. The URL can be |
31 * null. | 41 * null. |
32 */ | 42 */ |
33 protected CronetTestFramework startCronetTestFrameworkWithUrl(String url) { | 43 protected CronetTestFramework startCronetTestFrameworkWithUrl(String url) { |
34 return startCronetTestFrameworkWithUrlAndCommandLineArgs(url, null); | 44 return startCronetTestFrameworkWithUrlAndCronetEngineBuilder(url, null); |
35 } | 45 } |
36 | 46 |
37 /** | 47 /** |
| 48 * Starts the CronetTest framework using the provided CronetEngine.Builder |
| 49 * and loads the given URL. The URL can be null. |
| 50 */ |
| 51 protected CronetTestFramework startCronetTestFrameworkWithUrlAndCronetEngine
Builder( |
| 52 String url, CronetEngine.Builder builder) { |
| 53 mCronetTestFramework = new CronetTestFramework(url, null, getContext(),
builder); |
| 54 return mCronetTestFramework; |
| 55 } |
| 56 |
| 57 /** |
38 * Starts the CronetTest framework appending the provided command line | 58 * Starts the CronetTest framework appending the provided command line |
39 * arguments and loads the given URL. The URL can be null. | 59 * arguments and loads the given URL. The URL can be null. |
40 */ | 60 */ |
41 protected CronetTestFramework startCronetTestFrameworkWithUrlAndCommandLineA
rgs( | 61 protected CronetTestFramework startCronetTestFrameworkWithUrlAndCommandLineA
rgs( |
42 String url, String[] commandLineArgs) { | 62 String url, String[] commandLineArgs) { |
43 mCronetTestFramework = new CronetTestFramework(url, commandLineArgs, get
Context()); | 63 mCronetTestFramework = new CronetTestFramework(url, commandLineArgs, get
Context(), null); |
44 return mCronetTestFramework; | 64 return mCronetTestFramework; |
45 } | 65 } |
46 | 66 |
47 // Helper method to tell the framework to skip factory init during construct
ion. | 67 // Helper method to tell the framework to skip factory init during construct
ion. |
48 protected CronetTestFramework startCronetTestFrameworkAndSkipFactoryInit() { | 68 protected CronetTestFramework startCronetTestFrameworkAndSkipFactoryInit() { |
49 String[] commandLineArgs = { | 69 String[] commandLineArgs = { |
50 CronetTestFramework.LIBRARY_INIT_KEY, CronetTestFramework.LIBRAR
Y_INIT_SKIP}; | 70 CronetTestFramework.LIBRARY_INIT_KEY, CronetTestFramework.LIBRAR
Y_INIT_SKIP}; |
51 mCronetTestFramework = | 71 mCronetTestFramework = |
52 startCronetTestFrameworkWithUrlAndCommandLineArgs(null, commandL
ineArgs); | 72 startCronetTestFrameworkWithUrlAndCommandLineArgs(null, commandL
ineArgs); |
53 return mCronetTestFramework; | 73 return mCronetTestFramework; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 @Retention(RetentionPolicy.RUNTIME) | 106 @Retention(RetentionPolicy.RUNTIME) |
87 public @interface CompareDefaultWithCronet { | 107 public @interface CompareDefaultWithCronet { |
88 } | 108 } |
89 | 109 |
90 @Target(ElementType.METHOD) | 110 @Target(ElementType.METHOD) |
91 @Retention(RetentionPolicy.RUNTIME) | 111 @Retention(RetentionPolicy.RUNTIME) |
92 public @interface OnlyRunCronetHttpURLConnection { | 112 public @interface OnlyRunCronetHttpURLConnection { |
93 } | 113 } |
94 | 114 |
95 } | 115 } |
OLD | NEW |