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

Unified Diff: components/cronet/android/test/quic_test_server.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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/test/quic_test_server.cc
diff --git a/components/cronet/android/test/quic_test_server.cc b/components/cronet/android/test/quic_test_server.cc
index 4ad572d4baddff6596cf540972075e90b3f5853a..8808d55b56bf29c91e11acb04e4885c2a0709e62 100644
--- a/components/cronet/android/test/quic_test_server.cc
+++ b/components/cronet/android/test/quic_test_server.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/test/test_support_android.h"
#include "base/threading/thread.h"
#include "components/cronet/android/test/cronet_test_util.h"
#include "jni/QuicTestServer_jni.h"
@@ -29,7 +30,8 @@ static const int kServerPort = 6121;
base::Thread* g_quic_server_thread = nullptr;
net::QuicSimpleServer* g_quic_server = nullptr;
-void StartOnServerThread(const base::FilePath& test_files_root) {
+void StartOnServerThread(const base::FilePath& test_files_root,
+ const base::FilePath& test_data_dir) {
DCHECK(g_quic_server_thread->task_runner()->BelongsToCurrentThread());
DCHECK(!g_quic_server);
@@ -41,9 +43,7 @@ void StartOnServerThread(const base::FilePath& test_files_root) {
net::QuicConfig config;
// Set up server certs.
- base::FilePath directory;
- CHECK(base::android::GetExternalStorageDirectory(&directory));
- directory = directory.Append("net/data/ssl/certificates");
+ base::FilePath directory = test_data_dir.Append("net/data/ssl/certificates");
// TODO(xunjieli): Use scoped_ptr when crbug.com/545474 is fixed.
net::ProofSourceChromium* proof_source = new net::ProofSourceChromium();
CHECK(proof_source->Initialize(
@@ -73,8 +73,13 @@ void ShutdownOnServerThread() {
// the device.
void StartQuicTestServer(JNIEnv* env,
const JavaParamRef<jclass>& /*jcaller*/,
- const JavaParamRef<jstring>& jtest_files_root) {
+ const JavaParamRef<jstring>& jtest_files_root,
+ const JavaParamRef<jstring>& jtest_data_dir) {
DCHECK(!g_quic_server_thread);
+ base::FilePath test_data_dir(
+ base::android::ConvertJavaStringToUTF8(env, jtest_data_dir));
+ base::InitAndroidTestPaths(test_data_dir);
+
g_quic_server_thread = new base::Thread("quic server thread");
base::Thread::Options thread_options;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
@@ -83,7 +88,8 @@ void StartQuicTestServer(JNIEnv* env,
base::FilePath test_files_root(
base::android::ConvertJavaStringToUTF8(env, jtest_files_root));
g_quic_server_thread->task_runner()->PostTask(
- FROM_HERE, base::Bind(&StartOnServerThread, test_files_root));
+ FROM_HERE,
+ base::Bind(&StartOnServerThread, test_files_root, test_data_dir));
}
void ShutdownQuicTestServer(JNIEnv* env,

Powered by Google App Engine
This is Rietveld 408576698