Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java

Issue 1536433002: [Cronet] Get Cronet performance test running again (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add GN support Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 9 import org.chromium.base.PathUtils;
10 10
11 import java.lang.annotation.ElementType; 11 import java.lang.annotation.ElementType;
12 import java.lang.annotation.Retention; 12 import java.lang.annotation.Retention;
13 import java.lang.annotation.RetentionPolicy; 13 import java.lang.annotation.RetentionPolicy;
14 import java.lang.annotation.Target; 14 import java.lang.annotation.Target;
15 import java.lang.reflect.Method; 15 import java.lang.reflect.Method;
16 import java.net.URL; 16 import java.net.URL;
17 17
18 /** 18 /**
19 * Base test class for all CronetTest based tests. 19 * Base test class for all CronetTest based tests.
20 */ 20 */
21 public class CronetTestBase extends AndroidTestCase { 21 public class CronetTestBase extends AndroidTestCase {
22 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "cronet_test"; 22 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "cronet_test";
23 private static final String LOOPBACK_ADDRESS = "127.0.0.1";
23 24
24 private CronetTestFramework mCronetTestFramework; 25 private CronetTestFramework mCronetTestFramework;
25 // {@code true} when test is being run against system HttpURLConnection impl ementation. 26 // {@code true} when test is being run against system HttpURLConnection impl ementation.
26 private boolean mTestingSystemHttpURLConnection; 27 private boolean mTestingSystemHttpURLConnection;
27 private boolean mTestingJavaImpl = false; 28 private boolean mTestingJavaImpl = false;
28 29
29 @Override 30 @Override
30 protected void setUp() throws Exception { 31 protected void setUp() throws Exception {
31 super.setUp(); 32 super.setUp();
32 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, g etContext()); 33 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, g etContext());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 protected void registerHostResolver(CronetTestFramework framework) { 157 protected void registerHostResolver(CronetTestFramework framework) {
157 registerHostResolver(framework, false); 158 registerHostResolver(framework, false);
158 } 159 }
159 160
160 /** 161 /**
161 * Registers test host resolver. 162 * Registers test host resolver.
162 * 163 *
163 * @param isLegacyAPI true if the test should use the legacy API. 164 * @param isLegacyAPI true if the test should use the legacy API.
164 */ 165 */
165 protected void registerHostResolver(CronetTestFramework framework, boolean i sLegacyAPI) { 166 protected void registerHostResolver(CronetTestFramework framework, boolean i sLegacyAPI) {
166 long urlRequestContextAdapter;
167 if (isLegacyAPI) { 167 if (isLegacyAPI) {
168 urlRequestContextAdapter = ((ChromiumUrlRequestFactory) framework.mR equestFactory) 168 CronetTestUtil.registerHostResolverProc(framework.mRequestFactory, L OOPBACK_ADDRESS);
169 .getRequestContext()
170 .getUrlRequestContextAdapter();
171 } else { 169 } else {
172 urlRequestContextAdapter = ((CronetUrlRequestContext) framework.mCro netEngine) 170 CronetTestUtil.registerHostResolverProc(framework.mCronetEngine, LOO PBACK_ADDRESS);
173 .getUrlRequestContextAdapter();
174 } 171 }
175 NativeTestServer.registerHostResolverProc(urlRequestContextAdapter, isLe gacyAPI);
176 } 172 }
177 173
178 @Target(ElementType.METHOD) 174 @Target(ElementType.METHOD)
179 @Retention(RetentionPolicy.RUNTIME) 175 @Retention(RetentionPolicy.RUNTIME)
180 public @interface CompareDefaultWithCronet { 176 public @interface CompareDefaultWithCronet {
181 } 177 }
182 178
183 @Target(ElementType.METHOD) 179 @Target(ElementType.METHOD)
184 @Retention(RetentionPolicy.RUNTIME) 180 @Retention(RetentionPolicy.RUNTIME)
185 public @interface OnlyRunCronetHttpURLConnection { 181 public @interface OnlyRunCronetHttpURLConnection {
186 } 182 }
187 183
188 @Target(ElementType.METHOD) 184 @Target(ElementType.METHOD)
189 @Retention(RetentionPolicy.RUNTIME) 185 @Retention(RetentionPolicy.RUNTIME)
190 public @interface OnlyRunNativeCronet {} 186 public @interface OnlyRunNativeCronet {}
191 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698