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(); |