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 import org.chromium.base.test.util.UrlUtils; |
11 | 11 |
12 import java.net.MalformedURLException; | |
13 import java.net.URL; | |
14 | |
12 /** | 15 /** |
13 * Wrapper class to start an in-process native test server, and get URLs | 16 * Wrapper class to start an in-process native test server, and get URLs |
14 * needed to talk to it. | 17 * needed to talk to it. |
15 */ | 18 */ |
16 @JNINamespace("cronet") | 19 @JNINamespace("cronet") |
17 public final class NativeTestServer { | 20 public final class NativeTestServer { |
18 // This variable contains the response body of a request to getSuccessURL(). | 21 // This variable contains the response body of a request to getSuccessURL(). |
19 public static final String SUCCESS_BODY = "this is a text file\n"; | 22 public static final String SUCCESS_BODY = "this is a text file\n"; |
20 | 23 |
21 public static boolean startNativeTestServer(Context context) { | 24 public static boolean startNativeTestServer(Context context) { |
(...skipping 23 matching lines...) Expand all Loading... | |
45 } | 48 } |
46 | 49 |
47 public static String getRedirectToEchoBody() { | 50 public static String getRedirectToEchoBody() { |
48 return nativeGetRedirectToEchoBody(); | 51 return nativeGetRedirectToEchoBody(); |
49 } | 52 } |
50 | 53 |
51 public static String getFileURL(String filePath) { | 54 public static String getFileURL(String filePath) { |
52 return nativeGetFileURL(filePath); | 55 return nativeGetFileURL(filePath); |
53 } | 56 } |
54 | 57 |
55 public static String getSdchURL() { | 58 public static String getSdchURL() throws MalformedURLException { |
56 return nativeGetSdchURL(); | 59 return new URL("http", CronetTestUtil.SDCH_FAKE_HOST, getPort(), "").toS tring(); |
pauljensen
2016/07/26 18:18:51
Can we go back to this old code so we don't have t
mgersh
2016/07/27 21:14:58
I don't understand the complaint. I moved "fake.sd
pauljensen
2016/08/17 12:54:26
GetSdchURL() is defined in native_test_server.cc.
| |
57 } | 60 } |
58 | 61 |
59 // The following URLs will make NativeTestServer serve a response based on | 62 // The following URLs will make NativeTestServer serve a response based on |
60 // the contents of the corresponding file and its mock-http-headers file. | 63 // the contents of the corresponding file and its mock-http-headers file. |
61 | 64 |
62 public static String getSuccessURL() { | 65 public static String getSuccessURL() { |
63 return nativeGetFileURL("/success.txt"); | 66 return nativeGetFileURL("/success.txt"); |
64 } | 67 } |
65 | 68 |
66 public static String getRedirectURL() { | 69 public static String getRedirectURL() { |
67 return nativeGetFileURL("/redirect.html"); | 70 return nativeGetFileURL("/redirect.html"); |
68 } | 71 } |
69 | 72 |
70 public static String getMultiRedirectURL() { | 73 public static String getMultiRedirectURL() { |
71 return nativeGetFileURL("/multiredirect.html"); | 74 return nativeGetFileURL("/multiredirect.html"); |
72 } | 75 } |
73 | 76 |
74 public static String getNotFoundURL() { | 77 public static String getNotFoundURL() { |
75 return nativeGetFileURL("/notfound.html"); | 78 return nativeGetFileURL("/notfound.html"); |
76 } | 79 } |
77 | 80 |
81 public static int getPort() { | |
82 return nativeGetPort(); | |
83 } | |
84 | |
78 public static String getHostPort() { | 85 public static String getHostPort() { |
79 return nativeGetHostPort(); | 86 return nativeGetHostPort(); |
80 } | 87 } |
81 | 88 |
82 public static boolean isDataReductionProxySupported() { | 89 public static boolean isDataReductionProxySupported() { |
83 return nativeIsDataReductionProxySupported(); | 90 return nativeIsDataReductionProxySupported(); |
84 } | 91 } |
85 | 92 |
86 private static native boolean nativeStartNativeTestServer(String filePath, S tring testDataDir); | 93 private static native boolean nativeStartNativeTestServer(String filePath, S tring testDataDir); |
87 private static native void nativeShutdownNativeTestServer(); | 94 private static native void nativeShutdownNativeTestServer(); |
88 private static native String nativeGetEchoBodyURL(); | 95 private static native String nativeGetEchoBodyURL(); |
89 private static native String nativeGetEchoHeaderURL(String header); | 96 private static native String nativeGetEchoHeaderURL(String header); |
90 private static native String nativeGetEchoAllHeadersURL(); | 97 private static native String nativeGetEchoAllHeadersURL(); |
91 private static native String nativeGetEchoMethodURL(); | 98 private static native String nativeGetEchoMethodURL(); |
92 private static native String nativeGetRedirectToEchoBody(); | 99 private static native String nativeGetRedirectToEchoBody(); |
93 private static native String nativeGetFileURL(String filePath); | 100 private static native String nativeGetFileURL(String filePath); |
94 private static native String nativeGetSdchURL(); | |
95 private static native String nativeGetHostPort(); | 101 private static native String nativeGetHostPort(); |
102 private static native int nativeGetPort(); | |
96 private static native boolean nativeIsDataReductionProxySupported(); | 103 private static native boolean nativeIsDataReductionProxySupported(); |
97 } | 104 } |
OLD | NEW |