OLD | NEW |
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 | 8 |
9 import org.chromium.base.annotations.JNINamespace; | 9 import org.chromium.base.annotations.JNINamespace; |
| 10 import org.chromium.base.test.util.UrlUtils; |
10 | 11 |
11 /** | 12 /** |
12 * Wrapper class to start an in-process native test server, and get URLs | 13 * Wrapper class to start an in-process native test server, and get URLs |
13 * needed to talk to it. | 14 * needed to talk to it. |
14 */ | 15 */ |
15 @JNINamespace("cronet") | 16 @JNINamespace("cronet") |
16 public final class NativeTestServer { | 17 public final class NativeTestServer { |
17 // This variable contains the response body of a request to getSuccessURL(). | 18 // This variable contains the response body of a request to getSuccessURL(). |
18 public static final String SUCCESS_BODY = "this is a text file\n"; | 19 public static final String SUCCESS_BODY = "this is a text file\n"; |
19 | 20 |
20 public static boolean startNativeTestServer(Context context) { | 21 public static boolean startNativeTestServer(Context context) { |
21 TestFilesInstaller.installIfNeeded(context); | 22 TestFilesInstaller.installIfNeeded(context); |
22 return nativeStartNativeTestServer( | 23 return nativeStartNativeTestServer( |
23 TestFilesInstaller.getInstalledPath(context)); | 24 TestFilesInstaller.getInstalledPath(context), UrlUtils.getIsolat
edTestRoot()); |
24 } | 25 } |
25 | 26 |
26 public static void shutdownNativeTestServer() { | 27 public static void shutdownNativeTestServer() { |
27 nativeShutdownNativeTestServer(); | 28 nativeShutdownNativeTestServer(); |
28 } | 29 } |
29 | 30 |
30 public static String getEchoBodyURL() { | 31 public static String getEchoBodyURL() { |
31 return nativeGetEchoBodyURL(); | 32 return nativeGetEchoBodyURL(); |
32 } | 33 } |
33 | 34 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 76 } |
76 | 77 |
77 public static String getHostPort() { | 78 public static String getHostPort() { |
78 return nativeGetHostPort(); | 79 return nativeGetHostPort(); |
79 } | 80 } |
80 | 81 |
81 public static boolean isDataReductionProxySupported() { | 82 public static boolean isDataReductionProxySupported() { |
82 return nativeIsDataReductionProxySupported(); | 83 return nativeIsDataReductionProxySupported(); |
83 } | 84 } |
84 | 85 |
85 private static native boolean nativeStartNativeTestServer(String filePath); | 86 private static native boolean nativeStartNativeTestServer(String filePath, S
tring testDataDir); |
86 private static native void nativeShutdownNativeTestServer(); | 87 private static native void nativeShutdownNativeTestServer(); |
87 private static native String nativeGetEchoBodyURL(); | 88 private static native String nativeGetEchoBodyURL(); |
88 private static native String nativeGetEchoHeaderURL(String header); | 89 private static native String nativeGetEchoHeaderURL(String header); |
89 private static native String nativeGetEchoAllHeadersURL(); | 90 private static native String nativeGetEchoAllHeadersURL(); |
90 private static native String nativeGetEchoMethodURL(); | 91 private static native String nativeGetEchoMethodURL(); |
91 private static native String nativeGetRedirectToEchoBody(); | 92 private static native String nativeGetRedirectToEchoBody(); |
92 private static native String nativeGetFileURL(String filePath); | 93 private static native String nativeGetFileURL(String filePath); |
93 private static native String nativeGetSdchURL(); | 94 private static native String nativeGetSdchURL(); |
94 private static native String nativeGetHostPort(); | 95 private static native String nativeGetHostPort(); |
95 private static native boolean nativeIsDataReductionProxySupported(); | 96 private static native boolean nativeIsDataReductionProxySupported(); |
96 } | 97 } |
OLD | NEW |