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

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

Issue 2262453002: Cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix stuff. Created 4 years, 4 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;
8 import android.test.suitebuilder.annotation.SmallTest; 7 import android.test.suitebuilder.annotation.SmallTest;
9 8
10 import org.chromium.base.PathUtils; 9 import org.chromium.base.PathUtils;
11 import org.chromium.base.test.util.Feature; 10 import org.chromium.base.test.util.Feature;
12 import org.chromium.net.test.EmbeddedTestServer; 11 import org.chromium.net.test.EmbeddedTestServer;
13 12
14 import java.io.File; 13 import java.io.File;
15 import java.util.HashMap; 14 import java.util.HashMap;
16 15
17 /** 16 /**
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 63
65 // Make sure that the URL is set as expected. 64 // Make sure that the URL is set as expected.
66 assertEquals(mUrl, testFramework.getUrl()); 65 assertEquals(mUrl, testFramework.getUrl());
67 assertEquals(200, testFramework.getHttpStatusCode()); 66 assertEquals(200, testFramework.getHttpStatusCode());
68 } 67 }
69 68
70 @SmallTest 69 @SmallTest
71 @Feature({"Cronet"}) 70 @Feature({"Cronet"})
72 @OnlyRunNativeCronet // No NetLog from HttpURLConnection 71 @OnlyRunNativeCronet // No NetLog from HttpURLConnection
73 public void testNetLog() throws Exception { 72 public void testNetLog() throws Exception {
74 Context context = getContext(); 73 File directory = new File(PathUtils.getDataDirectory());
75 File directory = new File(PathUtils.getDataDirectory(context));
76 File file = File.createTempFile("cronet", "json", directory); 74 File file = File.createTempFile("cronet", "json", directory);
77 HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory( 75 HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
78 context, 76 getContext(), new UrlRequestContextConfig().setLibraryName("cron et_tests"));
79 new UrlRequestContextConfig().setLibraryName("cronet_tests"));
80 // Start NetLog immediately after the request context is created to make 77 // 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 78 // sure that the call won't crash the app even when the native request
82 // context is not fully initialized. See crbug.com/470196. 79 // context is not fully initialized. See crbug.com/470196.
83 factory.startNetLogToFile(file.getPath(), false); 80 factory.startNetLogToFile(file.getPath(), false);
84 // Starts a request. 81 // Starts a request.
85 HashMap<String, String> headers = new HashMap<String, String>(); 82 HashMap<String, String> headers = new HashMap<String, String>();
86 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener(); 83 TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
87 HttpUrlRequest request = factory.createRequest( 84 HttpUrlRequest request = factory.createRequest(
88 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ; 85 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ;
89 request.start(); 86 request.start();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ; 169 mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener) ;
173 request.setHttpMethod("HEAD"); 170 request.setHttpMethod("HEAD");
174 request.start(); 171 request.start();
175 listener.blockForComplete(); 172 listener.blockForComplete();
176 assertEquals(200, listener.mHttpStatusCode); 173 assertEquals(200, listener.mHttpStatusCode);
177 // HEAD requests do not get any response data and Content-Length must be 174 // HEAD requests do not get any response data and Content-Length must be
178 // ignored. 175 // ignored.
179 assertEquals(0, listener.mResponseAsBytes.length); 176 assertEquals(0, listener.mResponseAsBytes.length);
180 } 177 }
181 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698