From fc62b00880f4f00366e8e9bc1ea95cc52a1507ac Mon Sep 17 00:00:00 2001 From: Marc Horowitz Date: Tue, 27 Sep 2016 14:48:40 -0700 Subject: [PATCH] Update tests to work better with async runJSBundle Reviewed By: bestander Differential Revision: D3932963 fbshipit-source-id: 16967987b3f777104ab3a41d5967ff1b2f4678db --- .../testing/ReactIntegrationTestCase.java | 3 +- .../react/testing/ReactTestHelper.java | 28 ++++++------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java index 9be060b99f80df..5e703104e5c1ad 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java @@ -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; diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java index 46f636d2574fc9..8a65a51f61908d 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java @@ -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; @@ -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() { - @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; }