From 92c1b7bc0f6a9357f5b722812e3734aaa6a7b762 Mon Sep 17 00:00:00 2001 From: empyrical Date: Fri, 24 Aug 2018 18:22:37 -0600 Subject: [PATCH] Add e2e test for out of tree platforms --- ContainerShip/scripts/run-ci-e2e-tests.sh | 14 +++++ .../AccessibilityInfo.dummy.js | 15 ++++++ .../ActivityIndicator.dummy.js | 12 +++++ .../Components/CheckBox/CheckBox.dummy.js | 12 +++++ .../DatePicker/DatePickerIOS.dummy.js | 12 +++++ .../DatePickerAndroid.dummy.js | 21 ++++++++ .../DrawerLayoutAndroid.dummy.js | 12 +++++ .../Libraries/Components/Image/Image.dummy.js | 12 +++++ .../MaskedView/MaskedViewIOS.dummy.js | 12 +++++ .../Navigation/NavigatorIOS.dummy.js | 12 +++++ .../Components/Picker/PickerAndroid.dummy.js | 12 +++++ .../Components/Picker/PickerIOS.dummy.js | 12 +++++ .../ProgressBarAndroid.dummy.js | 12 +++++ .../ProgressViewIOS/ProgressViewIOS.dummy.js | 46 +++++++++++++++++ .../SafeAreaView/SafeAreaView.dummy.js | 13 +++++ .../SegmentedControlIOS.dummy.js | 46 +++++++++++++++++ .../StatusBar/StatusBarIOS.dummy.js | 13 +++++ .../Components/TabBarIOS/TabBarIOS.dummy.js | 36 +++++++++++++ .../TabBarIOS/TabBarItemIOS.dummy.js | 40 +++++++++++++++ .../TimePickerAndroid.dummy.js | 21 ++++++++ .../ToastAndroid/ToastAndroid.dummy.js | 21 ++++++++ .../ToolbarAndroid/ToolbarAndroid.dummy.js | 12 +++++ .../TouchableNativeFeedback.dummy.js | 51 +++++++++++++++++++ .../ViewPager/ViewPagerAndroid.dummy.js | 12 +++++ .../Components/WebView/WebView.dummy.js | 12 +++++ .../Networking/RCTNetworking.dummy.js | 37 ++++++++++++++ .../RCTTest/SnapshotViewIOS.dummy.js | 12 +++++ .../Libraries/Settings/Settings.dummy.js | 17 +++++++ .../Libraries/Utilities/BackHandler.dummy.js | 27 ++++++++++ .../Utilities/HMRLoadingView.dummy.js | 30 +++++++++++ .../Libraries/Utilities/Platform.dummy.js | 32 ++++++++++++ .../Libraries/Vibration/VibrationIOS.dummy.js | 22 ++++++++ .../react-native-dummy-implementation.js | 15 ++++++ .../js/OutOfTreeTestPlatform/package.json | 14 +++++ jest/hasteImpl.js | 12 ++++- 35 files changed, 710 insertions(+), 1 deletion(-) create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/AccessibilityInfo/AccessibilityInfo.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ActivityIndicator/ActivityIndicator.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/CheckBox/CheckBox.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePicker/DatePickerIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePickerAndroid/DatePickerAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Image/Image.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/MaskedView/MaskedViewIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Navigation/NavigatorIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressViewIOS/ProgressViewIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SafeAreaView/SafeAreaView.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/StatusBar/StatusBarIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarItemIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TimePickerAndroid/TimePickerAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToastAndroid/ToastAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToolbarAndroid/ToolbarAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Touchable/TouchableNativeFeedback.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ViewPager/ViewPagerAndroid.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Components/WebView/WebView.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Networking/RCTNetworking.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/RCTTest/SnapshotViewIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Settings/Settings.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/BackHandler.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/HMRLoadingView.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/Platform.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/Vibration/VibrationIOS.dummy.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/Libraries/react-native-dummy/react-native-dummy-implementation.js create mode 100644 RNTester/js/OutOfTreeTestPlatform/package.json diff --git a/ContainerShip/scripts/run-ci-e2e-tests.sh b/ContainerShip/scripts/run-ci-e2e-tests.sh index de2b97edb5bb7a..7da2bbb2031947 100755 --- a/ContainerShip/scripts/run-ci-e2e-tests.sh +++ b/ContainerShip/scripts/run-ci-e2e-tests.sh @@ -17,6 +17,7 @@ AVD_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1) ANDROID_NPM_DEPS="appium@1.5.1 mocha@2.4.5 wd@0.3.11 colors@1.0.3 pretty-data2@0.40.1" CLI_PACKAGE=$ROOT/react-native-cli/react-native-cli-*.tgz PACKAGE=$ROOT/react-native-*.tgz +DUMMY_PLATFORM_PACKAGE=$ROOT/RNTester/js/OutOfTreeTestPlatform/react-native-dummy-*.tgz # solve issue with max user watches limit echo 65536 | tee -a /proc/sys/fs/inotify/max_user_watches @@ -96,6 +97,11 @@ function e2e_suite() { npm pack cd .. + # install dummy platform + cd RNTester/js/OutOfTreeTestPlatform + npm pack + cd ../../../ + # can skip cli install for non sudo mode if [ $RUN_CLI_INSTALL -ne 0 ]; then npm install -g $CLI_PACKAGE @@ -229,6 +235,8 @@ function e2e_suite() { # js tests if [ $RUN_JS -ne 0 ]; then + npm install $DUMMY_PLATFORM_PACKAGE --save + # Check the packager produces a bundle (doesn't throw an error) react-native bundle --max-workers 1 --platform android --dev true --entry-file index.js --bundle-output android-bundle.js if [ $? -ne 0 ]; then @@ -241,6 +249,12 @@ function e2e_suite() { echo "Could not build iOS bundle" return 1 fi + + react-native bundle --max-workers 1 --platform dummy --dev true --entry-file index.js --bundle-output dummy-bundle.js + if [ $? -ne 0 ]; then + echo "Could not build out-of-tree dummy bundle" + return 1 + fi fi # directory cleanup diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/AccessibilityInfo/AccessibilityInfo.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/AccessibilityInfo/AccessibilityInfo.dummy.js new file mode 100644 index 00000000000000..f2adb6ea95de2e --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/AccessibilityInfo/AccessibilityInfo.dummy.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const AccessibilityInfo = {}; + +module.exports = AccessibilityInfo; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ActivityIndicator/ActivityIndicator.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ActivityIndicator/ActivityIndicator.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ActivityIndicator/ActivityIndicator.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/CheckBox/CheckBox.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/CheckBox/CheckBox.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/CheckBox/CheckBox.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePicker/DatePickerIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePicker/DatePickerIOS.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePicker/DatePickerIOS.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePickerAndroid/DatePickerAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePickerAndroid/DatePickerAndroid.dummy.js new file mode 100644 index 00000000000000..3b10d856493573 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DatePickerAndroid/DatePickerAndroid.dummy.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const DatePickerAndroid = { + async open(options: Object): Promise { + return Promise.reject({ + message: 'DatePickerAndroid is not supported on this platform.', + }); + }, +}; + +module.exports = DatePickerAndroid; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Image/Image.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Image/Image.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Image/Image.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/MaskedView/MaskedViewIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/MaskedView/MaskedViewIOS.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/MaskedView/MaskedViewIOS.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Navigation/NavigatorIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Navigation/NavigatorIOS.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Navigation/NavigatorIOS.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerAndroid.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerAndroid.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerIOS.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Picker/PickerIOS.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressViewIOS/ProgressViewIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressViewIOS/ProgressViewIOS.dummy.js new file mode 100644 index 00000000000000..8caa73db33e494 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ProgressViewIOS/ProgressViewIOS.dummy.js @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); + +class DummyProgressViewIOS extends React.Component { + render() { + return ( + + + ProgressViewIOS is not supported on this platform! + + + ); + } +} + +const styles = StyleSheet.create({ + dummy: { + width: 120, + height: 20, + backgroundColor: '#ffbcbc', + borderWidth: 1, + borderColor: 'red', + alignItems: 'center', + justifyContent: 'center', + }, + text: { + color: '#333333', + margin: 5, + fontSize: 10, + }, +}); + +module.exports = DummyProgressViewIOS; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SafeAreaView/SafeAreaView.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SafeAreaView/SafeAreaView.dummy.js new file mode 100644 index 00000000000000..ed6138f310609f --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SafeAreaView/SafeAreaView.dummy.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +module.exports = require('View'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.dummy.js new file mode 100644 index 00000000000000..7a988960ceca96 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.dummy.js @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); + +class DummySegmentedControlIOS extends React.Component { + render() { + return ( + + + SegmentedControlIOS is not supported on this platform! + + + ); + } +} + +const styles = StyleSheet.create({ + dummy: { + width: 120, + height: 50, + backgroundColor: '#ffbcbc', + borderWidth: 1, + borderColor: 'red', + alignItems: 'center', + justifyContent: 'center', + }, + text: { + color: '#333333', + margin: 5, + fontSize: 10, + }, +}); + +module.exports = DummySegmentedControlIOS; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/StatusBar/StatusBarIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/StatusBar/StatusBarIOS.dummy.js new file mode 100644 index 00000000000000..8a4b091f1eb79b --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/StatusBar/StatusBarIOS.dummy.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +module.exports = {}; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarIOS.dummy.js new file mode 100644 index 00000000000000..e8e376f8a9eb7e --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarIOS.dummy.js @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const TabBarItemIOS = require('TabBarItemIOS'); +const View = require('View'); + +class DummyTabBarIOS extends React.Component<$FlowFixMeProps> { + static Item = TabBarItemIOS; + + render() { + return ( + + {this.props.children} + + ); + } +} + +const styles = StyleSheet.create({ + tabGroup: { + flex: 1, + }, +}); + +module.exports = DummyTabBarIOS; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarItemIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarItemIOS.dummy.js new file mode 100644 index 00000000000000..7528af9ce0104e --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TabBarIOS/TabBarItemIOS.dummy.js @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +const React = require('React'); +const View = require('View'); +const StyleSheet = require('StyleSheet'); + +class DummyTab extends React.Component { + render() { + if (!this.props.selected) { + return ; + } + return ( + {this.props.children} + ); + } +} + +const styles = StyleSheet.create({ + tab: { + // From upstream react-native: TODO(5405356): Implement overflow: visible so position: absolute isn't useless + // position: 'absolute', + top: 0, + right: 0, + bottom: 0, + left: 0, + borderColor: 'red', + borderWidth: 1, + }, +}); + +module.exports = DummyTab; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TimePickerAndroid/TimePickerAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TimePickerAndroid/TimePickerAndroid.dummy.js new file mode 100644 index 00000000000000..6a0ecfa656313c --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/TimePickerAndroid/TimePickerAndroid.dummy.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const TimePickerAndroid = { + async open(options: Object): Promise { + return Promise.reject({ + message: 'TimePickerAndroid is not supported on this platform.', + }); + }, +}; + +module.exports = TimePickerAndroid; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToastAndroid/ToastAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToastAndroid/ToastAndroid.dummy.js new file mode 100644 index 00000000000000..50d6f022b2bcb8 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToastAndroid/ToastAndroid.dummy.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @noflow + */ + +'use strict'; + +const warning = require('fbjs/lib/warning'); + +const ToastAndroid = { + show: function(message: string, duration: number): void { + warning(false, 'ToastAndroid is not currently supported on this platform.'); + }, +}; + +module.exports = ToastAndroid; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToolbarAndroid/ToolbarAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToolbarAndroid/ToolbarAndroid.dummy.js new file mode 100644 index 00000000000000..260d559929796f --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ToolbarAndroid/ToolbarAndroid.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Touchable/TouchableNativeFeedback.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Touchable/TouchableNativeFeedback.dummy.js new file mode 100644 index 00000000000000..b0770047bbeef8 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/Touchable/TouchableNativeFeedback.dummy.js @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); + +class DummyTouchableNativeFeedback extends React.Component { + static SelectableBackground = () => ({}); + static SelectableBackgroundBorderless = () => ({}); + static Ripple = () => ({}); + static canUseNativeForeground = () => false; + + render() { + return ( + + + TouchableNativeFeedback is not supported on this platform! + + + ); + } +} + +const styles = StyleSheet.create({ + container: { + height: 100, + width: 300, + backgroundColor: '#ffbcbc', + borderWidth: 1, + borderColor: 'red', + alignItems: 'center', + justifyContent: 'center', + margin: 10, + }, + info: { + color: '#333333', + margin: 20, + }, +}); + +module.exports = DummyTouchableNativeFeedback; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ViewPager/ViewPagerAndroid.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ViewPager/ViewPagerAndroid.dummy.js new file mode 100644 index 00000000000000..260d559929796f --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/ViewPager/ViewPagerAndroid.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/WebView/WebView.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/WebView/WebView.dummy.js new file mode 100644 index 00000000000000..260d559929796f --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Components/WebView/WebView.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Networking/RCTNetworking.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Networking/RCTNetworking.dummy.js new file mode 100644 index 00000000000000..06dac45389dd81 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Networking/RCTNetworking.dummy.js @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + * @todo Implement + */ + +'use strict'; + +const MissingNativeEventEmitterShim = require('MissingNativeEventEmitterShim'); + +class MissingNativeRCTNetworkingShim extends MissingNativeEventEmitterShim { + isAvailable: boolean = false; + constructor() { + super('RCTNetworking', 'Networking'); + } + + sendRequest(...args: Array) { + this.throwMissingNativeModule(); + } + + abortRequest(...args: Array) { + this.throwMissingNativeModule(); + } + + clearCookies(...args: Array) { + this.throwMissingNativeModule(); + } +} + +const RCTNetworking = new MissingNativeRCTNetworkingShim(); + +module.exports = RCTNetworking; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/RCTTest/SnapshotViewIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/RCTTest/SnapshotViewIOS.dummy.js new file mode 100644 index 00000000000000..5fda2cd5ec2bce --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/RCTTest/SnapshotViewIOS.dummy.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('UnimplementedView'); diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Settings/Settings.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Settings/Settings.dummy.js new file mode 100644 index 00000000000000..4906e5f60ae46f --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Settings/Settings.dummy.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + * @todo Implement + */ + +'use strict'; + +// Completely empty shim for the sake of bundling. +const Settings = {}; + +module.exports = Settings; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/BackHandler.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/BackHandler.dummy.js new file mode 100644 index 00000000000000..02420530e8850b --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/BackHandler.dummy.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * On Apple TV, this implements back navigation using the TV remote's menu button. + * On iOS, this just implements a stub. + * + * @format + */ + +'use strict'; + +function emptyFunction() {} + +const BackHandler = { + exitApp: emptyFunction, + addEventListener() { + return { + remove: emptyFunction, + }; + }, + removeEventListener: emptyFunction, +}; + +module.exports = BackHandler; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/HMRLoadingView.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/HMRLoadingView.dummy.js new file mode 100644 index 00000000000000..a349407f23bb10 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/HMRLoadingView.dummy.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict-local + */ + +'use strict'; + +const processColor = require('processColor'); +const {DevLoadingView} = require('NativeModules'); + +class HMRLoadingView { + static showMessage(message: string) { + DevLoadingView.showMessage( + message, + processColor('#000000'), + processColor('#aaaaaa'), + ); + } + + static hide() { + DevLoadingView.hide(); + } +} + +module.exports = HMRLoadingView; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/Platform.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/Platform.dummy.js new file mode 100644 index 00000000000000..807303609d1063 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Utilities/Platform.dummy.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const NativeModules = require('NativeModules'); + +const Platform = { + OS: 'test', + get Version() { + const constants = NativeModules.PlatformConstants; + return constants && constants.Version; + }, + get isTesting(): boolean { + const constants = NativeModules.PlatformConstants; + return constants && constants.isTesting; + }, + get isTV(): boolean { + const constants = NativeModules.PlatformConstants; + return constants && constants.uiMode === 'tv'; + }, + select: (obj: Object) => ('test' in obj ? obj.test : obj.default), +}; + +module.exports = Platform; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/Vibration/VibrationIOS.dummy.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/Vibration/VibrationIOS.dummy.js new file mode 100644 index 00000000000000..c05739cf802c51 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/Vibration/VibrationIOS.dummy.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * Stub of VibrationIOS for Test Platform. + * + * @format + */ + +'use strict'; + +const warning = require('fbjs/lib/warning'); + +const VibrationIOS = { + vibrate: function() { + warning('VibrationIOS is not supported on this platform!'); + }, +}; + +module.exports = VibrationIOS; diff --git a/RNTester/js/OutOfTreeTestPlatform/Libraries/react-native-dummy/react-native-dummy-implementation.js b/RNTester/js/OutOfTreeTestPlatform/Libraries/react-native-dummy/react-native-dummy-implementation.js new file mode 100644 index 00000000000000..984d0d663eca0a --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/Libraries/react-native-dummy/react-native-dummy-implementation.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const ReactNativeDummy = {}; + +module.exports = ReactNativeDummy; diff --git a/RNTester/js/OutOfTreeTestPlatform/package.json b/RNTester/js/OutOfTreeTestPlatform/package.json new file mode 100644 index 00000000000000..32f2303b800351 --- /dev/null +++ b/RNTester/js/OutOfTreeTestPlatform/package.json @@ -0,0 +1,14 @@ +{ + "name": "react-native-dummy", + "version": "0.0.1", + "description": "Example platform for testing the bundler with out-of-tree platforms", + "main": "Libraries/react-native-dummy/react-native-dummy-implementation.js", + "repository": "https://github.com/facebook/react-native.git", + "license": "MIT", + "rnpm": { + "haste": { + "platforms": ["dummy"], + "providesModuleNodeModules": ["react-native-dummy"] + } + } +} diff --git a/jest/hasteImpl.js b/jest/hasteImpl.js index 9d1861bc9f2428..99c56bb766d3bc 100644 --- a/jest/hasteImpl.js +++ b/jest/hasteImpl.js @@ -13,7 +13,17 @@ const path = require('path'); const findPlugins = require('../local-cli/core/findPlugins'); -const plugins = findPlugins([path.resolve(__dirname, '../../../')]); +const REACT_NATIVE_CI = process.cwd() === path.resolve(__dirname, '..'); + +let pluginsPath; + +if (REACT_NATIVE_CI) { + pluginsPath = '..'; +} else { + pluginsPath = '../../../'; +} + +const plugins = findPlugins([path.resolve(__dirname, pluginsPath)]); // Detect out-of-tree platforms and add them to the whitelists const pluginRoots /*: Array<