From f7eca44046e47abb1ad465e1a26d79263a2d462c Mon Sep 17 00:00:00 2001 From: Franklyn Tackitt Date: Fri, 24 Jun 2016 13:25:15 -0700 Subject: [PATCH] Reverted commit D3443980 Summary: Currently, DevTools only work under ios (although this is undocumented!), because the JavaScriptEngine initialization process skips setupDevTools() on android. DevTools work fine with Android, as tested on 0.26, 0.27, and 0.28 using Nuclide's inspector. For reference, [the relevant issue on react-devtools](https://github.com/facebook/react-devtools/issues/229). Closes https://github.com/facebook/react-native/pull/8095 Reviewed By: javache Differential Revision: D3443980 Pulled By: bestander fbshipit-source-id: ce0f7dd62ae0f7dfe6654380821660f8660318a6 --- .../InitializeJavaScriptAppEngine.js | 2 +- .../react/testing/FakeWebSocketModule.java | 60 ------------------- .../testing/ReactInstanceSpecForTest.java | 4 +- ...alystNativeJSToJavaParametersTestCase.java | 6 +- ...talystNativeJavaToJSArgumentsTestCase.java | 2 - .../react/tests/InitialPropsTestCase.java | 2 - .../facebook/react/tests/JSLocaleTest.java | 5 +- .../react/tests/ProgressBarTestCase.java | 2 - .../react/tests/ViewRenderingTestCase.java | 2 - 9 files changed, 8 insertions(+), 77 deletions(-) delete mode 100644 ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index c83c52047..ba5fa68fc 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -220,7 +220,7 @@ function setUpCollections(): void { function setUpDevTools(): void { if (__DEV__) { // not when debugging in chrome - if (!window.document) { + if (!window.document && require('Platform').OS === 'ios') { const setupDevtools = require('setupDevtools'); setupDevtools(); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java deleted file mode 100644 index 76c9edb23..000000000 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * All rights reserved. - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package com.facebook.react.testing; - -import javax.annotation.Nullable; - -import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.BaseJavaModule; -import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.WritableMap; - -/** - * Dummy implementation of storage module, used for testing - */ -public final class FakeWebSocketModule extends BaseJavaModule { - - private static WritableMap errorMessage; - static { - errorMessage = Arguments.createMap(); - errorMessage.putString("message", "Fake Fake Web Socke tModule"); - } - - @Override - public String getName() { - return "WebSocketModule"; - } - - @Override - public boolean canOverrideExistingModule() { - return true; - } - - @ReactMethod - public void connect( - final String url, - @Nullable final ReadableArray protocols, - @Nullable final ReadableMap headers, - final int id) { - } - - @ReactMethod - public void close(int code, String reason, int id) { - } - - @ReactMethod - public void send(String message, int id) { - } - - @ReactMethod - public void sendBinary(String base64String, int id) { - } -} diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java index bf179010b..b9de7a1e7 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java @@ -9,7 +9,6 @@ package com.facebook.react.testing; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import android.annotation.SuppressLint; @@ -27,8 +26,7 @@ import com.facebook.react.ReactPackage; @SuppressLint("JavatestsIncorrectFolder") public class ReactInstanceSpecForTest { - private final List mNativeModules = - new ArrayList(Arrays.asList(new FakeWebSocketModule())); + private final List mNativeModules = new ArrayList<>(); private final List> mJSModuleSpecs = new ArrayList<>(); private final List mViewManagers = new ArrayList<>(); private ReactPackage mReactPackage = null; diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java index 06ff91a0c..f6130be3a 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java @@ -30,7 +30,6 @@ import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.modules.systeminfo.AndroidInfoModule; -import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; import com.facebook.react.uimanager.UIImplementation; @@ -38,6 +37,8 @@ import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.view.ReactViewManager; +import org.junit.Ignore; + /** * Integration test to verify passing various types of parameters from JS to Java works */ @@ -73,7 +74,7 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe @Override protected void setUp() throws Exception { super.setUp(); - + List viewManagers = Arrays.asList( new ReactViewManager()); final UIManagerModule mUIManager = new UIManagerModule( @@ -93,7 +94,6 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe mCatalystInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mRecordingTestModule) .addNativeModule(new AndroidInfoModule()) - .addNativeModule(new FakeWebSocketModule()) .addNativeModule(mUIManager) .addJSModule(TestJSToJavaParametersModule.class) .build(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java index 587f99121..fd6b1d779 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java @@ -20,7 +20,6 @@ import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.testing.AssertModule; -import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; import com.facebook.react.uimanager.UIImplementation; @@ -76,7 +75,6 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes mInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mAssertModule) - .addNativeModule(new FakeWebSocketModule()) .addJSModule(TestJavaToJSArgumentsModule.class) .addNativeModule(mUIManager) .build(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java index 951c59353..6f532e15c 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java @@ -12,7 +12,6 @@ import android.os.Bundle; import android.test.ActivityInstrumentationTestCase2; import com.facebook.react.bridge.BaseJavaModule; -import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactInstanceSpecForTest; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; @@ -71,7 +70,6 @@ public class InitialPropsTestCase extends @Override public void run() { ReactInstanceSpecForTest catalystInstanceSpec = new ReactInstanceSpecForTest(); - catalystInstanceSpec.addNativeModule(new FakeWebSocketModule()); catalystInstanceSpec.addNativeModule(mRecordingModule); Bundle props = new Bundle(); props.putString("key1", "string"); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java index d20b72fb4..370f353c3 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java @@ -11,7 +11,6 @@ package com.facebook.react.tests; import java.util.Arrays; import java.util.List; -import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; import com.facebook.react.testing.StringRecordingModule; @@ -60,9 +59,9 @@ public class JSLocaleTest extends ReactIntegrationTestCase { mInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mStringRecordingModule) .addNativeModule(mUIManager) - .addNativeModule(new FakeWebSocketModule()) .addJSModule(TestJSLocaleModule.class) .build(); + } public void testToUpper() { @@ -101,4 +100,6 @@ public class JSLocaleTest extends ReactIntegrationTestCase { assertEquals("γαζίες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο", answers[3]); assertEquals("chinese: 幓 厏吪吙 鈊釿閍 碞碠粻 曮禷", answers[4]); } + + } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java index 0886f20fa..b3282629b 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java @@ -30,7 +30,6 @@ import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.progressbar.ReactProgressBarViewManager; import com.facebook.react.views.view.ReactViewManager; -import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; @@ -84,7 +83,6 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase { mInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mUIManager) .addNativeModule(new AndroidInfoModule()) - .addNativeModule(new FakeWebSocketModule()) .addJSModule(ProgressBarTestModule.class) .build(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java index 38fff46ac..f4f817c2b 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java @@ -26,7 +26,6 @@ import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.view.ReactViewGroup; import com.facebook.react.views.view.ReactViewManager; -import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; @@ -65,7 +64,6 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase { mCatalystInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(uiManager) .addNativeModule(new AndroidInfoModule()) - .addNativeModule(new FakeWebSocketModule()) .addJSModule(ViewRenderingTestModule.class) .build();