| Index: components/cronet/android/test/src/org/chromium/cronet_test_apk/MockUrlRequestJobUtil.java
|
| diff --git a/components/cronet/android/test/src/org/chromium/cronet_test_apk/MockUrlRequestJobUtil.java b/components/cronet/android/test/src/org/chromium/cronet_test_apk/MockUrlRequestJobUtil.java
|
| index fb10546d397ab93ef4ac20624af801f10525c361..0e26b266592554e49bc9d3199081e56ef2bcf39e 100644
|
| --- a/components/cronet/android/test/src/org/chromium/cronet_test_apk/MockUrlRequestJobUtil.java
|
| +++ b/components/cronet/android/test/src/org/chromium/cronet_test_apk/MockUrlRequestJobUtil.java
|
| @@ -6,8 +6,17 @@ package org.chromium.cronet_test_apk;
|
|
|
| import org.chromium.base.JNINamespace;
|
|
|
| +/**
|
| + * Test utils for MockUrlRequestJobs.
|
| + */
|
| @JNINamespace("cronet")
|
| public final class MockUrlRequestJobUtil {
|
| + enum FailurePhase {
|
| + START,
|
| + READ_ASYNC,
|
| + READ_SYNC,
|
| + };
|
| +
|
| /**
|
| * Adds url interceptors for mock urls that are used in testing.
|
| */
|
| @@ -15,5 +24,31 @@ public final class MockUrlRequestJobUtil {
|
| nativeAddUrlInterceptors();
|
| }
|
|
|
| + /**
|
| + * Constructs a mock URL.
|
| + *
|
| + * @param path path to a mock file.
|
| + */
|
| + public static String getMockUrl(String path) {
|
| + return nativeGetMockUrl(path);
|
| + }
|
| +
|
| + /**
|
| + * Constructs a mock URL that hangs or fails at certain phase.
|
| + *
|
| + * @param path path to a mock file.
|
| + * @param phase at which request fails.
|
| + * @param netError reported by UrlRequestJob. Passing -1, results in hang.
|
| + */
|
| + public static String getMockUrlWithFailure(String path, FailurePhase phase,
|
| + int netError) {
|
| + return nativeGetMockUrlWithFailure(path, phase.ordinal(), netError);
|
| + }
|
| +
|
| private static native void nativeAddUrlInterceptors();
|
| +
|
| + private static native String nativeGetMockUrl(String path);
|
| +
|
| + private static native String nativeGetMockUrlWithFailure(String path,
|
| + int phase, int netError);
|
| }
|
|
|