initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule Asserts
*/
'use strict';
var Assert = require('NativeModules').Assert;
var Asserts = {
assertEquals: function(expected, actual, msg) {
if (expected !== actual) {
Assert.fail(
msg ||
'Expected: ' + expected + ', received: ' + actual + '\n' +
'at ' + (new Error()).stack);
} else {
Assert.success();
}
},
assertTrue: function(expr, msg) {
Asserts.assertEquals(true, expr, msg);
},
};
module.exports = Asserts;

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule CatalystRootViewTestModule
*/
'use strict';
var React = require('React');
var Recording = require('NativeModules').Recording;
var View = require('View');
class CatalystRootViewTestApp extends React.Component {
componentWillUnmount() {
Recording.record('RootComponentWillUnmount');
}
render() {
return <View collapsable={false} style={{alignSelf: 'stretch'}} />;
}
}
module.exports = {
CatalystRootViewTestApp: CatalystRootViewTestApp,
};

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule DatePickerDialogTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var DatePickerAndroid = require('DatePickerAndroid');
var React = require('React');
var RecordingModule = require('NativeModules').DatePickerDialogRecordingModule;
var View = require('View');
class DatePickerDialogTestApp extends React.Component {
render() {
return (<View />);
}
}
var DatePickerDialogTestModule = {
DatePickerDialogTestApp: DatePickerDialogTestApp,
showDatePickerDialog: function(options) {
DatePickerAndroid.open(options).then(
({action, year, month, day}) => {
if (action === DatePickerAndroid.dateSetAction) {
RecordingModule.recordDate(year, month, day);
} else if (action === DatePickerAndroid.dismissedAction) {
RecordingModule.recordDismissed();
}
},
({code, message}) => RecordingModule.recordError()
);
},
};
BatchedBridge.registerCallableModule(
'DatePickerDialogTestModule',
DatePickerDialogTestModule
);
module.exports = DatePickerDialogTestModule;

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule InitialPropsTestApp
*/
'use strict';
var React = require('React');
var RecordingModule = require('NativeModules').InitialPropsRecordingModule;
var Text = require('Text');
class InitialPropsTestApp extends React.Component {
componentDidMount() {
RecordingModule.recordProps(this.props);
}
render() {
return <Text>dummy</Text>;
}
}
module.exports = InitialPropsTestApp;

View File

@@ -0,0 +1,63 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule JSResponderTestApp
*/
'use strict';
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
var Text = require('Text');
var PanResponder = require('PanResponder');
var ScrollView = require('ScrollView');
class JSResponderTestApp extends React.Component {
_handleMoveShouldSetPanResponder = (e, gestureState) => {
return Math.abs(gestureState.dx) > 30;
};
UNSAFE_componentWillMount() {
this.panGesture = PanResponder.create({
onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,
});
}
render() {
var views = [];
for (var i = 0; i < 100; i++) {
views[i] = (
<View key={i} style={styles.row} collapsable={false}>
<Text>I am row {i}</Text>
</View>
);
}
return (
<View
style={styles.container}
{...this.panGesture.panHandlers}
collapsable={false}>
<ScrollView style={styles.scrollview} testID="scroll_view">
{views}
</ScrollView>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
},
scrollview: {
flex: 1,
},
row: {
height: 30,
}
});
module.exports = JSResponderTestApp;

View File

@@ -0,0 +1,73 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule LayoutEventsTestApp
*/
'use strict';
var React = require('React');
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],
];
class LayoutEventsTestApp extends React.Component {
constructor() {
super();
this.state = {
specNumber: 0,
};
this.numParentLayouts = 0;
}
handleOnLayout = (e) => {
var layout = e.nativeEvent.layout;
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
RecordingModule.record('Got an extraneous layout call');
} else {
this.setState({
specNumber: this.state.specNumber + 1,
});
}
};
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.
RecordingModule.record('Got an extraneous layout call on the parent');
}
this.numParentLayouts++;
};
render() {
const layout = LAYOUT_SPECS[this.state.specNumber];
return (
<View
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]}}/>
</View>
);
}
}
module.exports = LayoutEventsTestApp;

View File

