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

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: ignore netty proguard errors 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 void assertResponseEquals(UrlResponseInfo expected, UrlResponseInfo actual) { 174 void assertResponseEquals(UrlResponseInfo expected, UrlResponseInfo actual) {
179 assertEquals(expected.getAllHeaders(), actual.getAllHeaders()); 175 assertEquals(expected.getAllHeaders(), actual.getAllHeaders());
180 assertEquals(expected.getAllHeadersAsList(), actual.getAllHeadersAsList( )); 176 assertEquals(expected.getAllHeadersAsList(), actual.getAllHeadersAsList( ));
181 assertEquals(expected.getHttpStatusCode(), actual.getHttpStatusCode()); 177 assertEquals(expected.getHttpStatusCode(), actual.getHttpStatusCode());
182 assertEquals(expected.getHttpStatusText(), actual.getHttpStatusText()); 178 assertEquals(expected.getHttpStatusText(), actual.getHttpStatusText());
183 assertEquals(expected.getUrlChain(), actual.getUrlChain()); 179 assertEquals(expected.getUrlChain(), actual.getUrlChain());
184 assertEquals(expected.getUrl(), actual.getUrl()); 180 assertEquals(expected.getUrl(), actual.getUrl());
185 // Transferred bytes and proxy server are not supported in pure java 181 // Transferred bytes and proxy server are not supported in pure java
(...skipping 12 matching lines...) Expand all
198 194
199 @Target(ElementType.METHOD) 195 @Target(ElementType.METHOD)
200 @Retention(RetentionPolicy.RUNTIME) 196 @Retention(RetentionPolicy.RUNTIME)
201 public @interface OnlyRunCronetHttpURLConnection { 197 public @interface OnlyRunCronetHttpURLConnection {
202 } 198 }
203 199
204 @Target(ElementType.METHOD) 200 @Target(ElementType.METHOD)
205 @Retention(RetentionPolicy.RUNTIME) 201 @Retention(RetentionPolicy.RUNTIME)
206 public @interface OnlyRunNativeCronet {} 202 public @interface OnlyRunNativeCronet {}
207 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698