summaryrefslogtreecommitdiffstats
path: root/testing
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
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')
-rw-r--r--testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java5
-rw-r--r--testing/android/native_test_launcher.cc11
2 files changed, 13 insertions, 3 deletions
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
index b4bb6ad..35e381f 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
@@ -5,6 +5,7 @@
package org.chromium.native_test;
import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.util.Log;
@@ -36,7 +37,7 @@ public class ChromeNativeTestActivity extends Activity {
@Override
public void run() {
Log.d(TAG, ">>nativeRunTests");
- nativeRunTests(getFilesDir().getAbsolutePath());
+ nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext());
// TODO(jrg): make sure a crash in native code
// triggers nativeTestFailed().
Log.d(TAG, "<<nativeRunTests");
@@ -62,5 +63,5 @@ public class ChromeNativeTestActivity extends Activity {
Log.i(TAG, "loaded: " + mLibrary);
}
- private native void nativeRunTests(String filesDir);
+ private native void nativeRunTests(String filesDir, Context appContext);
}
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]);
}