@@ -0,0 +1,204 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule MeasureLayoutTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var ReactNative = require('ReactNative');
var View = require('View');
var StyleSheet = require('StyleSheet');
var UIManager = require('UIManager');
var assertEquals = require('Asserts').assertEquals;
var styles = StyleSheet.create({
A: {
'width': 500,
'height': 500,
},
B: {
backgroundColor: 'rgb(255, 0, 0)',
'left': 50,
'top': 80,
'width': 200,
'height': 300,
},
C: {
backgroundColor: 'rgb(0, 255, 0)',
'left': 100,
'top': 70,
'width': 50,
'height': 150,
},
D: {
backgroundColor: 'rgb(0, 0, 255)',
'left': 400,
'top': 100,
'width': 50,
'height': 200,
},
});
var 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);
}
render() {
return (
<View ref="A" style={styles.A} collapsable={false}>
<View ref="B" style={styles.B} collapsable={false}>
<View ref="C" style={styles.C} collapsable={false} />
</View>
<View ref="D" style={styles.D} collapsable={false} />
</View>
);
}
}
function shouldNotCallThisCallback() {
assertEquals(false, true);
}
var MeasureLayoutTestModule = {
MeasureLayoutTestApp: MeasureLayoutTestApp,
verifyMeasureOnViewA: function() {
UIManager.measure(A, function(a, b, width, height, x, y) {
assertEquals(500, width);
assertEquals(500, height);
assertEquals(0, x);
assertEquals(0, y);
});
},
verifyMeasureOnViewC: function() {
UIManager.measure(C, function(a, b, width, height, x, y) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(150, x);
assertEquals(150, y);
});
},
verifyMeasureLayoutCRelativeToA: function() {
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);
});
},
verifyMeasureLayoutCRelativeToSelf: function() {
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) {
assertEquals(500, width);
assertEquals(500, height);
assertEquals(0, x);
assertEquals(0, y);
});
},
verifyMeasureLayoutRelativeToParentOnViewB: function() {
UIManager.measureLayoutRelativeToParent(
B,
shouldNotCallThisCallback,
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) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(100, x);
assertEquals(70, y);
});
},
verifyMeasureLayoutDRelativeToB: function() {
UIManager.measureLayout(
D,
B,
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback);
},
verifyMeasureLayoutNonExistentTag: function() {
UIManager.measureLayout(
192,
A,
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback);
},
verifyMeasureLayoutNonExistentAncestor: function() {
UIManager.measureLayout(
B,
192,
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback);
},
verifyMeasureLayoutRelativeToParentNonExistentTag: function() {
UIManager.measureLayoutRelativeToParent(
192,
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback);
},
};
BatchedBridge.registerCallableModule(
'MeasureLayoutTestModule',
MeasureLayoutTestModule
);
module.exports = MeasureLayoutTestModule;

View File

@@ -0,0 +1,66 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule MultitouchHandlingTestAppModule
*/
'use strict';
var React = require('React');
var Recording = require('NativeModules').Recording;
var StyleSheet = require('StyleSheet');
var TouchEventUtils = require('fbjs/lib/TouchEventUtils');
var View = require('View');
class TouchTestApp extends React.Component {
handleStartShouldSetResponder = (e) => {
return true;
};
handleOnResponderMove = (e) => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
Recording.record('move;' + e.touches.length);
};
handleResponderStart = (e) => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('start;' + e.touches.length);
} else {
Recording.record('start;ExtraPointer');
}
};
handleResponderEnd = (e) => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('end;' + e.touches.length);
} else {
Recording.record('end;ExtraPointer');
}
};
render() {
return (
<View
style={styles.container}
onStartShouldSetResponder={this.handleStartShouldSetResponder}
onResponderMove={this.handleOnResponderMove}
onResponderStart={this.handleResponderStart}
onResponderEnd={this.handleResponderEnd}
collapsable={false}
/>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
},
});
module.exports = TouchTestApp;

View File

@@ -0,0 +1,75 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule NativeIdTestModule
* @flow
*/
'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');
/**
* All the views implemented on Android, each with the nativeID property set.
* We test that:
* - The app renders fine
* - The nativeID property is passed to the native views
*/
class NativeIdTestApp extends React.Component<{}> {
render() {
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} />
<Text nativeID="Text">text</Text>
<TextInput nativeID="TextInput" value="Text input" />
<TouchableBounce nativeID="TouchableBounce">
<Text>TouchableBounce</Text>
</TouchableBounce>
<TouchableHighlight nativeID="TouchableHighlight">
<Text>TouchableHighlight</Text>
</TouchableHighlight>
<TouchableOpacity nativeID="TouchableOpacity">
<Text>TouchableOpacity</Text>
</TouchableOpacity>
<TouchableWithoutFeedback nativeID="TouchableWithoutFeedback">
<View>
<Text>TouchableWithoutFeedback</Text>
</View>
</TouchableWithoutFeedback>
<View nativeID="View" />
</View>
);
}
}
const styles = StyleSheet.create({
base: {
width: 150,
height: 50,
},
});
module.exports = {
NativeIdTestApp: NativeIdTestApp,
};

View File

@@ -0,0 +1,90 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule PickerAndroidTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var RecordingModule = require('NativeModules').PickerAndroidRecordingModule;
var Picker = require('Picker');
var View = require('View');
var Item = Picker.Item;
var appInstance;
class PickerAndroidTestApp extends React.Component {
state = {
selected: 1,
mode: 'dropdown',
style: {},
};
UNSAFE_componentWillMount() {
appInstance = this;
}
render() {
return (
<View collapsable={false}>
<Picker
mode="dialog"
prompt="prompt"
style={this.state.style}
selectedValue={this.state.selected}
onValueChange={this.onValueChange}>
<Item label="item1" color="#ff0000" value={0} />
<Item label="item2" color="#00ff00" value={1} />
<Item label="item3" color="#0000ff" value={2} />
</Picker>
<Picker mode={this.state.mode}>
<Item label="item1" />
<Item label="item2" />
</Picker>
<Picker enabled={false}>
<Item label="item1" />
<Item label="item2" />
</Picker>
<Picker
mode="dropdown"
selectedValue={this.state.selected}
onValueChange={this.onValueChange}>
<Item label="item in sync 1" value={0} />
<Item label="item in sync 2" value={1} />
<Item label="item in sync 3" value={2} />
</Picker>
</View>
);
}
onValueChange = (value) => {
this.setState({selected: value});
RecordingModule.recordSelection(value);
};
}
var PickerAndroidTestModule = {
PickerAndroidTestApp: PickerAndroidTestApp,
selectItem: function(value) {
appInstance.setState({selected: value});
},
setMode: function(mode) {
appInstance.setState({mode: mode});
},
setPrimaryColor: function(color) {
appInstance.setState({style: {color}});
},
};
BatchedBridge.registerCallableModule(
'PickerAndroidTestModule',
PickerAndroidTestModule
);
module.exports = PickerAndroidTestModule;

