Enable Fabric test using Fabric C++ implementation

Summary:
This diff:
- Disables all tests but one of FabricViewTest
- Disables all tests but one of FabricBenchmarkTest
- Changes ReactAppTestActivity to run with Hermes

The reason there is only one test running in each test class, is because the tear down process of Fabric is still flaky and it produces crashes when restarting RN. We are working on this right now and we will enable the rest of the tests after that's fixed.

Reviewed By: achen1

Differential Revision: D9890700

fbshipit-source-id: a8716481eff15b77bd12b38aaaefd4e282c71f3b
This commit is contained in:
David Vacca 2018-09-19 07:59:12 -07:00 committed by Facebook Github Bot
parent 7e7040b7bd
commit 6b0512c819
5 changed files with 29 additions and 5 deletions

View File

@ -208,6 +208,9 @@ public class ReactAppTestActivity extends FragmentActivity
.getReactInstanceManagerBuilder() .getReactInstanceManagerBuilder()
.setApplication(getApplication()) .setApplication(getApplication())
.setBundleAssetName(bundleName); .setBundleAssetName(bundleName);
if (spec.getJavaScriptExecutorFactory() != null) {
builder.setJavaScriptExecutorFactory(spec.getJavaScriptExecutorFactory());
}
if (!spec.getAlternativeReactPackagesForTest().isEmpty()) { if (!spec.getAlternativeReactPackagesForTest().isEmpty()) {
builder.addPackages(spec.getAlternativeReactPackagesForTest()); builder.addPackages(spec.getAlternativeReactPackagesForTest());
} else { } else {

View File

@ -9,12 +9,14 @@ package com.facebook.react.testing;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.NativeModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
/** /**
* A spec that allows a test to add additional NativeModules/JS modules to the ReactInstance. This * A spec that allows a test to add additional NativeModules/JS modules to the ReactInstance. This
@ -29,12 +31,18 @@ public class ReactInstanceSpecForTest {
private final List<Class<? extends JavaScriptModule>> mJSModuleSpecs = new ArrayList<>(); private final List<Class<? extends JavaScriptModule>> mJSModuleSpecs = new ArrayList<>();
private final List<ViewManager> mViewManagers = new ArrayList<>(); private final List<ViewManager> mViewManagers = new ArrayList<>();
private final ArrayList<ReactPackage> mReactPackages = new ArrayList<>(); private final ArrayList<ReactPackage> mReactPackages = new ArrayList<>();
@Nullable private JavaScriptExecutorFactory mJavaScriptExecutorFactory = null;
public ReactInstanceSpecForTest addNativeModule(NativeModule module) { public ReactInstanceSpecForTest addNativeModule(NativeModule module) {
mNativeModules.add(module); mNativeModules.add(module);
return this; return this;
} }
public ReactInstanceSpecForTest setJavaScriptExecutorFactory(JavaScriptExecutorFactory javaScriptExecutorFactory) {
mJavaScriptExecutorFactory = javaScriptExecutorFactory;
return this;
}
public ReactInstanceSpecForTest setPackage(ReactPackage reactPackage) { public ReactInstanceSpecForTest setPackage(ReactPackage reactPackage) {
if (!mReactPackages.isEmpty()) { if (!mReactPackages.isEmpty()) {
throw new IllegalStateException( throw new IllegalStateException(
@ -66,6 +74,11 @@ public class ReactInstanceSpecForTest {
return mReactPackages.get(0); return mReactPackages.get(0);
} }
@Nullable
public JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
return mJavaScriptExecutorFactory;
}
public List<ReactPackage> getAlternativeReactPackagesForTest() { public List<ReactPackage> getAlternativeReactPackagesForTest() {
return mReactPackages; return mReactPackages;
} }

View File

@ -11,9 +11,11 @@ import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.testing.idledetection.IdleWaiter; import com.facebook.react.testing.idledetection.IdleWaiter;
import javax.annotation.Nullable;
/** /**
* Base class for instrumentation tests that runs React based application. * Base class for instrumentation tests that runs React based application.
@ -27,6 +29,9 @@ public abstract class ReactInstrumentationTest extends
protected StringRecordingModule mRecordingModule; protected StringRecordingModule mRecordingModule;
@Nullable
protected JavaScriptExecutorFactory mJavaScriptExecutorFactory = null;
public ReactInstrumentationTest() { public ReactInstrumentationTest() {
super(ReactAppTestActivity.class); super(ReactAppTestActivity.class);
} }
@ -49,7 +54,7 @@ public abstract class ReactInstrumentationTest extends
/** /**
* Renders this component within this test's activity * Renders this component within this test's activity
*/ */
public void renderComponent(final String componentName) throws Exception { public void renderComponent(final String componentName) {
getActivity().renderComponent(componentName, null); getActivity().renderComponent(componentName, null);
waitForBridgeAndUIIdle(); waitForBridgeAndUIIdle();
} }
@ -98,7 +103,12 @@ public abstract class ReactInstrumentationTest extends
* Override this method to provide extra native modules to be loaded before the app starts * Override this method to provide extra native modules to be loaded before the app starts
*/ */
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
return new ReactInstanceSpecForTest().addNativeModule(mRecordingModule); ReactInstanceSpecForTest reactInstanceSpecForTest =
new ReactInstanceSpecForTest().addNativeModule(mRecordingModule);
if (mJavaScriptExecutorFactory != null) {
reactInstanceSpecForTest.setJavaScriptExecutorFactory(mJavaScriptExecutorFactory);
}
return reactInstanceSpecForTest;
} }
/** /**

View File

@ -25,7 +25,6 @@ import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.systrace.Systrace; import com.facebook.systrace.Systrace;
import com.facebook.systrace.TraceListener; import com.facebook.systrace.TraceListener;
import java.lang.annotation.Native;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;

View File

@ -7,10 +7,9 @@
package com.facebook.react.bridge; package com.facebook.react.bridge;
import javax.annotation.Nullable;
import com.facebook.jni.HybridData; import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.proguard.annotations.DoNotStrip;
import javax.annotation.Nullable;
/** /**
* JavaScript executor that delegates JS calls processed by native code back to a java version * JavaScript executor that delegates JS calls processed by native code back to a java version