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

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

Issue 1492583002: Add HttpUrlConnection backed implementation of CronetEngine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enabled user agent test Created 4 years, 11 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698