Remove iOS platform check for running devtools

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.
Closes https://github.com/facebook/react-native/pull/8095

Reviewed By: bestander

Differential Revision: D3492788

Pulled By: andreicoman11

fbshipit-source-id: 1eda9196d7125da19a8d7baaab22b61b744ca629
This commit is contained in:
Franklyn Tackitt 2016-07-01 04:25:15 -07:00 committed by Facebook Github Bot 5
parent 010e1977a8
commit 22fbb6d46d
10 changed files with 71 additions and 8 deletions

View File

@ -200,7 +200,7 @@ function setUpCollections(): void {
function setUpDevTools(): void {
if (__DEV__) {
// not when debugging in chrome
if (!window.document && require('Platform').OS === 'ios') {
if (!window.document) {
const setupDevtools = require('setupDevtools');
setupDevtools();
}

View File

@ -0,0 +1,52 @@
/**
* 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.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
/**
* Dummy implementation of storage module, used for testing
*/
public final class FakeWebSocketModule extends BaseJavaModule {
@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) {
}
}

View File

@ -9,6 +9,7 @@
package com.facebook.react.testing;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.annotation.SuppressLint;
@ -26,7 +27,8 @@ import com.facebook.react.ReactPackage;
@SuppressLint("JavatestsIncorrectFolder")
public class ReactInstanceSpecForTest {
private final List<NativeModule> mNativeModules = new ArrayList<>();
private final List<NativeModule> mNativeModules =
new ArrayList<NativeModule>(Arrays.asList(new FakeWebSocketModule()));
private final List<Class<? extends JavaScriptModule>> mJSModuleSpecs = new ArrayList<>();
private final List<ViewManager> mViewManagers = new ArrayList<>();
private ReactPackage mReactPackage = null;

View File

@ -30,6 +30,7 @@ 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;
@ -37,8 +38,6 @@ 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
*/
@ -74,7 +73,7 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe
@Override
protected void setUp() throws Exception {
super.setUp();
List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
new ReactViewManager());
final UIManagerModule mUIManager = new UIManagerModule(
@ -94,6 +93,7 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe
mCatalystInstance = ReactTestHelper.catalystInstanceBuilder(this)
.addNativeModule(mRecordingTestModule)
.addNativeModule(new AndroidInfoModule())
.addNativeModule(new FakeWebSocketModule())
.addNativeModule(mUIManager)
.addJSModule(TestJSToJavaParametersModule.class)
.build();

View File

@ -20,6 +20,7 @@ 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;
@ -75,6 +76,7 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes
mInstance = ReactTestHelper.catalystInstanceBuilder(this)
.addNativeModule(mAssertModule)
.addNativeModule(new FakeWebSocketModule())
.addJSModule(TestJavaToJSArgumentsModule.class)
.addNativeModule(mUIManager)
.build();

View File

@ -29,6 +29,7 @@ import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.text.ReactRawTextManager;
import com.facebook.react.views.text.ReactTextViewManager;
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;
@ -92,6 +93,7 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase {
jsModule = ReactTestHelper.catalystInstanceBuilder(this)
.addNativeModule(uiManager)
.addNativeModule(new AndroidInfoModule())
.addNativeModule(new FakeWebSocketModule())
.addJSModule(UIManagerTestModule.class)
.build()
.getJSModule(UIManagerTestModule.class);

View File

@ -12,6 +12,7 @@ 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;
@ -70,6 +71,7 @@ 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");

View File

@ -11,6 +11,7 @@ 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;
@ -59,9 +60,9 @@ public class JSLocaleTest extends ReactIntegrationTestCase {
mInstance = ReactTestHelper.catalystInstanceBuilder(this)
.addNativeModule(mStringRecordingModule)
.addNativeModule(mUIManager)
.addNativeModule(new FakeWebSocketModule())
.addJSModule(TestJSLocaleModule.class)
.build();
}
public void testToUpper() {
@ -100,6 +101,4 @@ public class JSLocaleTest extends ReactIntegrationTestCase {
assertEquals("γαζίες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο", answers[3]);
assertEquals("chinese: 幓 厏吪吙 鈊釿閍 碞碠粻 曮禷", answers[4]);
}
}

View File

@ -30,6 +30,7 @@ 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;
@ -83,6 +84,7 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase {
mInstance = ReactTestHelper.catalystInstanceBuilder(this)
.addNativeModule(mUIManager)
.addNativeModule(new AndroidInfoModule())
.addNativeModule(new FakeWebSocketModule())
.addJSModule(ProgressBarTestModule.class)
.build();

View File

@ -26,6 +26,7 @@ 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;
@ -64,6 +65,7 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase {
mCatalystInstance = ReactTestHelper.catalystInstanceBuilder(this)
.addNativeModule(uiManager)
.addNativeModule(new AndroidInfoModule())
.addNativeModule(new FakeWebSocketModule())
.addJSModule(ViewRenderingTestModule.class)
.build();