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

Side by Side Diff: components/cronet/android/test/native_test_server.cc

Issue 2044523003: Revert of 👔 Reland of Move side-loaded test data /sdcard -> /sdcard/gtestdata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 unified diff | Download patch
OLDNEW
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 #include "components/cronet/android/test/native_test_server.h" 5 #include "components/cronet/android/test/native_test_server.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/android/path_utils.h" 13 #include "base/android/path_utils.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/test/test_support_android.h"
22 #include "components/cronet/android/test/cronet_test_util.h" 21 #include "components/cronet/android/test/cronet_test_util.h"
23 #include "jni/NativeTestServer_jni.h" 22 #include "jni/NativeTestServer_jni.h"
24 #include "net/base/host_port_pair.h" 23 #include "net/base/host_port_pair.h"
25 #include "net/base/url_util.h" 24 #include "net/base/url_util.h"
26 #include "net/http/http_status_code.h" 25 #include "net/http/http_status_code.h"
27 #include "net/test/embedded_test_server/embedded_test_server.h" 26 #include "net/test/embedded_test_server/embedded_test_server.h"
28 #include "net/test/embedded_test_server/http_request.h" 27 #include "net/test/embedded_test_server/http_request.h"
29 #include "net/test/embedded_test_server/http_response.h" 28 #include "net/test/embedded_test_server/http_response.h"
30 #include "url/gurl.h" 29 #include "url/gurl.h"
31 30
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 157 }
159 158
160 // Unhandled requests result in the Embedded test server sending a 404. 159 // Unhandled requests result in the Embedded test server sending a 404.
161 return std::unique_ptr<net::test_server::BasicHttpResponse>(); 160 return std::unique_ptr<net::test_server::BasicHttpResponse>();
162 } 161 }
163 162
164 } // namespace 163 } // namespace
165 164
166 jboolean StartNativeTestServer(JNIEnv* env, 165 jboolean StartNativeTestServer(JNIEnv* env,
167 const JavaParamRef<jclass>& jcaller, 166 const JavaParamRef<jclass>& jcaller,
168 const JavaParamRef<jstring>& jtest_files_root, 167 const JavaParamRef<jstring>& jtest_files_root) {
169 const JavaParamRef<jstring>& jtest_data_dir) {
170 // Shouldn't happen. 168 // Shouldn't happen.
171 if (g_test_server) 169 if (g_test_server)
172 return false; 170 return false;
173
174 base::FilePath test_data_dir(
175 base::android::ConvertJavaStringToUTF8(env, jtest_data_dir));
176 base::InitAndroidTestPaths(test_data_dir);
177
178 g_test_server = new net::EmbeddedTestServer(); 171 g_test_server = new net::EmbeddedTestServer();
179 g_test_server->RegisterRequestHandler( 172 g_test_server->RegisterRequestHandler(
180 base::Bind(&NativeTestServerRequestHandler)); 173 base::Bind(&NativeTestServerRequestHandler));
181 g_test_server->RegisterRequestHandler(base::Bind(&SdchRequestHandler)); 174 g_test_server->RegisterRequestHandler(base::Bind(&SdchRequestHandler));
182 base::FilePath test_files_root( 175 base::FilePath test_files_root(
183 base::android::ConvertJavaStringToUTF8(env, jtest_files_root)); 176 base::android::ConvertJavaStringToUTF8(env, jtest_files_root));
184 177
185 // Add a third handler for paths that NativeTestServerRequestHandler does not 178 // Add a third handler for paths that NativeTestServerRequestHandler does not
186 // handle. 179 // handle.
187 g_test_server->ServeFilesFromDirectory(test_files_root); 180 g_test_server->ServeFilesFromDirectory(test_files_root);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 #else 267 #else
275 return JNI_FALSE; 268 return JNI_FALSE;
276 #endif 269 #endif
277 } 270 }
278 271
279 bool RegisterNativeTestServer(JNIEnv* env) { 272 bool RegisterNativeTestServer(JNIEnv* env) {
280 return RegisterNativesImpl(env); 273 return RegisterNativesImpl(env);
281 } 274 }
282 275
283 } // namespace cronet 276 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/android/test/mock_cert_verifier.cc ('k') | components/cronet/android/test/quic_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698