Chromium Code Reviews| 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; | 9 import org.chromium.base.PathUtils; |
| 10 | 10 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // For all other tests. | 127 // For all other tests. |
| 128 super.runTest(); | 128 super.runTest(); |
| 129 } | 129 } |
| 130 } catch (Throwable e) { | 130 } catch (Throwable e) { |
| 131 throw new Throwable("CronetTestBase#runTest failed.", e); | 131 throw new Throwable("CronetTestBase#runTest failed.", e); |
| 132 } | 132 } |
| 133 } else if (packageName.equals("org.chromium.net")) { | 133 } else if (packageName.equals("org.chromium.net")) { |
| 134 try { | 134 try { |
| 135 Method method = getClass().getMethod(getName(), (Class[]) null); | 135 Method method = getClass().getMethod(getName(), (Class[]) null); |
| 136 super.runTest(); | 136 super.runTest(); |
| 137 if (!method.isAnnotationPresent(OnlyRunNativeCronet.class)) { | 137 if (!getClass().isAnnotationPresent(OnlyRunNativeCronet.class) |
|
pauljensen
2016/01/19 16:03:41
Charles wanted to avoid this as it makes it too ea
mef
2016/01/20 15:37:41
Done. We'll also need another annotation 'RunQuicA
| |
| 138 && !method.isAnnotationPresent(OnlyRunNativeCronet.class )) { | |
| 138 if (mCronetTestFramework != null) { | 139 if (mCronetTestFramework != null) { |
| 139 mCronetTestFramework.mCronetEngine = | 140 mCronetTestFramework.mCronetEngine = |
| 140 new JavaCronetEngine(UserAgent.from(getContext() )); | 141 new JavaCronetEngine(UserAgent.from(getContext() )); |
| 141 } | 142 } |
| 142 mTestingJavaImpl = true; | 143 mTestingJavaImpl = true; |
| 143 super.runTest(); | 144 super.runTest(); |
| 144 } | 145 } |
| 145 } catch (Throwable e) { | 146 } catch (Throwable e) { |
| 146 throw new Throwable("CronetTestBase#runTest failed.", e); | 147 throw new Throwable("CronetTestBase#runTest failed.", e); |
| 147 } | 148 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 168 urlRequestContextAdapter = ((ChromiumUrlRequestFactory) framework.mR equestFactory) | 169 urlRequestContextAdapter = ((ChromiumUrlRequestFactory) framework.mR equestFactory) |
| 169 .getRequestContext() | 170 .getRequestContext() |
| 170 .getUrlRequestContextAdapter(); | 171 .getUrlRequestContextAdapter(); |
| 171 } else { | 172 } else { |
| 172 urlRequestContextAdapter = ((CronetUrlRequestContext) framework.mCro netEngine) | 173 urlRequestContextAdapter = ((CronetUrlRequestContext) framework.mCro netEngine) |
| 173 .getUrlRequestContextAdapter(); | 174 .getUrlRequestContextAdapter(); |
| 174 } | 175 } |
| 175 NativeTestServer.registerHostResolverProc(urlRequestContextAdapter, isLe gacyAPI); | 176 NativeTestServer.registerHostResolverProc(urlRequestContextAdapter, isLe gacyAPI); |
| 176 } | 177 } |
| 177 | 178 |
| 179 void assertResponseEquals(UrlResponseInfo expected, UrlResponseInfo actual) { | |
| 180 assertEquals(expected.getAllHeaders(), actual.getAllHeaders()); | |
| 181 assertEquals(expected.getAllHeadersAsList(), actual.getAllHeadersAsList( )); | |
| 182 assertEquals(expected.getHttpStatusCode(), actual.getHttpStatusCode()); | |
| 183 assertEquals(expected.getHttpStatusText(), actual.getHttpStatusText()); | |
| 184 assertEquals(expected.getUrlChain(), actual.getUrlChain()); | |
| 185 assertEquals(expected.getUrl(), actual.getUrl()); | |
| 186 // Transferred bytes and proxy server are not supported in pure java | |
| 187 if (!(mCronetTestFramework.mCronetEngine instanceof JavaCronetEngine)) { | |
| 188 assertEquals(expected.getReceivedBytesCount(), actual.getReceivedByt esCount()); | |
| 189 assertEquals(expected.getProxyServer(), actual.getProxyServer()); | |
| 190 // This is a place where behavior intentionally differs between nati ve and java | |
| 191 assertEquals(expected.getNegotiatedProtocol(), actual.getNegotiatedP rotocol()); | |
| 192 } | |
| 193 } | |
| 194 | |
| 178 @Target(ElementType.METHOD) | 195 @Target(ElementType.METHOD) |
| 179 @Retention(RetentionPolicy.RUNTIME) | 196 @Retention(RetentionPolicy.RUNTIME) |
| 180 public @interface CompareDefaultWithCronet { | 197 public @interface CompareDefaultWithCronet { |
| 181 } | 198 } |
| 182 | 199 |
| 183 @Target(ElementType.METHOD) | 200 @Target(ElementType.METHOD) |
| 184 @Retention(RetentionPolicy.RUNTIME) | 201 @Retention(RetentionPolicy.RUNTIME) |
| 185 public @interface OnlyRunCronetHttpURLConnection { | 202 public @interface OnlyRunCronetHttpURLConnection { |
| 186 } | 203 } |
| 187 | 204 |
| 188 @Target(ElementType.METHOD) | 205 @Target({ElementType.TYPE, ElementType.METHOD}) |
| 189 @Retention(RetentionPolicy.RUNTIME) | 206 @Retention(RetentionPolicy.RUNTIME) |
| 190 public @interface OnlyRunNativeCronet {} | 207 public @interface OnlyRunNativeCronet {} |
| 191 } | 208 } |
| OLD | NEW |