View File

@@ -0,0 +1,51 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule ProgressBarTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var ProgressBar = require('ProgressBarAndroid');
var View = require('View');
var renderApplication = require('renderApplication');
class ProgressBarSampleApp extends React.Component {
state = {};
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="Horizontal200" />
</View>
</View>
);
}
}
var ProgressBarTestModule = {
renderProgressBarApplication: function(rootTag) {
renderApplication(ProgressBarSampleApp, {}, rootTag);
},
};
BatchedBridge.registerCallableModule(
'ProgressBarTestModule',
ProgressBarTestModule
);
module.exports = ProgressBarTestModule;

View File

@@ -0,0 +1,143 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule ScrollViewTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var createReactClass = require('create-react-class');
var View = require('View');
var ScrollView = require('ScrollView');
var Text = require('Text');
var StyleSheet = require('StyleSheet');
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
var ScrollListener = require('NativeModules').ScrollListener;
var NUM_ITEMS = 100;
// Shared by integration tests for ScrollView and HorizontalScrollView
var scrollViewApp;
class Item extends React.Component {
render() {
return (
<TouchableWithoutFeedback onPress={this.props.onPress}>
<View style={styles.item_container}>
<Text style={styles.item_text}>{this.props.text}</Text>
</View>
</TouchableWithoutFeedback>
);
}
}
var getInitialState = function() {
var data = [];
for (var i = 0; i < NUM_ITEMS; i++) {
data[i] = {text: 'Item ' + i + '!'};
}
return {
data: data,
};
};
var onScroll = function(e) {
ScrollListener.onScroll(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
};
var onScrollBeginDrag = function(e) {
ScrollListener.onScrollBeginDrag(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
};
var onScrollEndDrag = function(e) {
ScrollListener.onScrollEndDrag(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
};
var onItemPress = function(itemNumber) {
ScrollListener.onItemPress(itemNumber);
};
var ScrollViewTestApp = createReactClass({
displayName: 'ScrollViewTestApp',
getInitialState: getInitialState,
onScroll: onScroll,
onItemPress: onItemPress,
onScrollBeginDrag: onScrollBeginDrag,
onScrollEndDrag: onScrollEndDrag,
scrollTo: function(destX, destY) {
this.refs.scrollView.scrollTo(destY, destX);
},
render: function() {
scrollViewApp = this;
var children = this.state.data.map((item, index) => (
<Item
key={index} text={item.text}
onPress={this.onItemPress.bind(this, index)} />
));
return (
<ScrollView onScroll={this.onScroll} onScrollBeginDrag={this.onScrollBeginDrag} onScrollEndDrag={this.onScrollEndDrag} ref="scrollView">
{children}
</ScrollView>
);
},
});
var HorizontalScrollViewTestApp = createReactClass({
displayName: 'HorizontalScrollViewTestApp',
getInitialState: getInitialState,
onScroll: onScroll,
onItemPress: onItemPress,
scrollTo: function(destX, destY) {
this.refs.scrollView.scrollTo(destY, destX);
},
render: function() {
scrollViewApp = this;
var children = this.state.data.map((item, index) => (
<Item
key={index} text={item.text}
onPress={this.onItemPress.bind(this, index)} />
));
return (
<ScrollView horizontal={true} onScroll={this.onScroll} ref="scrollView">
{children}
</ScrollView>
);
},
});
var styles = StyleSheet.create({
item_container: {
padding: 30,
backgroundColor: '#ffffff',
},
item_text: {
flex: 1,
fontSize: 18,
alignSelf: 'center',
},
});
var ScrollViewTestModule = {
ScrollViewTestApp: ScrollViewTestApp,
HorizontalScrollViewTestApp: HorizontalScrollViewTestApp,
scrollTo: function(destX, destY) {
scrollViewApp.scrollTo(destX, destY);
},
};
BatchedBridge.registerCallableModule(
'ScrollViewTestModule',
ScrollViewTestModule
);
module.exports = ScrollViewTestModule;

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule ShareTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var RecordingModule = require('NativeModules').ShareRecordingModule;
var Share = require('Share');
var View = require('View');
class ShareTestApp extends React.Component {
render() {
return (<View />);
}
}
var ShareTestModule = {
ShareTestApp: ShareTestApp,
showShareDialog: function(content, options) {
Share.share(content, options).then(
() => RecordingModule.recordOpened(),
({code, message}) => RecordingModule.recordError()
);
},
};
BatchedBridge.registerCallableModule(
'ShareTestModule',
ShareTestModule
);
module.exports = ShareTestModule;

View File

@@ -0,0 +1,310 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule SubviewsClippingTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
var ScrollView = require('ScrollView');
var StyleSheet = require('StyleSheet');
var View = require('View');
var requireNativeComponent = require('requireNativeComponent');
var ClippableView = requireNativeComponent('ClippableView', null);
class ClippingSample1 extends React.Component {
render() {
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>
</View>
);
}
}
var sample1Styles = StyleSheet.create({
outer: {
width: 200,
height: 200,
backgroundColor: 'red',
},
inner: {
position: 'absolute',
width: 100,
height: 100,
backgroundColor: 'green',
},
inner1: {
top: -150,
left: 50,
},
inner2: {
top: 50,
left: 50,
},
inner3: {
top: 250,
left: 50,
},
inner4: {
left: -150,
top: 50,
},
inner5: {
left: 250,
top: 50,
},
});
class ClippingSample2 extends React.Component {
render() {
var styles = sample2Styles;
return (
<View>
<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]}/>
</ClippableView>
</ClippableView>
</View>
);
}
}
var sample2Styles = StyleSheet.create({
outer: {
width: 200,
height: 200,
backgroundColor: 'red',
},
complexInner: {
position: 'absolute',
width: 200,
height: 200,
left: 100,
top: 100,
backgroundColor: 'green',
},
inner: {
position: 'absolute',
width: 80,
height: 80,
backgroundColor: 'blue',
},
inner1: {
left: 10,
top: 10,
},
inner2: {
right: 10,
top: 10,
},
inner3: {
left: 10,
bottom: 10,
},
inner4: {
right: 10,
bottom: 10,
},
});
class UpdatingSample1 extends React.Component {
render() {
var styles = updating1Styles;
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>
</View>
);
}
}
var updating1Styles = StyleSheet.create({
outer: {
width: 200,
height: 200,
backgroundColor: 'red',
},
inner1: {
position: 'absolute',
width: 100,
height: 100,
left: 50,
top: -100,
backgroundColor: 'green',
},
inner2: {
position: 'absolute',
width: 100,
height: 100,
left: 50,
top: 50,
backgroundColor: 'green',
}
});
class UpdatingSample2 extends React.Component {
render() {
var styles = updating2Styles;
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>
</View>
);
}
}
var updating2Styles = StyleSheet.create({
outer: {
width: 100,
height: 100,
backgroundColor: 'red',
},
inner: {
position: 'absolute',
width: 100,
height: 100,
top: 100,
backgroundColor: 'green',
},
});
class ScrollViewTest extends React.Component {
render() {
var styles = scrollTestStyles;
var children = [];
for (var i = 0; i < 4; i++) {
children[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'}/>
</ClippableView>
);
}
return (
<ScrollView removeClippedSubviews={true} style={styles.scrollView} testID="scroll_view">
{children}
</ScrollView>
);
}
}
var scrollTestStyles = StyleSheet.create({
scrollView: {
width: 200,
height: 300,
},
row: {
flex: 1,
height: 120,
backgroundColor: 'red',
borderColor: 'blue',
borderBottomWidth: 1,
},
complex: {
flex: 1,
height: 240,
backgroundColor: 'yellow',
borderColor: 'blue',
borderBottomWidth: 1,
},
inner: {
flex: 1,
margin: 10,
height: 100,
backgroundColor: 'gray',
borderColor: 'green',
borderWidth: 1,
},
});
var appInstance = null;
class SubviewsClippingTestApp extends React.Component {
state = {};
UNSAFE_componentWillMount() {
appInstance = this;
}
setComponent = (component) => {
this.setState({component: component});
};
render() {
var component = this.state.component;
return (
<View>
{component}
</View>
);
}
}
var SubviewsClippingTestModule = {
App: SubviewsClippingTestApp,
renderClippingSample1: function() {
appInstance.setComponent(<ClippingSample1/>);
},
renderClippingSample2: function() {
appInstance.setComponent(<ClippingSample2/>);
},
renderUpdatingSample1: function(update1, update2) {
appInstance.setComponent(<UpdatingSample1 update1={update1} update2={update2}/>);
},
renderUpdatingSample2: function(update) {
appInstance.setComponent(<UpdatingSample2 update={update}/>);
},
renderScrollViewTest: function() {
appInstance.setComponent(<ScrollViewTest/>);
},
};
BatchedBridge.registerCallableModule(
'SubviewsClippingTestModule',
SubviewsClippingTestModule
);
module.exports = SubviewsClippingTestModule;

