Prettier the rest of ReactNative

Reviewed By: yungsters

Differential Revision: D7974340

fbshipit-source-id: 5fe457a8a9be4bd360fc3af9acb5c1136b2be0d7
This commit is contained in:
Eli White
2018-05-11 13:52:30 -07:00
committed by Facebook Github Bot
parent aba4ec0c09
commit 36fcbaa56d
170 changed files with 5132 additions and 3995 deletions
+9 -2
View File
@@ -4,6 +4,7 @@
* 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';
@@ -15,8 +16,14 @@ var Asserts = {
if (expected !== actual) {
Assert.fail(
msg ||
'Expected: ' + expected + ', received: ' + actual + '\n' +
'at ' + (new Error()).stack);
'Expected: ' +
expected +
', received: ' +
actual +
'\n' +
'at ' +
new Error().stack,
);
} else {
Assert.success();
}
@@ -4,6 +4,7 @@
* 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';
@@ -4,6 +4,7 @@
* 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';
@@ -16,7 +17,7 @@ var View = require('View');
class DatePickerDialogTestApp extends React.Component {
render() {
return (<View />);
return <View />;
}
}
@@ -31,14 +32,14 @@ var DatePickerDialogTestModule = {
RecordingModule.recordDismissed();
}
},
({code, message}) => RecordingModule.recordError()
({code, message}) => RecordingModule.recordError(),
);
},
};
BatchedBridge.registerCallableModule(
'DatePickerDialogTestModule',
DatePickerDialogTestModule
DatePickerDialogTestModule,
);
module.exports = DatePickerDialogTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -4,7 +4,9 @@
* 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';
var React = require('React');
@@ -56,7 +58,7 @@ var styles = StyleSheet.create({
},
row: {
height: 30,
}
},
});
module.exports = JSResponderTestApp;
@@ -4,6 +4,7 @@
* 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';
@@ -14,14 +15,13 @@ var View = require('View');
var RecordingModule = require('NativeModules').Recording;
const LAYOUT_SPECS = [
[10, 10, 100, 100],
[10, 10, 50, 50],
[0, 0, 50, 50],
[0, 0, 50, 50],
[10, 10, 100, 100],
[10, 10, 50, 50],
[0, 0, 50, 50],
[0, 0, 50, 50],
];
class LayoutEventsTestApp extends React.Component {
constructor() {
super();
this.state = {
@@ -30,9 +30,11 @@ class LayoutEventsTestApp extends React.Component {
this.numParentLayouts = 0;
}
handleOnLayout = (e) => {
handleOnLayout = e => {
var layout = e.nativeEvent.layout;
RecordingModule.record(layout.x + ',' + layout.y + '-' + layout.width + 'x' + layout.height);
RecordingModule.record(
layout.x + ',' + layout.y + '-' + layout.width + 'x' + layout.height,
);
if (this.state.specNumber >= LAYOUT_SPECS.length) {
// This will cause the test to fail
@@ -44,7 +46,7 @@ class LayoutEventsTestApp extends React.Component {
}
};
handleParentOnLayout = (e) => {
handleParentOnLayout = e => {
if (this.numParentLayouts > 0) {
// This will cause the test to fail - the parent's layout doesn't change
// so we should only get the event once.
@@ -57,13 +59,19 @@ class LayoutEventsTestApp extends React.Component {
const layout = LAYOUT_SPECS[this.state.specNumber];
return (
<View
onLayout={this.handleParentOnLayout}
testID="parent"
style={{left: 0, top: 0, width: 500, height: 500}}>
onLayout={this.handleParentOnLayout}
testID="parent"
style={{left: 0, top: 0, width: 500, height: 500}}>
<View
onLayout={this.handleOnLayout}
testID="container"
style={{left: layout[0], top: layout[1], width: layout[2], height: layout[3]}}/>
onLayout={this.handleOnLayout}
testID="container"
style={{
left: layout[0],
top: layout[1],
width: layout[2],
height: layout[3],
}}
/>
</View>
);
}
@@ -4,6 +4,7 @@
* 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';
@@ -19,29 +20,29 @@ var assertEquals = require('Asserts').assertEquals;
var styles = StyleSheet.create({
A: {
'width': 500,
'height': 500,
width: 500,
height: 500,
},
B: {
backgroundColor: 'rgb(255, 0, 0)',
'left': 50,
'top': 80,
'width': 200,
'height': 300,
left: 50,
top: 80,
width: 200,
height: 300,
},
C: {
backgroundColor: 'rgb(0, 255, 0)',
'left': 100,
'top': 70,
'width': 50,
'height': 150,
left: 100,
top: 70,
width: 50,
height: 150,
},
D: {
backgroundColor: 'rgb(0, 0, 255)',
'left': 400,
'top': 100,
'width': 50,
'height': 200,
left: 400,
top: 100,
width: 50,
height: 200,
},
});
@@ -90,114 +91,124 @@ var MeasureLayoutTestModule = {
});
},
verifyMeasureLayoutCRelativeToA: function() {
UIManager.measureLayout(
C,
A,
shouldNotCallThisCallback,
function (x, y, width, height) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(150, x);
assertEquals(150, y);
});
UIManager.measureLayout(C, A, shouldNotCallThisCallback, function(
x,
y,
width,
height,
) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(150, x);
assertEquals(150, y);
});
},
verifyMeasureLayoutCRelativeToB: function() {
UIManager.measureLayout(
C,
B,
shouldNotCallThisCallback,
function (x, y, width, height) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(100, x);
assertEquals(70, y);
});
UIManager.measureLayout(C, B, shouldNotCallThisCallback, function(
x,
y,
width,
height,
) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(100, x);
assertEquals(70, y);
});
},
verifyMeasureLayoutCRelativeToSelf: function() {
UIManager.measureLayout(
C,
C,
shouldNotCallThisCallback,
function (x, y, width, height) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(0, x);
assertEquals(0, y);
});
UIManager.measureLayout(C, C, shouldNotCallThisCallback, function(
x,
y,
width,
height,
) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(0, x);
assertEquals(0, y);
});
},
verifyMeasureLayoutRelativeToParentOnViewA: function() {
UIManager.measureLayoutRelativeToParent(
A,
shouldNotCallThisCallback,
function (x, y, width, height) {
function(x, y, width, height) {
assertEquals(500, width);
assertEquals(500, height);
assertEquals(0, x);
assertEquals(0, y);
});
},
);
},
verifyMeasureLayoutRelativeToParentOnViewB: function() {
UIManager.measureLayoutRelativeToParent(
B,
shouldNotCallThisCallback,
function (x, y, width, height) {
function(x, y, width, height) {
assertEquals(200, width);
assertEquals(300, height);
assertEquals(50, x);
assertEquals(80, y);
});
},
);
},
verifyMeasureLayoutRelativeToParentOnViewC: function() {
UIManager.measureLayoutRelativeToParent(
C,
shouldNotCallThisCallback,
function (x, y, width, height) {
function(x, y, width, height) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(100, x);
assertEquals(70, y);
});
},
);
},
verifyMeasureLayoutDRelativeToB: function() {
UIManager.measureLayout(
D,
B,
function () {
function() {
assertEquals(true, true);
},
shouldNotCallThisCallback);
shouldNotCallThisCallback,
);
},
verifyMeasureLayoutNonExistentTag: function() {
UIManager.measureLayout(
192,
A,
function () {
function() {
assertEquals(true, true);
},
shouldNotCallThisCallback);
shouldNotCallThisCallback,
);
},
verifyMeasureLayoutNonExistentAncestor: function() {
UIManager.measureLayout(
B,
192,
function () {
function() {
assertEquals(true, true);
},
shouldNotCallThisCallback);
shouldNotCallThisCallback,
);
},
verifyMeasureLayoutRelativeToParentNonExistentTag: function() {
UIManager.measureLayoutRelativeToParent(
192,
function () {
function() {
assertEquals(true, true);
},
shouldNotCallThisCallback);
shouldNotCallThisCallback,
);
},
};
BatchedBridge.registerCallableModule(
'MeasureLayoutTestModule',
MeasureLayoutTestModule
MeasureLayoutTestModule,
);
module.exports = MeasureLayoutTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -15,16 +16,16 @@ var TouchEventUtils = require('fbjs/lib/TouchEventUtils');
var View = require('View');
class TouchTestApp extends React.Component {
handleStartShouldSetResponder = (e) => {
handleStartShouldSetResponder = e => {
return true;
};
handleOnResponderMove = (e) => {
handleOnResponderMove = e => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
Recording.record('move;' + e.touches.length);
};
handleResponderStart = (e) => {
handleResponderStart = e => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('start;' + e.touches.length);
@@ -33,7 +34,7 @@ class TouchTestApp extends React.Component {
}
};
handleResponderEnd = (e) => {
handleResponderEnd = e => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('end;' + e.touches.length);
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
@@ -28,18 +29,16 @@ const View = require('View');
*/
class NativeIdTestApp extends React.Component<{}> {
render() {
const uri = 'data:image/gif;base64,' +
'R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapy' +
'uvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/' +
'TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5' +
'iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97V' +
'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7';
const uri =
'data:image/gif;base64,' +
'R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapy' +
'uvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/' +
'TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5' +
'iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97V' +
'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7';
return (
<View>
<Image
nativeID="Image"
source={{uri: uri}}
style={styles.base} />
<Image nativeID="Image" source={{uri: uri}} style={styles.base} />
<Text nativeID="Text">text</Text>
<TextInput nativeID="TextInput" value="Text input" />
<TouchableBounce nativeID="TouchableBounce">
@@ -4,6 +4,7 @@
* 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';
@@ -62,7 +63,7 @@ class PickerAndroidTestApp extends React.Component {
);
}
onValueChange = (value) => {
onValueChange = value => {
this.setState({selected: value});
RecordingModule.recordSelection(value);
};
@@ -83,7 +84,7 @@ var PickerAndroidTestModule = {
BatchedBridge.registerCallableModule(
'PickerAndroidTestModule',
PickerAndroidTestModule
PickerAndroidTestModule,
);
module.exports = PickerAndroidTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -21,14 +22,14 @@ class ProgressBarSampleApp extends React.Component {
render() {
return (
<View>
<ProgressBar styleAttr="Horizontal" testID="Horizontal"/>
<ProgressBar styleAttr="Small" testID="Small"/>
<ProgressBar styleAttr="Large" testID="Large"/>
<ProgressBar styleAttr="Normal" testID="Normal"/>
<ProgressBar styleAttr="Inverse" testID="Inverse"/>
<ProgressBar styleAttr="SmallInverse" testID="SmallInverse"/>
<ProgressBar styleAttr="LargeInverse" testID="LargeInverse"/>
<View style={{width:200}}>
<ProgressBar styleAttr="Horizontal" testID="Horizontal" />
<ProgressBar styleAttr="Small" testID="Small" />
<ProgressBar styleAttr="Large" testID="Large" />
<ProgressBar styleAttr="Normal" testID="Normal" />
<ProgressBar styleAttr="Inverse" testID="Inverse" />
<ProgressBar styleAttr="SmallInverse" testID="SmallInverse" />
<ProgressBar styleAttr="LargeInverse" testID="LargeInverse" />
<View style={{width: 200}}>
<ProgressBar styleAttr="Horizontal" testID="Horizontal200" />
</View>
</View>
@@ -44,7 +45,7 @@ var ProgressBarTestModule = {
BatchedBridge.registerCallableModule(
'ProgressBarTestModule',
ProgressBarTestModule
ProgressBarTestModule,
);
module.exports = ProgressBarTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -47,15 +48,24 @@ var getInitialState = function() {
};
var onScroll = function(e) {
ScrollListener.onScroll(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
ScrollListener.onScroll(
e.nativeEvent.contentOffset.x,
e.nativeEvent.contentOffset.y,
);
};
var onScrollBeginDrag = function(e) {
ScrollListener.onScrollBeginDrag(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
ScrollListener.onScrollBeginDrag(
e.nativeEvent.contentOffset.x,
e.nativeEvent.contentOffset.y,
);
};
var onScrollEndDrag = function(e) {
ScrollListener.onScrollEndDrag(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
ScrollListener.onScrollEndDrag(
e.nativeEvent.contentOffset.x,
e.nativeEvent.contentOffset.y,
);
};
var onItemPress = function(itemNumber) {
@@ -78,11 +88,17 @@ var ScrollViewTestApp = createReactClass({
scrollViewApp = this;
var children = this.state.data.map((item, index) => (
<Item
key={index} text={item.text}
onPress={this.onItemPress.bind(this, index)} />
key={index}
text={item.text}
onPress={this.onItemPress.bind(this, index)}
/>
));
return (
<ScrollView onScroll={this.onScroll} onScrollBeginDrag={this.onScrollBeginDrag} onScrollEndDrag={this.onScrollEndDrag} ref="scrollView">
<ScrollView
onScroll={this.onScroll}
onScrollBeginDrag={this.onScrollBeginDrag}
onScrollEndDrag={this.onScrollEndDrag}
ref="scrollView">
{children}
</ScrollView>
);
@@ -103,8 +119,10 @@ var HorizontalScrollViewTestApp = createReactClass({
scrollViewApp = this;
var children = this.state.data.map((item, index) => (
<Item
key={index} text={item.text}
onPress={this.onItemPress.bind(this, index)} />
key={index}
text={item.text}
onPress={this.onItemPress.bind(this, index)}
/>
));
return (
<ScrollView horizontal={true} onScroll={this.onScroll} ref="scrollView">
@@ -136,7 +154,7 @@ var ScrollViewTestModule = {
BatchedBridge.registerCallableModule(
'ScrollViewTestModule',
ScrollViewTestModule
ScrollViewTestModule,
);
module.exports = ScrollViewTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -16,7 +17,7 @@ var View = require('View');
class ShareTestApp extends React.Component {
render() {
return (<View />);
return <View />;
}
}
@@ -25,14 +26,11 @@ var ShareTestModule = {
showShareDialog: function(content, options) {
Share.share(content, options).then(
() => RecordingModule.recordOpened(),
({code, message}) => RecordingModule.recordError()
({code, message}) => RecordingModule.recordError(),
);
},
};
BatchedBridge.registerCallableModule(
'ShareTestModule',
ShareTestModule
);
BatchedBridge.registerCallableModule('ShareTestModule', ShareTestModule);
module.exports = ShareTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -24,12 +25,30 @@ class ClippingSample1 extends React.Component {
var styles = sample1Styles;
return (
<View>
<ClippableView clippableViewID="outer" style={styles.outer} removeClippedSubviews={true}>
<ClippableView clippableViewID="inner1" style={[styles.inner, styles.inner1]}/>
<ClippableView clippableViewID="inner2" style={[styles.inner, styles.inner2]}/>
<ClippableView clippableViewID="inner3" style={[styles.inner, styles.inner3]}/>
<ClippableView clippableViewID="inner4" style={[styles.inner, styles.inner4]}/>
<ClippableView clippableViewID="inner5" style={[styles.inner, styles.inner5]}/>
<ClippableView
clippableViewID="outer"
style={styles.outer}
removeClippedSubviews={true}>
<ClippableView
clippableViewID="inner1"
style={[styles.inner, styles.inner1]}
/>
<ClippableView
clippableViewID="inner2"
style={[styles.inner, styles.inner2]}
/>
<ClippableView
clippableViewID="inner3"
style={[styles.inner, styles.inner3]}
/>
<ClippableView
clippableViewID="inner4"
style={[styles.inner, styles.inner4]}
/>
<ClippableView
clippableViewID="inner5"
style={[styles.inner, styles.inner5]}
/>
</ClippableView>
</View>
);
@@ -75,15 +94,30 @@ class ClippingSample2 extends React.Component {
var styles = sample2Styles;
return (
<View>
<ClippableView clippableViewID="outer" style={styles.outer} removeClippedSubviews={true}>
<ClippableView
clippableViewID="outer"
style={styles.outer}
removeClippedSubviews={true}>
<ClippableView
clippableViewID="complexInner"
style={styles.complexInner}
removeClippedSubviews={true}>
<ClippableView clippableViewID="inner1" style={[styles.inner, styles.inner1]}/>
<ClippableView clippableViewID="inner2" style={[styles.inner, styles.inner2]}/>
<ClippableView clippableViewID="inner3" style={[styles.inner, styles.inner3]}/>
<ClippableView clippableViewID="inner4" style={[styles.inner, styles.inner4]}/>
clippableViewID="complexInner"
style={styles.complexInner}
removeClippedSubviews={true}>
<ClippableView
clippableViewID="inner1"
style={[styles.inner, styles.inner1]}
/>
<ClippableView
clippableViewID="inner2"
style={[styles.inner, styles.inner2]}
/>
<ClippableView
clippableViewID="inner3"
style={[styles.inner, styles.inner3]}
/>
<ClippableView
clippableViewID="inner4"
style={[styles.inner, styles.inner4]}
/>
</ClippableView>
</ClippableView>
</View>
@@ -132,13 +166,19 @@ var sample2Styles = StyleSheet.create({
class UpdatingSample1 extends React.Component {
render() {
var styles = updating1Styles;
var inner1Styles = [styles.inner1, {height: this.props.update1 ? 200 : 100}];
var inner1Styles = [
styles.inner1,
{height: this.props.update1 ? 200 : 100},
];
var inner2Styles = [styles.inner2, {top: this.props.update2 ? 200 : 50}];
return (
<View>
<ClippableView clippableViewID="outer" style={styles.outer} removeClippedSubviews={true}>
<ClippableView clippableViewID="inner1" style={inner1Styles}/>
<ClippableView clippableViewID="inner2" style={inner2Styles}/>
<ClippableView
clippableViewID="outer"
style={styles.outer}
removeClippedSubviews={true}>
<ClippableView clippableViewID="inner1" style={inner1Styles} />
<ClippableView clippableViewID="inner2" style={inner2Styles} />
</ClippableView>
</View>
);
@@ -166,7 +206,7 @@ var updating1Styles = StyleSheet.create({
left: 50,
top: 50,
backgroundColor: 'green',
}
},
});
class UpdatingSample2 extends React.Component {
@@ -175,8 +215,11 @@ class UpdatingSample2 extends React.Component {
var outerStyles = [styles.outer, {height: this.props.update ? 200 : 100}];
return (
<View>
<ClippableView clippableViewID="outer" style={outerStyles} removeClippedSubviews={true}>
<ClippableView clippableViewID="inner" style={styles.inner}/>
<ClippableView
clippableViewID="outer"
style={outerStyles}
removeClippedSubviews={true}>
<ClippableView clippableViewID="inner" style={styles.inner} />
</ClippableView>
</View>
);
@@ -204,25 +247,28 @@ class ScrollViewTest extends React.Component {
var children = [];
for (var i = 0; i < 4; i++) {
children[i] = (
<ClippableView key={i} style={styles.row} clippableViewID={'' + i}/>
<ClippableView key={i} style={styles.row} clippableViewID={'' + i} />
);
}
for (var i = 4; i < 6; i++) {
var viewID = 'C' + (i - 4);
children[i] = (
<ClippableView
key={i}
style={styles.complex}
clippableViewID={viewID}
removeClippedSubviews={true}>
<ClippableView style={styles.inner} clippableViewID={viewID + '.1'}/>
<ClippableView style={styles.inner} clippableViewID={viewID + '.2'}/>
key={i}
style={styles.complex}
clippableViewID={viewID}
removeClippedSubviews={true}>
<ClippableView style={styles.inner} clippableViewID={viewID + '.1'} />
<ClippableView style={styles.inner} clippableViewID={viewID + '.2'} />
</ClippableView>
);
}
return (
<ScrollView removeClippedSubviews={true} style={styles.scrollView} testID="scroll_view">
<ScrollView
removeClippedSubviews={true}
style={styles.scrollView}
testID="scroll_view">
{children}
</ScrollView>
);
@@ -258,7 +304,6 @@ var scrollTestStyles = StyleSheet.create({
},
});
var appInstance = null;
class SubviewsClippingTestApp extends React.Component {
@@ -268,42 +313,40 @@ class SubviewsClippingTestApp extends React.Component {
appInstance = this;
}
setComponent = (component) => {
setComponent = component => {
this.setState({component: component});
};
render() {
var component = this.state.component;
return (
<View>
{component}
</View>
);
return <View>{component}</View>;
}
}
var SubviewsClippingTestModule = {
App: SubviewsClippingTestApp,
renderClippingSample1: function() {
appInstance.setComponent(<ClippingSample1/>);
appInstance.setComponent(<ClippingSample1 />);
},
renderClippingSample2: function() {
appInstance.setComponent(<ClippingSample2/>);
appInstance.setComponent(<ClippingSample2 />);
},
renderUpdatingSample1: function(update1, update2) {
appInstance.setComponent(<UpdatingSample1 update1={update1} update2={update2}/>);
appInstance.setComponent(
<UpdatingSample1 update1={update1} update2={update2} />,
);
},
renderUpdatingSample2: function(update) {
appInstance.setComponent(<UpdatingSample2 update={update}/>);
appInstance.setComponent(<UpdatingSample2 update={update} />);
},
renderScrollViewTest: function() {
appInstance.setComponent(<ScrollViewTest/>);
appInstance.setComponent(<ScrollViewTest />);
},
};
BatchedBridge.registerCallableModule(
'SubviewsClippingTestModule',
SubviewsClippingTestModule
SubviewsClippingTestModule,
);
module.exports = SubviewsClippingTestModule;
@@ -4,13 +4,15 @@
* 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';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var RecordingModule = require('NativeModules').SwipeRefreshLayoutRecordingModule;
var RecordingModule = require('NativeModules')
.SwipeRefreshLayoutRecordingModule;
var ScrollView = require('ScrollView');
var RefreshControl = require('RefreshControl');
var Text = require('Text');
@@ -26,9 +28,7 @@ class Row extends React.Component {
return (
<TouchableWithoutFeedback onPress={this._onPress}>
<View>
<Text>
{this.state.clicks + ' clicks'}
</Text>
<Text>{this.state.clicks + ' clicks'}</Text>
</View>
</TouchableWithoutFeedback>
);
@@ -77,12 +77,12 @@ var SwipeRefreshLayoutTestModule = {
if (app != null) {
app.setState({rows});
}
}
},
};
BatchedBridge.registerCallableModule(
'SwipeRefreshLayoutTestModule',
SwipeRefreshLayoutTestModule
SwipeRefreshLayoutTestModule,
);
module.exports = SwipeRefreshLayoutTestModule;
+79 -75
View File
@@ -4,7 +4,9 @@
* 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';
// Disable YellowBox so we do not have to mock its dependencies
@@ -29,86 +31,88 @@ require('SwipeRefreshLayoutTestModule');
require('TextInputTestModule');
require('TimePickerDialogTestModule');
// Define catalyst test apps used in integration tests
var AppRegistry = require('AppRegistry');
var apps = [
{
appKey: 'CatalystRootViewTestApp',
component: () => require('CatalystRootViewTestModule').CatalystRootViewTestApp
},
{
appKey: 'DatePickerDialogTestApp',
component: () => require('DatePickerDialogTestModule').DatePickerDialogTestApp
},
{
appKey: 'JSResponderTestApp',
component: () => require('JSResponderTestApp'),
},
{
appKey: 'HorizontalScrollViewTestApp',
component: () => require('ScrollViewTestModule').HorizontalScrollViewTestApp,
},
{
appKey: 'InitialPropsTestApp',
component: () => require('InitialPropsTestApp'),
},
{
appKey: 'LayoutEventsTestApp',
component: () => require('LayoutEventsTestApp'),
},
{
appKey: 'MeasureLayoutTestApp',
component: () => require('MeasureLayoutTestModule').MeasureLayoutTestApp
},
{
appKey: 'MultitouchHandlingTestAppModule',
component: () => require('MultitouchHandlingTestAppModule')
},
{
appKey: 'NativeIdTestApp',
component: () => require('NativeIdTestModule').NativeIdTestApp
},
{
appKey: 'PickerAndroidTestApp',
component: () => require('PickerAndroidTestModule').PickerAndroidTestApp,
},
{
appKey: 'ScrollViewTestApp',
component: () => require('ScrollViewTestModule').ScrollViewTestApp,
},
{
appKey: 'ShareTestApp',
component: () => require('ShareTestModule').ShareTestApp,
},
{
appKey: 'SubviewsClippingTestApp',
component: () => require('SubviewsClippingTestModule').App,
},
{
appKey: 'SwipeRefreshLayoutTestApp',
component: () => require('SwipeRefreshLayoutTestModule').SwipeRefreshLayoutTestApp
},
{
appKey: 'TextInputTestApp',
component: () => require('TextInputTestModule').TextInputTestApp
},
{
appKey: 'TestIdTestApp',
component: () => require('TestIdTestModule').TestIdTestApp
},
{
appKey: 'TimePickerDialogTestApp',
component: () => require('TimePickerDialogTestModule').TimePickerDialogTestApp
},
{
appKey: 'TouchBubblingTestAppModule',
component: () => require('TouchBubblingTestAppModule')
},
{
appKey: 'CatalystRootViewTestApp',
component: () =>
require('CatalystRootViewTestModule').CatalystRootViewTestApp,
},
{
appKey: 'DatePickerDialogTestApp',
component: () =>
require('DatePickerDialogTestModule').DatePickerDialogTestApp,
},
{
appKey: 'JSResponderTestApp',
component: () => require('JSResponderTestApp'),
},
{
appKey: 'HorizontalScrollViewTestApp',
component: () =>
require('ScrollViewTestModule').HorizontalScrollViewTestApp,
},
{
appKey: 'InitialPropsTestApp',
component: () => require('InitialPropsTestApp'),
},
{
appKey: 'LayoutEventsTestApp',
component: () => require('LayoutEventsTestApp'),
},
{
appKey: 'MeasureLayoutTestApp',
component: () => require('MeasureLayoutTestModule').MeasureLayoutTestApp,
},
{
appKey: 'MultitouchHandlingTestAppModule',
component: () => require('MultitouchHandlingTestAppModule'),
},
{
appKey: 'NativeIdTestApp',
component: () => require('NativeIdTestModule').NativeIdTestApp,
},
{
appKey: 'PickerAndroidTestApp',
component: () => require('PickerAndroidTestModule').PickerAndroidTestApp,
},
{
appKey: 'ScrollViewTestApp',
component: () => require('ScrollViewTestModule').ScrollViewTestApp,
},
{
appKey: 'ShareTestApp',
component: () => require('ShareTestModule').ShareTestApp,
},
{
appKey: 'SubviewsClippingTestApp',
component: () => require('SubviewsClippingTestModule').App,
},
{
appKey: 'SwipeRefreshLayoutTestApp',
component: () =>
require('SwipeRefreshLayoutTestModule').SwipeRefreshLayoutTestApp,
},
{
appKey: 'TextInputTestApp',
component: () => require('TextInputTestModule').TextInputTestApp,
},
{
appKey: 'TestIdTestApp',
component: () => require('TestIdTestModule').TestIdTestApp,
},
{
appKey: 'TimePickerDialogTestApp',
component: () =>
require('TimePickerDialogTestModule').TimePickerDialogTestApp,
},
{
appKey: 'TouchBubblingTestAppModule',
component: () => require('TouchBubblingTestAppModule'),
},
];
module.exports = apps;
AppRegistry.registerConfig(apps);
@@ -4,6 +4,7 @@
* 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';
@@ -30,16 +31,19 @@ class TestIdTestApp extends React.Component {
render() {
return (
<View>
<Image
testID="Image"
source={{uri: 'data:image/gif;base64,' +
source={{
uri:
'data:image/gif;base64,' +
'R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapy' +
'uvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/' +
'TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5' +
'iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97V' +
'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7'}}
style={styles.base} />
'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7',
}}
style={styles.base}
/>
<Text testID="Text">text</Text>
@@ -64,7 +68,6 @@ class TestIdTestApp extends React.Component {
</TouchableWithoutFeedback>
<View testID="View" />
</View>
);
}
@@ -4,6 +4,7 @@
* 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';
@@ -20,9 +21,6 @@ var TestJSLocaleModule = {
},
};
BatchedBridge.registerCallableModule(
'TestJSLocaleModule',
TestJSLocaleModule
);
BatchedBridge.registerCallableModule('TestJSLocaleModule', TestJSLocaleModule);
module.exports = TestJSLocaleModule;
@@ -4,6 +4,7 @@
* 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';
@@ -49,9 +50,9 @@ var TestJSToJavaParametersModule = {
},
returnMapWithArrays: function() {
Recording.receiveMap({
'empty': [],
'ints': [43, 44],
'mixed': [77, 'string', ['another', 'array']],
empty: [],
ints: [43, 44],
mixed: [77, 'string', ['another', 'array']],
});
},
returnArrayWithStringDoubleIntMapArrayBooleanNull: function() {
@@ -65,7 +66,7 @@ var TestJSToJavaParametersModule = {
int: -55,
array: [],
boolean: true,
null: null
null: null,
});
},
returnArrayWithLargeInts: function() {
@@ -80,7 +81,7 @@ var TestJSToJavaParametersModule = {
b: 41,
c: 'string',
d: 'other string',
e: [1,'foo','bar'],
e: [1, 'foo', 'bar'],
f: null,
});
},
@@ -99,7 +100,8 @@ var TestJSToJavaParametersModule = {
'two-bytes': '\u00A2',
'three-bytes': '\u20AC',
'four-bytes': '\uD83D\uDE1C',
'mixed': '\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107'
mixed:
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
});
},
returnArrayWithMultibyteUTF8CharacterString: function() {
@@ -108,14 +110,14 @@ var TestJSToJavaParametersModule = {
'\u00A2',
'\u20AC',
'\uD83D\uDE1C',
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107'
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
]);
},
};
BatchedBridge.registerCallableModule(
'TestJSToJavaParametersModule',
TestJSToJavaParametersModule
TestJSToJavaParametersModule,
);
module.exports = TestJSToJavaParametersModule;
@@ -4,6 +4,7 @@
* 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';
@@ -24,9 +25,7 @@ function strictStringCompare(a, b) {
}
function assertStrictStringEquals(a, b) {
assertTrue(
strictStringCompare(a,b),
'Expected: ' + a + ', received: ' + b);
assertTrue(strictStringCompare(a, b), 'Expected: ' + a + ', received: ' + b);
}
var TestJavaToJSArgumentsModule = {
@@ -92,7 +91,8 @@ var TestJavaToJSArgumentsModule = {
assertStrictStringEquals('\uD83D\uDE1C', map['four-bytes']);
assertStrictStringEquals(
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
map.mixed);
map.mixed,
);
},
receiveArrayWithMultibyteUTF8CharacterString: function(array) {
assertTrue(true);
@@ -101,13 +101,14 @@ var TestJavaToJSArgumentsModule = {
assertStrictStringEquals('\uD83D\uDE1C', array[2]);
assertStrictStringEquals(
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
array[3]);
array[3],
);
},
};
BatchedBridge.registerCallableModule(
'TestJavaToJSArgumentsModule',
TestJavaToJSArgumentsModule
TestJavaToJSArgumentsModule,
);
module.exports = TestJavaToJSArgumentsModule;
@@ -4,6 +4,7 @@
* 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';
@@ -26,12 +27,12 @@ var TestJavaToJSReturnValuesModule = {
} catch (ex) {
assertTrue(ex.message.indexOf('Exception triggered') !== -1);
}
}
},
};
BatchedBridge.registerCallableModule(
'TestJavaToJSReturnValuesModule',
TestJavaToJSReturnValuesModule
TestJavaToJSReturnValuesModule,
);
module.exports = TestJavaToJSReturnValuesModule;
@@ -4,6 +4,7 @@
* 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';
@@ -25,13 +26,14 @@ class TokenizedTextExample extends React.Component {
this.state = {text: ''};
}
render() {
//define delimiter
let delimiter = /\s+/;
//split string
let _text = this.state.text;
let token, index, parts = [];
let token,
index,
parts = [];
while (_text) {
delimiter.lastIndex = 0;
token = delimiter.exec(_text);
@@ -50,9 +52,13 @@ class TokenizedTextExample extends React.Component {
parts.push(_text);
//highlight hashtags
parts = parts.map((text) => {
parts = parts.map(text => {
if (/^#/.test(text)) {
return <Text key={text} style={styles.hashtag}>{text}</Text>;
return (
<Text key={text} style={styles.hashtag}>
{text}
</Text>
);
} else {
return text;
}
@@ -65,7 +71,7 @@ class TokenizedTextExample extends React.Component {
testID="tokenizedInput"
multiline={true}
style={styles.multiline}
onChangeText={(text) => {
onChangeText={text => {
this.setState({text});
}}>
<Text>{parts}</Text>
@@ -80,7 +86,7 @@ class TextInputTestApp extends React.Component {
app = this;
}
handleOnSubmitEditing = (record) => {
handleOnSubmitEditing = record => {
Recording.record(record);
};
@@ -173,7 +179,7 @@ var TextInputTestModule = {
BatchedBridge.registerCallableModule(
'TextInputTestModule',
TextInputTestModule
TextInputTestModule,
);
module.exports = TextInputTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -31,14 +32,14 @@ var TimePickerDialogTestModule = {
RecordingModule.recordDismissed();
}
},
({code, message}) => RecordingModule.recordError()
({code, message}) => RecordingModule.recordError(),
);
},
};
BatchedBridge.registerCallableModule(
'TimePickerDialogTestModule',
TimePickerDialogTestModule
TimePickerDialogTestModule,
);
module.exports = TimePickerDialogTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -16,16 +17,20 @@ var View = require('View');
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
class TouchBubblingTestApp extends React.Component {
handlePress = (record) => {
handlePress = record => {
Recording.record(record);
};
render() {
return (
<View style={styles.container}>
<TouchableWithoutFeedback onPress={this.handlePress.bind(this, 'outer')} testID="D">
<TouchableWithoutFeedback
onPress={this.handlePress.bind(this, 'outer')}
testID="D">
<View style={styles.outer}>
<TouchableWithoutFeedback onPress={this.handlePress.bind(this, 'inner')} testID="B">
<TouchableWithoutFeedback
onPress={this.handlePress.bind(this, 'inner')}
testID="B">
<View style={styles.inner}>
<View style={styles.superinner} testID="A" />
</View>
@@ -33,7 +38,9 @@ class TouchBubblingTestApp extends React.Component {
<View style={styles.inner} testID="C" />
</View>
</TouchableWithoutFeedback>
<TouchableWithoutFeedback onPress={this.handlePress.bind(this, 'outsider')} testID="E">
<TouchableWithoutFeedback
onPress={this.handlePress.bind(this, 'outsider')}
testID="E">
<View style={styles.element} />
</TouchableWithoutFeedback>
</View>
@@ -68,7 +75,7 @@ var styles = StyleSheet.create({
backgroundColor: '#eeeeee',
height: 20,
width: 20,
}
},
});
module.exports = TouchBubblingTestApp;
@@ -4,6 +4,7 @@
* 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';
@@ -34,16 +35,25 @@ var FlexTestApp = createReactClass({
left: 10,
width: 50,
height: 60,
}
},
}),
render: function() {
return (
<View style={this._styles.container} testID="container" collapsable={false}>
<View style={[this._styles.child, {backgroundColor: '#ff0000'}]} collapsable={false}/>
<View style={[this._styles.child, {backgroundColor: '#0000ff'}]} collapsable={false}/>
<View
style={this._styles.container}
testID="container"
collapsable={false}>
<View
style={[this._styles.child, {backgroundColor: '#ff0000'}]}
collapsable={false}
/>
<View
style={[this._styles.child, {backgroundColor: '#0000ff'}]}
collapsable={false}
/>
</View>
);
}
},
});
var FlexWithText = createReactClass({
@@ -65,14 +75,17 @@ var FlexWithText = createReactClass({
}),
render: function() {
return (
<View style={this._styles.container} testID="container" collapsable={false}>
<View
style={this._styles.container}
testID="container"
collapsable={false}>
<View style={this._styles.row} collapsable={false}>
<Text style={this._styles.inner}>Hello</Text>
<Text style={this._styles.inner}>World</Text>
</View>
</View>
);
}
},
});
var AbsolutePositionTestApp = createReactClass({
@@ -84,11 +97,17 @@ var AbsolutePositionTestApp = createReactClass({
left: 10,
width: 50,
height: 60,
}
},
}),
render: function() {
return <View style={this._styles.absolute} testID="absolute" collapsable={false}/>;
}
return (
<View
style={this._styles.absolute}
testID="absolute"
collapsable={false}
/>
);
},
});
var AbsolutePositionBottomRightTestApp = createReactClass({
@@ -104,15 +123,18 @@ var AbsolutePositionBottomRightTestApp = createReactClass({
right: 10,
width: 50,
height: 60,
}
},
}),
render: function() {
return (
<View style={this._styles.container} testID="container" collapsable={false}>
<View style={this._styles.absolute} collapsable={false}/>
<View
style={this._styles.container}
testID="container"
collapsable={false}>
<View style={this._styles.absolute} collapsable={false} />
</View>
);
}
},
});
var CenteredTextView = createReactClass({
@@ -134,11 +156,13 @@ var CenteredTextView = createReactClass({
return (
<View collapsable={false}>
<View style={this._styles.parent} collapsable={false}>
<Text style={this._styles.text} testID="text">{this.props.text}</Text>
<Text style={this._styles.text} testID="text">
{this.props.text}
</Text>
</View>
</View>
);
}
},
});
var flushUpdatePositionInList = null;
@@ -150,11 +174,11 @@ var UpdatePositionInListTestApp = createReactClass({
},
active: {
height: 50,
}
},
}),
getInitialState: function() {
flushUpdatePositionInList = () => this.setState({ active: true });
return { active: false };
flushUpdatePositionInList = () => this.setState({active: true});
return {active: false};
},
render: function() {
return (
@@ -167,10 +191,10 @@ var UpdatePositionInListTestApp = createReactClass({
]}
collapsable={false}
/>
<View style={this._styles.element} collapsable={false}/>
<View style={this._styles.element} collapsable={false} />
</View>
);
}
},
});
var UIManagerTestModule = {
@@ -194,12 +218,12 @@ var UIManagerTestModule = {
},
flushUpdatePositionInList: function() {
flushUpdatePositionInList();
}
},
};
BatchedBridge.registerCallableModule(
'UIManagerTestModule',
UIManagerTestModule
UIManagerTestModule,
);
module.exports = UIManagerTestModule;
@@ -4,6 +4,7 @@
* 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';
@@ -26,9 +27,7 @@ class ViewSampleApp extends React.Component {
state = {};
render() {
return (
<View style={styles.view} collapsable={false}/>
);
return <View style={styles.view} collapsable={false} />;
}
}
@@ -40,7 +39,10 @@ class MarginSampleApp extends React.Component {
render() {
updateMargins = this.setState.bind(this, {margin: 15});
return (
<View style={{margin: this.state.margin, marginLeft: 20}} collapsable={false}/>
<View
style={{margin: this.state.margin, marginLeft: 20}}
collapsable={false}
/>
);
}
}
@@ -48,8 +50,13 @@ class MarginSampleApp extends React.Component {
class BorderSampleApp extends React.Component {
render() {
return (
<View style={{borderLeftWidth: 20, borderWidth: 5, backgroundColor: 'blue'}} collapsable={false}>
<View style={{backgroundColor: 'red', width: 20, height: 20}} collapsable={false}/>
<View
style={{borderLeftWidth: 20, borderWidth: 5, backgroundColor: 'blue'}}
collapsable={false}>
<View
style={{backgroundColor: 'red', width: 20, height: 20}}
collapsable={false}
/>
</View>
);
}
@@ -64,11 +71,9 @@ class TransformSampleApp extends React.Component {
{rotate: '15deg'},
{scaleX: 5},
{scaleY: 10},
]
],
};
return (
<View style={style} collapsable={false}/>
);
return <View style={style} collapsable={false} />;
}
}
@@ -92,7 +97,7 @@ var ViewRenderingTestModule = {
BatchedBridge.registerCallableModule(
'ViewRenderingTestModule',
ViewRenderingTestModule
ViewRenderingTestModule,
);
module.exports = ViewRenderingTestModule;