Thread safe renderComponent

Reviewed By: mdvacca

Differential Revision: D7528307

fbshipit-source-id: 1f22898c17f10b883965b03d5c95bbb3c39209c4
This commit is contained in:
Andrew Chen (Eng)
2018-04-06 12:31:02 -07:00
committed by Facebook Github Bot
parent 159869d250
commit c2b9be08f8
3 changed files with 51 additions and 53 deletions
@@ -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();
}