View File

@@ -0,0 +1,89 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule SwipeRefreshLayoutTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var RecordingModule = require('NativeModules').SwipeRefreshLayoutRecordingModule;
var ScrollView = require('ScrollView');
var RefreshControl = require('RefreshControl');
var Text = require('Text');
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
var View = require('View');
class Row extends React.Component {
state = {
clicks: 0,
};
render() {
return (
<TouchableWithoutFeedback onPress={this._onPress}>
<View>
<Text>
{this.state.clicks + ' clicks'}
</Text>
</View>
</TouchableWithoutFeedback>
);
}
_onPress = () => {
this.setState({clicks: this.state.clicks + 1});
};
}
var app = null;
class SwipeRefreshLayoutTestApp extends React.Component {
state = {
rows: 2,
};
componentDidMount() {
app = this;
}
render() {
var rows = [];
for (var i = 0; i < this.state.rows; i++) {
rows.push(<Row key={i} />);
}
return (
<ScrollView
style={{flex: 1}}
refreshControl={
<RefreshControl
style={{flex: 1}}
refreshing={false}
onRefresh={() => RecordingModule.onRefresh()}
/>
}>
{rows}
</ScrollView>
);
}
}
var SwipeRefreshLayoutTestModule = {
SwipeRefreshLayoutTestApp,
setRows: function(rows) {
if (app != null) {
app.setState({rows});
}
}
};
BatchedBridge.registerCallableModule(
'SwipeRefreshLayoutTestModule',
SwipeRefreshLayoutTestModule
);
module.exports = SwipeRefreshLayoutTestModule;

