summaryrefslogtreecommitdiffstats
path: root/testing/android/native_test_launcher.cc
diff options
context:
space:
mode:
authornileshagrawal@chromium.org <nileshagrawal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-26 20:19:47 +0000
committernileshagrawal@chromium.org <nileshagrawal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-26 20:19:47 +0000
commit595b063ca05e9b4134a21fd53a08f5fe6ad9624c (patch)
treefd662dfb97b495d00acc10098827bf4b94d5de9e /testing/android/native_test_launcher.cc
parente0b32e85e0712cdd721a0c1cd283964f798489f3 (diff)
downloadchromium_src-595b063ca05e9b4134a21fd53a08f5fe6ad9624c.zip
chromium_src-595b063ca05e9b4134a21fd53a08f5fe6ad9624c.tar.gz
chromium_src-595b063ca05e9b4134a21fd53a08f5fe6ad9624c.tar.bz2
Add PathUtilsTest.
- This test invokes JNI calls and included only if gtest_target_type=shared_library. - Also set the application context to get these JNI calls working. BUG=125059 TEST= Review URL: http://codereview.chromium.org/10161032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'testing/android/native_test_launcher.cc')
-rw-r--r--testing/android/native_test_launcher.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/testing/android/native_test_launcher.cc b/testing/android/native_test_launcher.cc
index 455d43d..1555fbe 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]);
}