Skip to content

Commit

Permalink
Migrate "androidTest" JS from Haste to path-based requires (#24813)
Browse files Browse the repository at this point in the history
Summary:
The files in `ReactAndroid/src/androidTest/js` use Haste names; this commit migrates them to use path-based imports. This helps us move RN towards standard path-based requires. All the requires in `androidTest` have been rewritten to use relative requires.

[General] [Changed] - Migrate "androidTest" JS from Haste to path-based requires
Pull Request resolved: #24813

Differential Revision: D15318108

Pulled By: cpojer

fbshipit-source-id: dddc68f992b8dea48afb01fd4481bd5b846231ca
  • Loading branch information
ide authored and facebook-github-bot committed May 14, 2019
1 parent 916186a commit cd9adda
Show file tree
Hide file tree
Showing 29 changed files with 216 additions and 199 deletions.
26 changes: 15 additions & 11 deletions ReactAndroid/src/androidTest/js/AnimatedTransformTestModule.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule AnimatedTransformTestModule
* @format
*/

'use strict';

var BatchedBridge = require('BatchedBridge');
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
var TouchableOpacity = require('TouchableOpacity');
var Text = require('Text');
var RecordingModule = require('NativeModules').Recording;
const React = require('react');
const {
NativeModules,
StyleSheet,
Text,
TouchableOpacity,
View,
} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const {Recording: RecordingModule} = NativeModules;

const styles = StyleSheet.create({
base: {
Expand Down Expand Up @@ -62,7 +66,7 @@ class AnimatedTransformTestApp extends React.Component {
onPress={this.toggle}
testID="TouchableOpacity"
style={[styles.base, this.state.flag ? styles.transformed : null]}>
<Text>TouchableOpacity</Text>
<Text>TouchableOpacity</Text>
</TouchableOpacity>
</View>
);
Expand All @@ -75,7 +79,7 @@ var AnimatedTransformTestModule = {

BatchedBridge.registerCallableModule(
'AnimatedTransformTestModule',
AnimatedTransformTestModule
AnimatedTransformTestModule,
);

module.exports = AnimatedTransformTestModule;
4 changes: 3 additions & 1 deletion ReactAndroid/src/androidTest/js/Asserts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

'use strict';

const Assert = require('NativeModules').Assert;
const {NativeModules} = require('react-native');

const {Assert} = NativeModules;

const Asserts = {
assertEquals: function(expected, actual, msg) {
Expand Down
10 changes: 5 additions & 5 deletions ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const Recording = require('NativeModules').Recording;
const StyleSheet = require('StyleSheet');
const View = require('View');
const React = require('react');
const {NativeModules, StyleSheet, View} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const {Recording} = NativeModules;

let that;

Expand Down
11 changes: 5 additions & 6 deletions ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const DatePickerAndroid = require('DatePickerAndroid');
const React = require('React');
const RecordingModule = require('NativeModules')
.DatePickerDialogRecordingModule;
const View = require('View');
const React = require('react');
const {DatePickerAndroid, NativeModules, View} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const {DatePickerDialogRecordingModule: RecordingModule} = NativeModules;

class DatePickerDialogTestApp extends React.Component {
render() {
Expand Down
8 changes: 3 additions & 5 deletions ReactAndroid/src/androidTest/js/ImageErrorTestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

'use strict';

const React = require('React');
const Image = require('Image');
const StyleSheet = require('StyleSheet');
const View = require('View');
const React = require('react');
const {Image, NativeModules, StyleSheet, View} = require('react-native');

const RecordingModule = require('NativeModules').Recording;
const {Recording: RecordingModule} = NativeModules;

class ImageErrorTestApp extends React.Component {
onError = e => {
Expand Down
4 changes: 2 additions & 2 deletions ReactAndroid/src/androidTest/js/ImageOverlayColorTestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

'use strict';

const React = require('React');
const Image = require('Image');
const React = require('react');
const {Image} = require('react-native');

class ImageOverlayColorTestApp extends React.Component {
render() {
Expand Down
7 changes: 3 additions & 4 deletions ReactAndroid/src/androidTest/js/InitialPropsTestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@

'use strict';

const React = require('React');
const RecordingModule = require('NativeModules').InitialPropsRecordingModule;
const Text = require('Text');
const React = require('react');
const {NativeModules, Text} = require('react-native');

class InitialPropsTestApp extends React.Component {
componentDidMount() {
RecordingModule.recordProps(this.props);
NativeModules.InitialPropsRecordingModule.recordProps(this.props);
}

render() {
Expand Down
14 changes: 8 additions & 6 deletions ReactAndroid/src/androidTest/js/JSResponderTestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

'use strict';

const React = require('React');
const StyleSheet = require('StyleSheet');
const View = require('View');
const Text = require('Text');
const PanResponder = require('PanResponder');
const ScrollView = require('ScrollView');
const React = require('react');
const {
PanResponder,
ScrollView,
StyleSheet,
Text,
View,
} = require('react-native');

class JSResponderTestApp extends React.Component {
_handleMoveShouldSetPanResponder = (e, gestureState) => {
Expand Down
7 changes: 3 additions & 4 deletions ReactAndroid/src/androidTest/js/LayoutEventsTestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

'use strict';

const React = require('React');
const View = require('View');
const StyleSheet = require('StyleSheet');
const React = require('react');
const {NativeModules, StyleSheet, View} = require('react-native');

const RecordingModule = require('NativeModules').Recording;
const {Recording: RecordingModule} = NativeModules;

const LAYOUT_SPECS = [
[10, 10, 100, 100],
Expand Down
19 changes: 8 additions & 11 deletions ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const ReactNative = require('ReactNative');
const View = require('View');
const StyleSheet = require('StyleSheet');
const UIManager = require('UIManager');
const React = require('react');
const {StyleSheet, UIManager, View, findNodeHandle} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const assertEquals = require('Asserts').assertEquals;
const assertEquals = require('./Asserts').assertEquals;

const styles = StyleSheet.create({
A: {
Expand Down Expand Up @@ -50,10 +47,10 @@ let A, B, C, D;

class MeasureLayoutTestApp extends React.Component {
componentDidMount() {
A = ReactNative.findNodeHandle(this.refs.A);
B = ReactNative.findNodeHandle(this.refs.B);
C = ReactNative.findNodeHandle(this.refs.C);
D = ReactNative.findNodeHandle(this.refs.D);
A = findNodeHandle(this.refs.A);
B = findNodeHandle(this.refs.B);
C = findNodeHandle(this.refs.C);
D = findNodeHandle(this.refs.D);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

'use strict';

const React = require('React');
const Recording = require('NativeModules').Recording;
const StyleSheet = require('StyleSheet');
const View = require('View');
const React = require('react');
const {NativeModules, StyleSheet, View} = require('react-native');

const {Recording} = NativeModules;

const extractSingleTouch = nativeEvent => {
const touches = nativeEvent.touches;
Expand Down
22 changes: 12 additions & 10 deletions ReactAndroid/src/androidTest/js/NativeIdTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@

'use strict';

const Image = require('Image');
const React = require('React');
const StyleSheet = require('StyleSheet');
const Text = require('Text');
const TextInput = require('TextInput');
const TouchableBounce = require('TouchableBounce');
const TouchableHighlight = require('TouchableHighlight');
const TouchableOpacity = require('TouchableOpacity');
const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
const View = require('View');
const React = require('react');
const {
Image,
StyleSheet,
Text,
TextInput,
TouchableHighlight,
TouchableOpacity,
TouchableWithoutFeedback,
View,
} = require('react-native');
const TouchableBounce = require('react-native/Libraries/Components/Touchable/TouchableBounce');

/**
* All the views implemented on Android, each with the nativeID property set.
Expand Down
9 changes: 4 additions & 5 deletions ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const RecordingModule = require('NativeModules').PickerAndroidRecordingModule;
const Picker = require('Picker');
const View = require('View');
const React = require('react');
const {NativeModules, Picker, View} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const {Recording: RecordingModule} = NativeModules;
const Item = Picker.Item;

let appInstance;
Expand Down
16 changes: 8 additions & 8 deletions ReactAndroid/src/androidTest/js/ProgressBarTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const ReactNative = require('react-native');
const {StyleSheet} = ReactNative;
const ProgressBar = require('ProgressBarAndroid');
const View = require('View');

const renderApplication = require('renderApplication');
const React = require('react');
const {
ProgressBarAndroid: ProgressBar,
StyleSheet,
View,
} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');
const renderApplication = require('react-native/Libraries/ReactNative/renderApplication');

class ProgressBarSampleApp extends React.Component {
state = {};
Expand Down
20 changes: 12 additions & 8 deletions ReactAndroid/src/androidTest/js/ScrollViewTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const View = require('View');
const ScrollView = require('ScrollView');
const Text = require('Text');
const StyleSheet = require('StyleSheet');
const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
const ScrollListener = require('NativeModules').ScrollListener;
const React = require('react');
const {
NativeModules,
ScrollView,
StyleSheet,
Text,
TouchableWithoutFeedback,
View,
} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const {ScrollListener} = NativeModules;

const NUM_ITEMS = 100;

Expand Down
10 changes: 5 additions & 5 deletions ReactAndroid/src/androidTest/js/ShareTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const RecordingModule = require('NativeModules').ShareRecordingModule;
const Share = require('Share');
const View = require('View');
const React = require('react');
const {NativeModules, Share, View} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const {ShareRecordingModule: RecordingModule} = NativeModules;

class ShareTestApp extends React.Component {
render() {
Expand Down
15 changes: 8 additions & 7 deletions ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const ScrollView = require('ScrollView');
const StyleSheet = require('StyleSheet');
const View = require('View');

const requireNativeComponent = require('requireNativeComponent');
const React = require('react');
const {
ScrollView,
StyleSheet,
View,
requireNativeComponent,
} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const ClippableView = requireNativeComponent('ClippableView');

Expand Down
23 changes: 13 additions & 10 deletions ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@

'use strict';

const BatchedBridge = require('BatchedBridge');
const React = require('React');
const RecordingModule = require('NativeModules')
.SwipeRefreshLayoutRecordingModule;
const ScrollView = require('ScrollView');
const StyleSheet = require('StyleSheet');
const RefreshControl = require('RefreshControl');
const Text = require('Text');
const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
const View = require('View');
const React = require('react');
const {
NativeModules,
RefreshControl,
ScrollView,
StyleSheet,
Text,
TouchableWithoutFeedback,
View,
} = require('react-native');
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');

const {SwipeRefreshLayoutRecordingModule: RecordingModule} = NativeModules;

class Row extends React.Component {
state = {
Expand Down
Loading

0 comments on commit cd9adda

Please sign in to comment.