Skip to content

Commit

Permalink
Update tests to work better with async runJSBundle
Browse files Browse the repository at this point in the history
Reviewed By: bestander

Differential Revision: D3932963

fbshipit-source-id: 16967987b3f777104ab3a41d5967ff1b2f4678db
  • Loading branch information
mhorowitz authored and Facebook Github Bot 9 committed Sep 27, 2016
1 parent ba8066d commit fc62b00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
*/
public abstract class ReactIntegrationTestCase extends AndroidTestCase {

private static final long IDLE_TIMEOUT_MS = 15000;
// we need a bigger timeout for CI builds because they run on a slow emulator
private static final long IDLE_TIMEOUT_MS = 60000;

private @Nullable CatalystInstance mInstance;
private @Nullable ReactBridgeIdleSignaler mBridgeIdleSignaler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;

import android.app.Instrumentation;
import android.content.Context;
Expand Down Expand Up @@ -144,25 +143,14 @@ public ReactTestFactory.ReactInstanceEasyBuilder addJSModule(Class moduleInterfa
@Override
public CatalystInstance build() {
final CatalystInstance instance = builder.build();
try {
instance.getReactQueueConfiguration().getJSQueueThread().callOnQueue(
new Callable<Void>() {
@Override
public Void call() throws Exception {
testCase.initializeWithInstance(instance);
instance.runJSBundle();
return null;
}
}).get();
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
instance.initialize();
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
testCase.initializeWithInstance(instance);
instance.runJSBundle();
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
instance.initialize();
}
});
testCase.waitForBridgeAndUIIdle();
return instance;
}
Expand Down

0 comments on commit fc62b00

Please sign in to comment.