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.content.Context; | 7 import android.content.Context; |
8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 | 9 |
10 import org.chromium.base.PathUtils; | 10 import org.chromium.base.PathUtils; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 CronetTestFramework testFramework = | 48 CronetTestFramework testFramework = |
49 startCronetTestFrameworkWithUrlAndCommandLineArgs(URL, commandLi
neArgs); | 49 startCronetTestFrameworkWithUrlAndCommandLineArgs(URL, commandLi
neArgs); |
50 | 50 |
51 // Make sure that the URL is set as expected. | 51 // Make sure that the URL is set as expected. |
52 assertEquals(URL, testFramework.getUrl()); | 52 assertEquals(URL, testFramework.getUrl()); |
53 assertEquals(200, testFramework.getHttpStatusCode()); | 53 assertEquals(200, testFramework.getHttpStatusCode()); |
54 } | 54 } |
55 | 55 |
56 @SmallTest | 56 @SmallTest |
57 @Feature({"Cronet"}) | 57 @Feature({"Cronet"}) |
| 58 @OnlyRunNativeCronet // No NetLog from HttpURLConnection |
58 public void testNetLog() throws Exception { | 59 public void testNetLog() throws Exception { |
59 Context context = getContext(); | 60 Context context = getContext(); |
60 File directory = new File(PathUtils.getDataDirectory(context)); | 61 File directory = new File(PathUtils.getDataDirectory(context)); |
61 File file = File.createTempFile("cronet", "json", directory); | 62 File file = File.createTempFile("cronet", "json", directory); |
62 HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory( | 63 HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory( |
63 context, | 64 context, |
64 new UrlRequestContextConfig().setLibraryName("cronet_tests")); | 65 new UrlRequestContextConfig().setLibraryName("cronet_tests")); |
65 // Start NetLog immediately after the request context is created to make | 66 // Start NetLog immediately after the request context is created to make |
66 // sure that the call won't crash the app even when the native request | 67 // sure that the call won't crash the app even when the native request |
67 // context is not fully initialized. See crbug.com/470196. | 68 // context is not fully initialized. See crbug.com/470196. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 URL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener); | 158 URL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener); |
158 request.setHttpMethod("HEAD"); | 159 request.setHttpMethod("HEAD"); |
159 request.start(); | 160 request.start(); |
160 listener.blockForComplete(); | 161 listener.blockForComplete(); |
161 assertEquals(200, listener.mHttpStatusCode); | 162 assertEquals(200, listener.mHttpStatusCode); |
162 // HEAD requests do not get any response data and Content-Length must be | 163 // HEAD requests do not get any response data and Content-Length must be |
163 // ignored. | 164 // ignored. |
164 assertEquals(0, listener.mResponseAsBytes.length); | 165 assertEquals(0, listener.mResponseAsBytes.length); |
165 } | 166 } |
166 } | 167 } |
OLD | NEW |