View File

@@ -0,0 +1,115 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TestBundle
*/
'use strict';
// Disable YellowBox so we do not have to mock its dependencies
console.disableYellowBox = true;
// Include callable JS modules first, in case one of the other ones below throws
require('ProgressBarTestModule');
require('ViewRenderingTestModule');
require('TestJavaToJSArgumentsModule');
require('TestJSLocaleModule');
require('TestJSToJavaParametersModule');
require('TestJavaToJSReturnValuesModule');
require('UIManagerTestModule');
require('CatalystRootViewTestModule');
require('DatePickerDialogTestModule');
require('MeasureLayoutTestModule');
require('PickerAndroidTestModule');
require('ScrollViewTestModule');
require('ShareTestModule');
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')
},
];
module.exports = apps;
AppRegistry.registerConfig(apps);

View File

@@ -0,0 +1,83 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TestIdTestModule
*/
'use strict';
var Image = require('Image');
var React = require('React');
var StyleSheet = require('StyleSheet');
var Switch = require('Switch');
var Text = require('Text');
var TextInput = require('TextInput');
var TouchableBounce = require('TouchableBounce');
var TouchableHighlight = require('TouchableHighlight');
var TouchableOpacity = require('TouchableOpacity');
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
var View = require('View');
/**
* All the views implemented on Android, each with the testID property set.
* We test that:
* - The app renders fine
* - The testID property is passed to the native views
*/
class TestIdTestApp extends React.Component {
render() {
return (
<View>
<Image
testID="Image"
source={{uri: 'data:image/gif;base64,' +
'R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapy' +
'uvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/' +
'TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5' +
'iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97V' +
'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7'}}
style={styles.base} />
<Text testID="Text">text</Text>
<TextInput testID="TextInput" value="Text input" />
<TouchableBounce testID="TouchableBounce">
<Text>TouchableBounce</Text>
</TouchableBounce>
<TouchableHighlight testID="TouchableHighlight">
<Text>TouchableHighlight</Text>
</TouchableHighlight>
<TouchableOpacity testID="TouchableOpacity">
<Text>TouchableOpacity</Text>
</TouchableOpacity>
<TouchableWithoutFeedback testID="TouchableWithoutFeedback">
<View>
<Text>TouchableWithoutFeedback</Text>
</View>
</TouchableWithoutFeedback>
<View testID="View" />
</View>
);
}
}
var styles = StyleSheet.create({
base: {
width: 150,
height: 50,
},
});
module.exports = {
TestIdTestApp: TestIdTestApp,
};

View File

@@ -0,0 +1,29 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TestJSLocaleModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var Recording = require('NativeModules').Recording;
var TestJSLocaleModule = {
toUpper: function(s) {
Recording.record(s.toUpperCase());
},
toLower: function(s) {
Recording.record(s.toLowerCase());
},
};
BatchedBridge.registerCallableModule(
'TestJSLocaleModule',
TestJSLocaleModule
);
module.exports = TestJSLocaleModule;

View File

@@ -0,0 +1,122 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TestJSToJavaParametersModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var Recording = require('NativeModules').Recording;
var TestJSToJavaParametersModule = {
returnBasicTypes: function() {
Recording.receiveBasicTypes('foo', 3.14, true, null);
},
returnBoxedTypes: function() {
Recording.receiveBoxedTypes(42, 3.14, true);
},
returnDynamicTypes: function() {
Recording.receiveDynamic('foo');
Recording.receiveDynamic(3.14);
},
returnArrayWithBasicTypes: function() {
Recording.receiveArray(['foo', 3.14, -111, true, null]);
},
returnNestedArray: function() {
Recording.receiveArray(['we', ['have', ['to', ['go', ['deeper']]]]]);
},
returnArrayWithMaps: function() {
Recording.receiveArray([{m1k1: 'm1v1', m1k2: 'm1v2'}, {m2k1: 'm2v1'}]);
},
returnMapWithBasicTypes: function() {
Recording.receiveMap({
stringKey: 'stringValue',
doubleKey: 3.14,
intKey: -11,
booleanKey: true,
nullKey: null,
});
},
returnNestedMap: function() {
Recording.receiveMap({
weHaveToGoDeeper: {
inception: true,
},
});
},
returnMapWithArrays: function() {
Recording.receiveMap({
'empty': [],
'ints': [43, 44],
'mixed': [77, 'string', ['another', 'array']],
});
},
returnArrayWithStringDoubleIntMapArrayBooleanNull: function() {
Recording.receiveArray(['string', 3.14, 555, {}, [], true, null]);
},
returnMapWithStringDoubleIntMapArrayBooleanNull: function() {
Recording.receiveMap({
string: 'string',
double: 3,
map: {},
int: -55,
array: [],
boolean: true,
null: null
});
},
returnArrayWithLargeInts: function() {
Recording.receiveArray([2147483648, -5555555555]);
},
returnMapWithLargeInts: function() {
Recording.receiveMap({first: -2147483649, second: 5551231231});
},
returnMapForMerge1: function() {
Recording.receiveMap({
a: 1,
b: 41,
c: 'string',
d: 'other string',
e: [1,'foo','bar'],
f: null,
});
},
returnMapForMerge2: function() {
Recording.receiveMap({
a: 'overwrite',
d: 77,
e: null,
f: ['array', 'with', 'stuff'],
newkey: 'newvalue',
});
},
returnMapWithMultibyteUTF8CharacterString: function() {
Recording.receiveMap({
'one-byte': 'a',
'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'
});
},
returnArrayWithMultibyteUTF8CharacterString: function() {
Recording.receiveArray([
'a',
'\u00A2',
'\u20AC',
'\uD83D\uDE1C',
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107'
]);
},
};
BatchedBridge.registerCallableModule(
'TestJSToJavaParametersModule',
TestJSToJavaParametersModule
);
module.exports = TestJSToJavaParametersModule;

