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

Unified Diff: testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java

Issue 1982493002: [Android] Log uncaught Java exceptions when running native tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix findbugs warning Created 4 years, 7 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: testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java
diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java
index 00d5c7899f63cebbef09918e4cc341f32ed3cb3b..1e1cb119a3c78a8e09b6c1d3936fedb3501beddc 100644
--- a/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java
+++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java
@@ -49,6 +49,25 @@ public class NativeTestActivity extends Activity {
private boolean mStdoutFifo = false;
private String mStdoutFilePath;
+ private static class ReportingUncaughtExceptionHandler
+ implements Thread.UncaughtExceptionHandler {
+
+ private TestStatusReporter mReporter;
+ private Thread.UncaughtExceptionHandler mWrappedHandler;
+
+ public ReportingUncaughtExceptionHandler(TestStatusReporter reporter,
+ Thread.UncaughtExceptionHandler wrappedHandler) {
+ mReporter = reporter;
+ mWrappedHandler = wrappedHandler;
+ }
+
+ @Override
+ public void uncaughtException(Thread thread, Throwable ex) {
+ mReporter.uncaughtException(Process.myPid(), ex);
+ if (mWrappedHandler != null) mWrappedHandler.uncaughtException(thread, ex);
+ }
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
ChromiumMultiDexInstaller.install(this);
@@ -58,6 +77,10 @@ public class NativeTestActivity extends Activity {
parseArgumentsFromIntent(getIntent());
mReporter = new TestStatusReporter(this);
+ mReporter.testRunStarted(Process.myPid());
+ Thread.setDefaultUncaughtExceptionHandler(
+ new ReportingUncaughtExceptionHandler(mReporter,
+ Thread.getDefaultUncaughtExceptionHandler()));
}
private void parseArgumentsFromIntent(Intent intent) {
@@ -135,7 +158,6 @@ public class NativeTestActivity extends Activity {
}
private void runTests() {
- mReporter.testRunStarted(Process.myPid());
nativeRunTests(mCommandLineFlags.toString(), mCommandLineFilePath, mStdoutFilePath,
mStdoutFifo, getApplicationContext());
finish();

Powered by Google App Engine
This is Rietveld 408576698