| 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 java.lang.annotation.ElementType; | 9 import java.lang.annotation.ElementType; |
| 10 import java.lang.annotation.Retention; | 10 import java.lang.annotation.Retention; |
| 11 import java.lang.annotation.RetentionPolicy; | 11 import java.lang.annotation.RetentionPolicy; |
| 12 import java.lang.annotation.Target; | 12 import java.lang.annotation.Target; |
| 13 import java.lang.reflect.Method; | 13 import java.lang.reflect.Method; |
| 14 import java.net.URL; | 14 import java.net.URL; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Base test class for all CronetTest based tests. | 17 * Base test class for all CronetTest based tests. |
| 18 */ | 18 */ |
| 19 public class CronetTestBase extends AndroidTestCase { | 19 public class CronetTestBase extends AndroidTestCase { |
| 20 private CronetTestFramework mCronetTestFramework; | 20 private CronetTestFramework mCronetTestFramework; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Starts the CronetTest framework. | 23 * Starts the CronetTest framework. |
| 24 */ | 24 */ |
| 25 protected CronetTestFramework startCronetTestFramework() { | 25 protected CronetTestFramework startCronetTestFramework() { |
| 26 return startCronetTestFrameworkWithUrlAndCommandLineArgs(null, null); | 26 return startCronetTestFrameworkWithUrlAndCronetEngineBuilder(null, null)
; |
| 27 } | 27 } |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Starts the CronetTest framework and loads the given URL. The URL can be | 30 * Starts the CronetTest framework and loads the given URL. The URL can be |
| 31 * null. | 31 * null. |
| 32 */ | 32 */ |
| 33 protected CronetTestFramework startCronetTestFrameworkWithUrl(String url) { | 33 protected CronetTestFramework startCronetTestFrameworkWithUrl(String url) { |
| 34 return startCronetTestFrameworkWithUrlAndCommandLineArgs(url, null); | 34 return startCronetTestFrameworkWithUrlAndCronetEngineBuilder(url, null); |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Starts the CronetTest framework using the provided CronetEngine.Builder |
| 39 * and loads the given URL. The URL can be null. |
| 40 */ |
| 41 protected CronetTestFramework startCronetTestFrameworkWithUrlAndCronetEngine
Builder( |
| 42 String url, CronetEngine.Builder builder) { |
| 43 mCronetTestFramework = new CronetTestFramework(url, null, getContext(),
builder); |
| 44 return mCronetTestFramework; |
| 45 } |
| 46 |
| 47 /** |
| 38 * Starts the CronetTest framework appending the provided command line | 48 * Starts the CronetTest framework appending the provided command line |
| 39 * arguments and loads the given URL. The URL can be null. | 49 * arguments and loads the given URL. The URL can be null. |
| 40 */ | 50 */ |
| 41 protected CronetTestFramework startCronetTestFrameworkWithUrlAndCommandLineA
rgs( | 51 protected CronetTestFramework startCronetTestFrameworkWithUrlAndCommandLineA
rgs( |
| 42 String url, String[] commandLineArgs) { | 52 String url, String[] commandLineArgs) { |
| 43 mCronetTestFramework = new CronetTestFramework(url, commandLineArgs, get
Context()); | 53 mCronetTestFramework = new CronetTestFramework(url, commandLineArgs, get
Context(), null); |
| 44 return mCronetTestFramework; | 54 return mCronetTestFramework; |
| 45 } | 55 } |
| 46 | 56 |
| 47 // Helper method to tell the framework to skip factory init during construct
ion. | 57 // Helper method to tell the framework to skip factory init during construct
ion. |
| 48 protected CronetTestFramework startCronetTestFrameworkAndSkipFactoryInit() { | 58 protected CronetTestFramework startCronetTestFrameworkAndSkipFactoryInit() { |
| 49 String[] commandLineArgs = { | 59 String[] commandLineArgs = { |
| 50 CronetTestFramework.LIBRARY_INIT_KEY, CronetTestFramework.LIBRAR
Y_INIT_SKIP}; | 60 CronetTestFramework.LIBRARY_INIT_KEY, CronetTestFramework.LIBRAR
Y_INIT_SKIP}; |
| 51 mCronetTestFramework = | 61 mCronetTestFramework = |
| 52 startCronetTestFrameworkWithUrlAndCommandLineArgs(null, commandL
ineArgs); | 62 startCronetTestFrameworkWithUrlAndCommandLineArgs(null, commandL
ineArgs); |
| 53 return mCronetTestFramework; | 63 return mCronetTestFramework; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 @Retention(RetentionPolicy.RUNTIME) | 96 @Retention(RetentionPolicy.RUNTIME) |
| 87 public @interface CompareDefaultWithCronet { | 97 public @interface CompareDefaultWithCronet { |
| 88 } | 98 } |
| 89 | 99 |
| 90 @Target(ElementType.METHOD) | 100 @Target(ElementType.METHOD) |
| 91 @Retention(RetentionPolicy.RUNTIME) | 101 @Retention(RetentionPolicy.RUNTIME) |
| 92 public @interface OnlyRunCronetHttpURLConnection { | 102 public @interface OnlyRunCronetHttpURLConnection { |
| 93 } | 103 } |
| 94 | 104 |
| 95 } | 105 } |
| OLD | NEW |