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

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

Issue 2406273002: [Cronet] Test the libcronet that's shipped, not libcronet_test (Closed)
Patch Set: fix shutdown race Created 4 years, 1 month 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
Index: components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
diff --git a/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java b/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
index 96750028ea374fcdf297bbdc0fd113dffd9af363..43823554edcc7021f05feed5b8c48e07a14f7a72 100644
--- a/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
+++ b/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
@@ -7,6 +7,7 @@ package org.chromium.net;
import static junit.framework.Assert.assertTrue;
import org.chromium.base.annotations.JNINamespace;
+import org.chromium.net.impl.CronetUrlRequestContext;
import org.chromium.net.test.FailurePhase;
/**
@@ -14,11 +15,25 @@ import org.chromium.net.test.FailurePhase;
*/
@JNINamespace("cronet")
public final class MockUrlRequestJobFactory {
+ private final long mInterceptorHandle;
+ private final CronetTestUtil.NetworkThreadTestConnector mNetworkThreadTestConnector;
+
/**
* Sets up URL interceptors.
*/
- public static void setUp() {
- nativeAddUrlInterceptors();
+ public MockUrlRequestJobFactory(CronetEngine cronetEngine) {
+ mNetworkThreadTestConnector = new CronetTestUtil.NetworkThreadTestConnector(cronetEngine);
+
+ mInterceptorHandle = nativeAddUrlInterceptors(
+ ((CronetUrlRequestContext) cronetEngine).getUrlRequestContextAdapter());
+ }
+
+ /**
+ * Remove URL Interceptors.
+ */
+ public void shutdown() {
+ nativeRemoveUrlInterceptorJobFactory(mInterceptorHandle);
+ mNetworkThreadTestConnector.shutdown();
}
/**
@@ -75,7 +90,9 @@ public final class MockUrlRequestJobFactory {
return nativeGetMockUrlForHangingRead();
}
- private static native void nativeAddUrlInterceptors();
+ private static native long nativeAddUrlInterceptors(long requestContextAdapter);
+
+ private static native void nativeRemoveUrlInterceptorJobFactory(long interceptorHandle);
private static native String nativeGetMockUrlWithFailure(int phase, int netError);

Powered by Google App Engine
This is Rietveld 408576698