mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Thread safe renderComponent
Reviewed By: mdvacca Differential Revision: D7528307 fbshipit-source-id: 1f22898c17f10b883965b03d5c95bbb3c39209c4
This commit is contained in:
committed by
Facebook Github Bot
parent
159869d250
commit
c2b9be08f8
+5
-25
@@ -37,37 +37,17 @@ public abstract class ReactInstrumentationTest extends
|
||||
intent.putExtra(ReactAppTestActivity.EXTRA_IS_FABRIC_TEST, isFabricTest());
|
||||
setActivityIntent(intent);
|
||||
final ReactAppTestActivity activity = getActivity();
|
||||
try {
|
||||
runTestOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
activity.loadBundle(
|
||||
createReactInstanceSpecForTest(),
|
||||
getBundleName(),
|
||||
getEnableDevSupport());
|
||||
}
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
throw new Exception("Unable to load react bundle " + getBundleName(), t);
|
||||
}
|
||||
activity.loadBundle(
|
||||
createReactInstanceSpecForTest(),
|
||||
getBundleName(),
|
||||
getEnableDevSupport());
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders this component within this test's activity
|
||||
*/
|
||||
public void renderComponent(final String componentName) throws Exception {
|
||||
final ReactAppTestActivity activity = getActivity();
|
||||
try {
|
||||
runTestOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
activity.renderComponent(componentName, null);
|
||||
}
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
throw new Exception("Unable to render component " + componentName, t);
|
||||
}
|
||||
assertTrue("Layout never occurred!", activity.waitForLayout(5000));
|
||||
getActivity().renderComponent(componentName, null);
|
||||
waitForBridgeAndUIIdle();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user