Customize ExceptionHandler in ReactAppTestActivity

Summary:
This diff extends the ReactAppTestActivity to allow customization of the RN ExceptionHandler

Changelog:
This diff extends the ReactAppTestActivity to allow customization of the RN ExceptionHandler

Reviewed By: JoshuaGross

Differential Revision: D17993132

fbshipit-source-id: 7320d35a4d88d56a7356f2863829c88758c08341
This commit is contained in:
David Vacca
2019-10-18 09:09:30 -07:00
committed by Facebook Github Bot
parent 8425292eb4
commit 3408dc0b3e
2 changed files with 16 additions and 0 deletions
@@ -207,6 +207,10 @@ public class ReactAppTestActivity extends FragmentActivity
if (spec.getJavaScriptExecutorFactory() != null) {
builder.setJavaScriptExecutorFactory(spec.getJavaScriptExecutorFactory());
}
if (spec.getNativeModuleCallExceptionHandler() != null) {
builder.setNativeModuleCallExceptionHandler(spec.getNativeModuleCallExceptionHandler());
}
if (!spec.getAlternativeReactPackagesForTest().isEmpty()) {
builder.addPackages(spec.getAlternativeReactPackagesForTest());
} else {
@@ -13,6 +13,7 @@ import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,6 +32,7 @@ public class ReactInstanceSpecForTest {
private final List<Class<? extends JavaScriptModule>> mJSModuleSpecs = new ArrayList<>();
private final List<ViewManager> mViewManagers = new ArrayList<>();
private final ArrayList<ReactPackage> mReactPackages = new ArrayList<>();
@Nullable private NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler = null;
@Nullable private FabricUIManagerFactory mFabricUIManagerFactory = null;
@Nullable private JavaScriptExecutorFactory mJavaScriptExecutorFactory = null;
@@ -39,6 +41,16 @@ public class ReactInstanceSpecForTest {
return this;
}
public ReactInstanceSpecForTest setNativeModuleCallExceptionHandler(
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
return this;
}
public NativeModuleCallExceptionHandler getNativeModuleCallExceptionHandler() {
return mNativeModuleCallExceptionHandler;
}
public ReactInstanceSpecForTest setJavaScriptExecutorFactory(
JavaScriptExecutorFactory javaScriptExecutorFactory) {
mJavaScriptExecutorFactory = javaScriptExecutorFactory;