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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 urlRequestContextAdapter = ((ChromiumUrlRequestFactory) framework.mR
equestFactory) | 168 urlRequestContextAdapter = ((ChromiumUrlRequestFactory) framework.mR
equestFactory) |
169 .getRequestContext() | 169 .getRequestContext() |
170 .getUrlRequestContextAdapter(); | 170 .getUrlRequestContextAdapter(); |
171 } else { | 171 } else { |
172 urlRequestContextAdapter = ((CronetUrlRequestContext) framework.mCro
netEngine) | 172 urlRequestContextAdapter = ((CronetUrlRequestContext) framework.mCro
netEngine) |
173 .getUrlRequestContextAdapter(); | 173 .getUrlRequestContextAdapter(); |
174 } | 174 } |
175 NativeTestServer.registerHostResolverProc(urlRequestContextAdapter, isLe
gacyAPI); | 175 NativeTestServer.registerHostResolverProc(urlRequestContextAdapter, isLe
gacyAPI); |
176 } | 176 } |
177 | 177 |
| 178 void assertResponseEquals(UrlResponseInfo expected, UrlResponseInfo actual)
{ |
| 179 assertEquals(expected.getAllHeaders(), actual.getAllHeaders()); |
| 180 assertEquals(expected.getAllHeadersAsList(), actual.getAllHeadersAsList(
)); |
| 181 assertEquals(expected.getHttpStatusCode(), actual.getHttpStatusCode()); |
| 182 assertEquals(expected.getHttpStatusText(), actual.getHttpStatusText()); |
| 183 assertEquals(expected.getUrlChain(), actual.getUrlChain()); |
| 184 assertEquals(expected.getUrl(), actual.getUrl()); |
| 185 // Transferred bytes and proxy server are not supported in pure java |
| 186 if (!(mCronetTestFramework.mCronetEngine instanceof JavaCronetEngine)) { |
| 187 assertEquals(expected.getReceivedBytesCount(), actual.getReceivedByt
esCount()); |
| 188 assertEquals(expected.getProxyServer(), actual.getProxyServer()); |
| 189 // This is a place where behavior intentionally differs between nati
ve and java |
| 190 assertEquals(expected.getNegotiatedProtocol(), actual.getNegotiatedP
rotocol()); |
| 191 } |
| 192 } |
| 193 |
178 @Target(ElementType.METHOD) | 194 @Target(ElementType.METHOD) |
179 @Retention(RetentionPolicy.RUNTIME) | 195 @Retention(RetentionPolicy.RUNTIME) |
180 public @interface CompareDefaultWithCronet { | 196 public @interface CompareDefaultWithCronet { |
181 } | 197 } |
182 | 198 |
183 @Target(ElementType.METHOD) | 199 @Target(ElementType.METHOD) |
184 @Retention(RetentionPolicy.RUNTIME) | 200 @Retention(RetentionPolicy.RUNTIME) |
185 public @interface OnlyRunCronetHttpURLConnection { | 201 public @interface OnlyRunCronetHttpURLConnection { |
186 } | 202 } |
187 | 203 |
188 @Target(ElementType.METHOD) | 204 @Target(ElementType.METHOD) |
189 @Retention(RetentionPolicy.RUNTIME) | 205 @Retention(RetentionPolicy.RUNTIME) |
190 public @interface OnlyRunNativeCronet {} | 206 public @interface OnlyRunNativeCronet {} |
191 } | 207 } |
OLD | NEW |