Made SandCastle run the same Instrumentation Tests that are open sourced and are running on CI

Reviewed By: mkonicek

Differential Revision: D3229774

fb-gh-sync-id: 48239e8898eb011ad767bf102aa65025351363c6
fbshipit-source-id: 48239e8898eb011ad767bf102aa65025351363c6
This commit is contained in:
Konstantin Raev
2016-04-29 05:10:27 -07:00
committed by Facebook Github Bot 6
parent 58876d5a03
commit f99786cc89
7 changed files with 287 additions and 12 deletions

View File

@@ -0,0 +1,82 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @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;
var PickerAndroidTestApp = React.createClass({
componentWillMount: function() {
appInstance = this;
},
getInitialState: function() {
return {
selected: 1,
mode: 'dropdown',
style: {},
};
},
render: function() {
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>
</View>
);
},
onValueChange: function(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,142 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ScrollViewTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
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;
var Item = React.createClass({
render: function() {
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 = React.createClass({
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 = React.createClass({
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,38 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
'use strict';
// Disable YellowBox so we do not have to mock its dependencies
console.disableYellowBox = true;
// Include modules used by integration tests
require('ScrollViewTestModule');
require('PickerAndroidTestModule');
// Define catalyst test apps used in integration tests
var AppRegistry = require('AppRegistry');
var apps = [
{
appKey: 'ScrollViewTestApp',
component: () => require('ScrollViewTestModule').ScrollViewTestApp,
},
{
appKey: 'HorizontalScrollViewTestApp',
component: () => require('ScrollViewTestModule').HorizontalScrollViewTestApp,
},
{
appKey: 'PickerAndroidTestApp',
component: () => require('PickerAndroidTestModule').PickerAndroidTestApp,
},
];
module.exports = apps;
AppRegistry.registerConfig(apps);