View File

@@ -0,0 +1,114 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TestJavaToJSArgumentsModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var {assertEquals, assertTrue} = require('Asserts');
function strictStringCompare(a, b) {
if (typeof a !== 'string' || typeof b !== 'string' || a.length !== b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (a.charCodeAt(i) !== b.charCodeAt(i)) {
return false;
}
}
return true;
}
function assertStrictStringEquals(a, b) {
assertTrue(
strictStringCompare(a,b),
'Expected: ' + a + ', received: ' + b);
}
var TestJavaToJSArgumentsModule = {
receiveBasicTypes: function(str, dbl, bool, null_arg) {
assertEquals('foo', str);
assertEquals(3.14, dbl);
assertEquals(true, bool);
assertEquals(null, null_arg);
},
receiveArrayWithBasicTypes: function(arr) {
assertEquals(4, arr.length);
assertEquals('red panda', arr[0]);
assertEquals(1.19, arr[1]);
assertEquals(true, arr[2]);
assertEquals(null, arr[3]);
},
receiveNestedArray: function(arr) {
assertEquals(2, arr.length);
assertEquals('level1', arr[0]);
var arr2 = arr[1];
assertEquals('level2', arr2[0]);
var arr3 = arr2[1];
assertEquals('level3', arr3[0]);
},
receiveArrayWithMaps: function(arr) {
assertEquals(2, arr.length);
var m1 = arr[0];
var m2 = arr[1];
assertEquals('m1v1', m1.m1k1);
assertEquals('m1v2', m1.m1k2);
assertEquals('m2v1', m2.m2k1);
},
receiveMapWithBasicTypes: function(map) {
assertEquals('stringValue', map.stringKey);
assertEquals(3.14, map.doubleKey);
assertEquals(true, map.booleanKey);
assertEquals(null, map.nullKey);
},
receiveNestedMap: function(map) {
var nestedMap = map.nestedMap;
assertEquals('foxes', nestedMap.animals);
},
receiveMapWithArrays: function(map) {
var a1 = map.array1;
var a2 = map.array2;
assertEquals(3, a1.length);
assertEquals(2, a2.length);
assertEquals(3, a1[0]);
assertEquals(9, a2[1]);
},
receiveMapAndArrayWithNullValues: function(map, array) {
assertEquals(null, map.string);
assertEquals(null, map.array);
assertEquals(null, map.map);
assertEquals(null, array[0]);
assertEquals(null, array[1]);
assertEquals(null, array[2]);
},
receiveMapWithMultibyteUTF8CharacterString: function(map) {
assertStrictStringEquals('\u00A2', map['two-bytes']);
assertStrictStringEquals('\u20AC', map['three-bytes']);
assertStrictStringEquals('\uD83D\uDE1C', map['four-bytes']);
assertStrictStringEquals(
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
map.mixed);
},
receiveArrayWithMultibyteUTF8CharacterString: function(array) {
assertTrue(true);
assertStrictStringEquals('\u00A2', array[0]);
assertStrictStringEquals('\u20AC', array[1]);
assertStrictStringEquals('\uD83D\uDE1C', array[2]);
assertStrictStringEquals(
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
array[3]);
},
};
BatchedBridge.registerCallableModule(
'TestJavaToJSArgumentsModule',
TestJavaToJSArgumentsModule
);
module.exports = TestJavaToJSArgumentsModule;

View File

@@ -0,0 +1,38 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TestJavaToJSReturnValuesModule
*/
'use strict';
const BatchedBridge = require('BatchedBridge');
const {assertEquals, assertTrue} = require('Asserts');
const {TestModule} = require('NativeModules');
var TestJavaToJSReturnValuesModule = {
callMethod: function(methodName, expectedType, expectedJSON) {
const result = TestModule[methodName]();
assertEquals(expectedType, typeof result);
assertEquals(expectedJSON, JSON.stringify(result));
},
triggerException: function() {
try {
TestModule.triggerException();
} catch (ex) {
assertTrue(ex.message.indexOf('Exception triggered') !== -1);
}
}
};
BatchedBridge.registerCallableModule(
'TestJavaToJSReturnValuesModule',
TestJavaToJSReturnValuesModule
);
module.exports = TestJavaToJSReturnValuesModule;

View File

