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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java

Issue 2585203003: Don't try to report metrics when there's no URLRequest (Closed)
Patch Set: delete part of test Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/cronet/android/cronet_url_request_adapter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java
index 1f671a8bff67a8d7c3e4ae8ba1683c6c1d443cbc..5205d9fa13231775abd79a6038a8f9f8b8823e25 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java
@@ -292,6 +292,34 @@ public class RequestFinishedInfoTest extends CronetTestBase {
mTestFramework.mCronetEngine.shutdown();
}
+ // Checks that CronetURLRequestAdapter::DestroyOnNetworkThread() doesn't crash when metrics
+ // collection is enabled and the URLRequest hasn't been created. See http://crbug.com/675629.
+ @SmallTest
+ @OnlyRunNativeCronet
+ @Feature({"Cronet"})
+ public void testExceptionInRequestStart() throws Exception {
+ mTestFramework = startCronetTestFramework();
+ TestRequestFinishedListener requestFinishedListener = new TestRequestFinishedListener();
xunjieli 2016/12/19 21:18:31 Can you make sure the executor backing this listen
mgersh 2016/12/19 21:37:25 Oh, that's a better way to do it, thanks. Done.
+ mTestFramework.mCronetEngine.addRequestFinishedListener(requestFinishedListener);
+ TestUrlRequestCallback callback = new TestUrlRequestCallback();
+ ExperimentalUrlRequest.Builder urlRequestBuilder =
+ mTestFramework.mCronetEngine.newUrlRequestBuilder(
+ mUrl, callback, callback.getExecutor());
+ // Empty headers are invalid and will cause start() to throw an exception.
+ UrlRequest request = urlRequestBuilder.addHeader("", "")
+ .addRequestAnnotation("request annotation")
+ .addRequestAnnotation(this)
xunjieli 2016/12/19 21:18:31 are these two annotations needed?
mgersh 2016/12/19 21:37:25 Nope, just left over from an earlier version. Remo
+ .build();
+ try {
+ request.start();
+ fail("UrlRequest.start() should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Invalid header =", e.getMessage());
+ }
+
+ mTestFramework.mCronetEngine.shutdown();
+ }
+
@SmallTest
@Feature({"Cronet"})
public void testMetricsGetters() throws Exception {
« no previous file with comments | « components/cronet/android/cronet_url_request_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698