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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 request.setUploadData(null, uploadData); | 125 request.setUploadData(null, uploadData); |
126 fail("setUploadData should throw on null content type"); | 126 fail("setUploadData should throw on null content type"); |
127 } catch (NullPointerException e) { | 127 } catch (NullPointerException e) { |
128 // Nothing to do here. | 128 // Nothing to do here. |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 @SmallTest | 132 @SmallTest |
133 @Feature({"Cronet"}) | 133 @Feature({"Cronet"}) |
134 public void testLegacyLoadUrl() throws Exception { | 134 public void testLegacyLoadUrl() throws Exception { |
135 HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig(); | 135 CronetEngine.Builder builder = new CronetEngine.Builder(getContext()); |
pauljensen
2015/10/28 14:43:06
Had to switch to CronetEngine.Builder here so buil
xunjieli
2015/10/28 15:23:58
Acknowledged.
| |
136 config.enableLegacyMode(true); | 136 builder.enableLegacyMode(true); |
137 // TODO(mef) fix tests so that library isn't loaded for legacy stack | 137 // TODO(mef) fix tests so that library isn't loaded for legacy stack |
138 config.setLibraryName("cronet_tests"); | |
139 | 138 |
140 String[] commandLineArgs = {CronetTestFramework.CONFIG_KEY, config.toStr ing()}; | |
141 CronetTestFramework testFramework = | 139 CronetTestFramework testFramework = |
142 startCronetTestFrameworkWithUrlAndCommandLineArgs(URL, commandLi neArgs); | 140 startCronetTestFrameworkWithUrlAndCronetEngineBuilder(URL, build er); |
143 | 141 |
144 // Make sure that the URL is set as expected. | 142 // Make sure that the URL is set as expected. |
145 assertEquals(URL, testFramework.getUrl()); | 143 assertEquals(URL, testFramework.getUrl()); |
146 assertEquals(200, testFramework.getHttpStatusCode()); | 144 assertEquals(200, testFramework.getHttpStatusCode()); |
147 } | 145 } |
148 | 146 |
149 @SmallTest | 147 @SmallTest |
150 @Feature({"Cronet"}) | 148 @Feature({"Cronet"}) |
151 public void testRequestHead() throws Exception { | 149 public void testRequestHead() throws Exception { |
152 CronetTestFramework testFramework = startCronetTestFrameworkWithUrl(URL) ; | 150 CronetTestFramework testFramework = startCronetTestFrameworkWithUrl(URL) ; |
153 | 151 |
154 HashMap<String, String> headers = new HashMap<String, String>(); | 152 HashMap<String, String> headers = new HashMap<String, String>(); |
155 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener(); | 153 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener(); |
156 | 154 |
157 // Create request. | 155 // Create request. |
158 HttpUrlRequest request = testFramework.mRequestFactory.createRequest( | 156 HttpUrlRequest request = testFramework.mRequestFactory.createRequest( |
159 URL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener); | 157 URL, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener); |
160 request.setHttpMethod("HEAD"); | 158 request.setHttpMethod("HEAD"); |
161 request.start(); | 159 request.start(); |
162 listener.blockForComplete(); | 160 listener.blockForComplete(); |
163 assertEquals(200, listener.mHttpStatusCode); | 161 assertEquals(200, listener.mHttpStatusCode); |
164 // HEAD requests do not get any response data and Content-Length must be | 162 // HEAD requests do not get any response data and Content-Length must be |
165 // ignored. | 163 // ignored. |
166 assertEquals(0, listener.mResponseAsBytes.length); | 164 assertEquals(0, listener.mResponseAsBytes.length); |
167 } | 165 } |
168 } | 166 } |
OLD | NEW |