@@ -0,0 +1,180 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TextInputTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var StyleSheet = require('StyleSheet');
var Text = require('Text');
var TextInput = require('TextInput');
var View = require('View');
var Recording = require('NativeModules').Recording;
var app;
class TokenizedTextExample extends React.Component {
constructor(props) {
super(props);
this.state = {text: ''};
}
render() {
//define delimiter
let delimiter = /\s+/;
//split string
let _text = this.state.text;
let token, index, parts = [];
while (_text) {
delimiter.lastIndex = 0;
token = delimiter.exec(_text);
if (token === null) {
break;
}
index = token.index;
if (token[0].length === 0) {
index = 1;
}
parts.push(_text.substr(0, index));
parts.push(token[0]);
index = index + token[0].length;
_text = _text.slice(index);
}
parts.push(_text);
//highlight hashtags
parts = parts.map((text) => {
if (/^#/.test(text)) {
return <Text key={text} style={styles.hashtag}>{text}</Text>;
} else {
return text;
}
});
return (
<View>
<TextInput
ref="tokenizedInput"
testID="tokenizedInput"
multiline={true}
style={styles.multiline}
onChangeText={(text) => {
this.setState({text});
}}>
<Text>{parts}</Text>
</TextInput>
</View>
);
}
}
class TextInputTestApp extends React.Component {
componentDidMount() {
app = this;
}
handleOnSubmitEditing = (record) => {
Recording.record(record);
};
render() {
return (
<View style={styles.container}>
<TextInput
style={styles.textInputHeight}
autoCorrect={true}
autoFocus={true}
keyboardType="numeric"
multiline={true}
secureTextEntry={true}
defaultValue="This is text"
testID="textInput1"
/>
<TextInput
style={styles.textInput}
autoCapitalize="sentences"
autoCorrect={false}
autoFocus={false}
keyboardType="default"
multiline={false}
secureTextEntry={false}
placeholder="1234"
testID="textInput2"
/>
<TextInput
ref="textInput3"
style={styles.textInput}
defaultValue="Hello, World"
testID="textInput3"
/>
<TextInput
ref="textInput4"
style={[styles.textInput, {color: '#00ff00'}]}
testID="textInput4"
/>
<TextInput
ref="textInput5"
style={[styles.textInput, {color: '#00ff00'}]}
defaultValue=""
testID="textInput5"
/>
<TextInput
ref="textInput6"
style={[styles.textInput, {color: '#00ff00'}]}
defaultValue="Text"
testID="textInput6"
/>
<TextInput
ref="onSubmitTextInput"
onSubmitEditing={this.handleOnSubmitEditing.bind(this, 'onSubmit')}
defaultValue=""
testID="onSubmitTextInput"
/>
<TokenizedTextExample />
</View>
);
}
}
var styles = StyleSheet.create({
container: {
padding: 5,
margin: 10,
},
textInputHeight: {
fontSize: 21,
height: 30,
},
textInput: {
fontSize: 21,
padding: 0,
},
hashtag: {
color: 'blue',
fontWeight: 'bold',
},
});
var TextInputTestModule = {
TextInputTestApp,
setValueRef: function(ref, value) {
app.refs[ref].setNativeProps({
text: value,
});
},
};
BatchedBridge.registerCallableModule(
'TextInputTestModule',
TextInputTestModule
);
module.exports = TextInputTestModule;

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TimePickerDialogTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var TimePickerAndroid = require('TimePickerAndroid');
var React = require('React');
var RecordingModule = require('NativeModules').TimePickerDialogRecordingModule;
var View = require('View');
class TimePickerDialogTestApp extends React.Component {
render() {
return <View />;
}
}
var TimePickerDialogTestModule = {
TimePickerDialogTestApp: TimePickerDialogTestApp,
showTimePickerDialog: function(options) {
TimePickerAndroid.open(options).then(
({action, hour, minute}) => {
if (action === TimePickerAndroid.timeSetAction) {
RecordingModule.recordTime(hour, minute);
} else if (action === TimePickerAndroid.dismissedAction) {
RecordingModule.recordDismissed();
}
},
({code, message}) => RecordingModule.recordError()
);
},
};
BatchedBridge.registerCallableModule(
'TimePickerDialogTestModule',
TimePickerDialogTestModule
);
module.exports = TimePickerDialogTestModule;

View File

@@ -0,0 +1,75 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule TouchBubblingTestAppModule
*/
'use strict';
var Recording = require('NativeModules').Recording;
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
class TouchBubblingTestApp extends React.Component {
handlePress = (record) => {
Recording.record(record);
};
render() {
return (
<View style={styles.container}>
<TouchableWithoutFeedback onPress={this.handlePress.bind(this, 'outer')} testID="D">
<View style={styles.outer}>
<TouchableWithoutFeedback onPress={this.handlePress.bind(this, 'inner')} testID="B">
<View style={styles.inner}>
<View style={styles.superinner} testID="A" />
</View>
</TouchableWithoutFeedback>
<View style={styles.inner} testID="C" />
</View>
</TouchableWithoutFeedback>
<TouchableWithoutFeedback onPress={this.handlePress.bind(this, 'outsider')} testID="E">
<View style={styles.element} />
</TouchableWithoutFeedback>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flexDirection: 'column',
backgroundColor: '#ccdd44',
},
element: {
backgroundColor: '#ff0000',
height: 100,
margin: 30,
},
outer: {
backgroundColor: '#00ff00',
height: 100,
margin: 30,
flexDirection: 'row',
justifyContent: 'space-between',
},
inner: {
backgroundColor: '#0000ff',
height: 50,
width: 50,
margin: 10,
},
superinner: {
backgroundColor: '#eeeeee',
height: 20,
width: 20,
}
});
module.exports = TouchBubblingTestApp;

View File

