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

Side by Side Diff: net/test/embedded_test_server/android/embedded_test_server_android.cc

Issue 2043803003: 👔 Reland #2: Move side-loaded test data /sdcard -> /sdcard/gtestdata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase atop https://codereview.chromium.org/2041723006 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "net/test/embedded_test_server/android/embedded_test_server_android.h" 5 #include "net/test/embedded_test_server/android/embedded_test_server_android.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/test/test_support_android.h"
11 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
12 #include "net/test/jni/EmbeddedTestServerImpl_jni.h" 13 #include "net/test/jni/EmbeddedTestServerImpl_jni.h"
13 14
14 namespace net { 15 namespace net {
15 namespace test_server { 16 namespace test_server {
16 17
17 EmbeddedTestServerAndroid::EmbeddedTestServerAndroid(JNIEnv* env, jobject jobj) 18 EmbeddedTestServerAndroid::EmbeddedTestServerAndroid(JNIEnv* env, jobject jobj)
18 : weak_java_server_(env, jobj), test_server_() { 19 : weak_java_server_(env, jobj), test_server_() {
19 Java_EmbeddedTestServerImpl_setNativePtr(env, jobj, 20 Java_EmbeddedTestServerImpl_setNativePtr(env, jobj,
20 reinterpret_cast<intptr_t>(this)); 21 reinterpret_cast<intptr_t>(this));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const base::FilePath directory( 63 const base::FilePath directory(
63 base::android::ConvertJavaStringToUTF8(env, jdirectory_path)); 64 base::android::ConvertJavaStringToUTF8(env, jdirectory_path));
64 test_server_.ServeFilesFromDirectory(directory); 65 test_server_.ServeFilesFromDirectory(directory);
65 } 66 }
66 67
67 void EmbeddedTestServerAndroid::Destroy(JNIEnv* env, 68 void EmbeddedTestServerAndroid::Destroy(JNIEnv* env,
68 const JavaParamRef<jobject>& jobj) { 69 const JavaParamRef<jobject>& jobj) {
69 delete this; 70 delete this;
70 } 71 }
71 72
72 static void Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 73 static void Init(JNIEnv* env,
74 const JavaParamRef<jobject>& jobj,
75 const JavaParamRef<jstring>& jtest_data_dir) {
73 TRACE_EVENT0("native", "EmbeddedTestServerAndroid::Init"); 76 TRACE_EVENT0("native", "EmbeddedTestServerAndroid::Init");
77 base::FilePath test_data_dir(
78 base::android::ConvertJavaStringToUTF8(env, jtest_data_dir));
79 base::InitAndroidTestPaths(test_data_dir);
74 new EmbeddedTestServerAndroid(env, jobj); 80 new EmbeddedTestServerAndroid(env, jobj);
75 } 81 }
76 82
77 // static 83 // static
78 bool EmbeddedTestServerAndroid::RegisterEmbeddedTestServerAndroid(JNIEnv* env) { 84 bool EmbeddedTestServerAndroid::RegisterEmbeddedTestServerAndroid(JNIEnv* env) {
79 return RegisterNativesImpl(env); 85 return RegisterNativesImpl(env);
80 } 86 }
81 87
82 } // namespace test_server 88 } // namespace test_server
83 } // namespace net 89 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698