From 294185ac328b1c9ae2da6331575d48fc1bb818ff Mon Sep 17 00:00:00 2001 From: Chris Hopman Date: Fri, 5 Feb 2016 18:09:18 -0800 Subject: [PATCH] Fix race in catalyst tests Summary: Native code accesses the Java Application through the ApplicationHolder. The application should be set on the holder as soon as possible. This change fixes a race in WebWorkersTest. public Reviewed By: astreet Differential Revision: D2905157 fb-gh-sync-id: 7e488f4eecefedb8482276776b3a66e14a843f90 --- .../facebook/react/testing/ReactIntegrationTestCase.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 3b8f1aba6..5161a4aaa 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java @@ -147,7 +147,6 @@ public abstract class ReactIntegrationTestCase extends AndroidTestCase { mBridgeIdleSignaler = new ReactBridgeIdleSignaler(); mInstance.addBridgeIdleDebugListener(mBridgeIdleSignaler); getContext().initializeWithInstance(mInstance); - ApplicationHolder.setApplication((Application) getContext().getApplicationContext()); } public boolean waitForBridgeIdle(long millis) { @@ -165,6 +164,12 @@ public abstract class ReactIntegrationTestCase extends AndroidTestCase { IDLE_TIMEOUT_MS); } + @Override + protected void setUp() throws Exception { + super.setUp(); + ApplicationHolder.setApplication((Application) getContext().getApplicationContext()); + } + @Override protected void tearDown() throws Exception { super.tearDown();