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

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlTest.java

Issue 2267173003: Remove deprecated UrlRequestContextConfig & HttpUrlRequestFactoryConfig (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + addressed commnents Created 4 years, 3 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.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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 @SmallTest 70 @SmallTest
71 @Feature({"Cronet"}) 71 @Feature({"Cronet"})
72 @OnlyRunNativeCronet // No NetLog from HttpURLConnection 72 @OnlyRunNativeCronet // No NetLog from HttpURLConnection
73 public void testNetLog() throws Exception { 73 public void testNetLog() throws Exception {
74 Context context = getContext(); 74 Context context = getContext();
75 File directory = new File(PathUtils.getDataDirectory(context)); 75 File directory = new File(PathUtils.getDataDirectory(context));
76 File file = File.createTempFile("cronet", "json", directory); 76 File file = File.createTempFile("cronet", "json", directory);
77 HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory( 77 HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
78 context, 78 context, new CronetEngine.Builder(null /*context*/).setLibraryNa me("cronet_tests"));
79 new UrlRequestContextConfig().setLibraryName("cronet_tests"));
80 // Start NetLog immediately after the request context is created to make 79 // Start NetLog immediately after the request context is created to make
81 // sure that the call won't crash the app even when the native request 80 // sure that the call won't crash the app even when the native request
82 // context is not fully initialized. See crbug.com/470196. 81 // context is not fully initialized. See crbug.com/470196.
83 factory.startNetLogToFile(file.getPath(), false); 82 factory.startNetLogToFile(file.getPath(), false);
84 // Starts a request. 83 // Starts a request.
85 HashMap<String, String> headers = new HashMap<String, String>(); 84 HashMap<String, String> headers = new HashMap<String, String>();
86 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener(); 85 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
87 HttpUrlRequest request = factory.createRequest( 86 HttpUrlRequest request = factory.createRequest(
88 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ; 87 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ;
89 request.start(); 88 request.start();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ; 171 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ;
173 request.setHttpMethod("HEAD"); 172 request.setHttpMethod("HEAD");
174 request.start(); 173 request.start();
175 listener.blockForComplete(); 174 listener.blockForComplete();
176 assertEquals(200, listener.mHttpStatusCode); 175 assertEquals(200, listener.mHttpStatusCode);
177 // HEAD requests do not get any response data and Content-Length must be 176 // HEAD requests do not get any response data and Content-Length must be
178 // ignored. 177 // ignored.
179 assertEquals(0, listener.mResponseAsBytes.length); 178 assertEquals(0, listener.mResponseAsBytes.length);
180 } 179 }
181 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698