| Index: testing/android/native_test_launcher.cc
|
| diff --git a/testing/android/native_test_launcher.cc b/testing/android/native_test_launcher.cc
|
| index bc5d47f3b9313321a6800776af54e883a2864059..37dfdebf7dfdb11dc33eb8801f685e0de03a33cb 100644
|
| --- a/testing/android/native_test_launcher.cc
|
| +++ b/testing/android/native_test_launcher.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/android/jni_android.h"
|
| #include "base/android/jni_string.h"
|
| #include "base/android/path_utils.h"
|
| +#include "base/android/scoped_java_ref.h"
|
| #include "base/at_exit.h"
|
| #include "base/command_line.h"
|
| #include "base/file_path.h"
|
| @@ -156,7 +157,10 @@ void LibraryLoadedOnMainThread(JNIEnv* env) {
|
|
|
| // This method is called on a separate java thread so that we won't trigger
|
| // an ANR.
|
| -static void RunTests(JNIEnv* env, jobject obj, jstring jfiles_dir) {
|
| +static void RunTests(JNIEnv* env,
|
| + jobject obj,
|
| + jstring jfiles_dir,
|
| + jobject app_context) {
|
| FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir));
|
| // A few options, such "--gtest_list_tests", will just use printf directly
|
| // and won't use the "AndroidLogPrinter". Redirect stdout to a known file.
|
| @@ -175,6 +179,11 @@ static void RunTests(JNIEnv* env, jobject obj, jstring jfiles_dir) {
|
| AndroidLogPrinter* log = new AndroidLogPrinter();
|
| log->Init(&argc, &argv[0]);
|
|
|
| + // Set the application context in base.
|
| + base::android::ScopedJavaLocalRef<jobject> scoped_context(
|
| + env, env->NewLocalRef(app_context));
|
| + base::android::InitApplicationContext(scoped_context);
|
| +
|
| main(argc, &argv[0]);
|
| }
|
|
|
|
|