@@ -0,0 +1,206 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule UIManagerTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
var Text = require('Text');
var createReactClass = require('create-react-class');
var renderApplication = require('renderApplication');
var FlexTestApp = createReactClass({
displayName: 'FlexTestApp',
_styles: StyleSheet.create({
container: {
width: 200,
height: 200,
flexDirection: 'row',
},
child: {
flex: 1,
},
absolute: {
position: 'absolute',
top: 15,
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>
);
}
});
var FlexWithText = createReactClass({
displayName: 'FlexWithText',
_styles: StyleSheet.create({
container: {
flexDirection: 'column',
margin: 20,
},
row: {
flexDirection: 'row',
alignItems: 'flex-end',
height: 300,
},
inner: {
flex: 1,
margin: 10,
},
}),
render: function() {
return (
<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({
displayName: 'AbsolutePositionTestApp',
_styles: StyleSheet.create({
absolute: {
position: 'absolute',
top: 15,
left: 10,
width: 50,
height: 60,
}
}),
render: function() {
return <View style={this._styles.absolute} testID="absolute" collapsable={false}/>;
}
});
var AbsolutePositionBottomRightTestApp = createReactClass({
displayName: 'AbsolutePositionBottomRightTestApp',
_styles: StyleSheet.create({
container: {
width: 100,
height: 100,
},
absolute: {
position: 'absolute',
bottom: 15,
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>
);
}
});
var CenteredTextView = createReactClass({
displayName: 'CenteredTextView',
_styles: StyleSheet.create({
parent: {
width: 200,
height: 100,
backgroundColor: '#aa3311',
justifyContent: 'center',
alignItems: 'center',
},
text: {
fontSize: 15,
color: '#672831',
},
}),
render: function() {
return (
<View collapsable={false}>
<View style={this._styles.parent} collapsable={false}>
<Text style={this._styles.text} testID="text">{this.props.text}</Text>
</View>
</View>
);
}
});
var flushUpdatePositionInList = null;
var UpdatePositionInListTestApp = createReactClass({
displayName: 'UpdatePositionInListTestApp',
_styles: StyleSheet.create({
element: {
height: 10,
},
active: {
height: 50,
}
}),
getInitialState: function() {
flushUpdatePositionInList = () => this.setState({ active: true });
return { active: false };
},
render: function() {
return (
<View collapsable={false} testID="container">
<View style={this._styles.element} collapsable={false} />
<View
style={[
this._styles.element,
this.state.active && this._styles.active,
]}
collapsable={false}
/>
<View style={this._styles.element} collapsable={false}/>
</View>
);
}
});
var UIManagerTestModule = {
renderFlexTestApplication: function(rootTag) {
renderApplication(FlexTestApp, {}, rootTag);
},
renderFlexWithTextApplication: function(rootTag) {
renderApplication(FlexWithText, {}, rootTag);
},
renderAbsolutePositionBottomRightTestApplication: function(rootTag) {
renderApplication(AbsolutePositionBottomRightTestApp, {}, rootTag);
},
renderAbsolutePositionTestApplication: function(rootTag) {
renderApplication(AbsolutePositionTestApp, {}, rootTag);
},
renderCenteredTextViewTestApplication: function(rootTag, text) {
renderApplication(CenteredTextView, {text: text}, rootTag);
},
renderUpdatePositionInListTestApplication: function(rootTag) {
renderApplication(UpdatePositionInListTestApp, {}, rootTag);
},
flushUpdatePositionInList: function() {
flushUpdatePositionInList();
}
};
BatchedBridge.registerCallableModule(
'UIManagerTestModule',
UIManagerTestModule
);
module.exports = UIManagerTestModule;

View File

@@ -0,0 +1,99 @@
/**
* Copyright (c) 2013-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.
*
* @providesModule ViewRenderingTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var View = require('View');
var StyleSheet = require('StyleSheet');
var renderApplication = require('renderApplication');
var styles = StyleSheet.create({
view: {
opacity: 0.75,
backgroundColor: 'rgb(255, 0, 0)',
},
});
class ViewSampleApp extends React.Component {
state = {};
render() {
return (
<View style={styles.view} collapsable={false}/>
);
}
}
var updateMargins;
class MarginSampleApp extends React.Component {
state = {margin: 10};
render() {
updateMargins = this.setState.bind(this, {margin: 15});
return (
<View style={{margin: this.state.margin, marginLeft: 20}} collapsable={false}/>
);
}
}
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>
);
}
}
class TransformSampleApp extends React.Component {
render() {
var style = {
transform: [
{translateX: 20},
{translateY: 25},
{rotate: '15deg'},
{scaleX: 5},
{scaleY: 10},
]
};
return (
<View style={style} collapsable={false}/>
);
}
}
var ViewRenderingTestModule = {
renderViewApplication: function(rootTag) {
renderApplication(ViewSampleApp, {}, rootTag);
},
renderMarginApplication: function(rootTag) {
renderApplication(MarginSampleApp, {}, rootTag);
},
renderBorderApplication: function(rootTag) {
renderApplication(BorderSampleApp, {}, rootTag);
},
renderTransformApplication: function(rootTag) {
renderApplication(TransformSampleApp, {}, rootTag);
},
updateMargins: function() {
updateMargins();
},
};
BatchedBridge.registerCallableModule(
'ViewRenderingTestModule',
ViewRenderingTestModule
);
module.exports = ViewRenderingTestModule;