2020-01-21 19:39:40 +00:00
|
|
|
import React, {Component} from 'react';
|
|
|
|
import {
|
|
|
|
StyleSheet,
|
|
|
|
SafeAreaView,
|
|
|
|
Text,
|
|
|
|
TouchableOpacity,
|
|
|
|
View,
|
|
|
|
Keyboard,
|
|
|
|
Button,
|
2020-02-19 02:40:30 +00:00
|
|
|
Platform,
|
2020-01-21 19:39:40 +00:00
|
|
|
} from 'react-native';
|
2020-01-16 22:49:10 +00:00
|
|
|
|
2020-10-08 13:20:36 +00:00
|
|
|
import Permission from './examples/Permission';
|
2020-01-21 19:39:40 +00:00
|
|
|
import Alerts from './examples/Alerts';
|
|
|
|
import Scrolling from './examples/Scrolling';
|
|
|
|
import Background from './examples/Background';
|
2020-04-29 16:09:22 +00:00
|
|
|
import Downloads from './examples/Downloads';
|
2020-02-19 02:40:30 +00:00
|
|
|
import Uploads from './examples/Uploads';
|
2020-03-17 21:01:20 +00:00
|
|
|
import Injection from './examples/Injection';
|
2020-05-15 22:34:55 +00:00
|
|
|
import LocalPageLoad from './examples/LocalPageLoad';
|
2020-01-16 22:49:10 +00:00
|
|
|
|
2020-01-21 19:39:40 +00:00
|
|
|
const TESTS = {
|
2020-10-08 13:20:36 +00:00
|
|
|
Permission: {
|
|
|
|
title: 'Permission',
|
|
|
|
testId: 'permission',
|
|
|
|
description: 'Permission tests',
|
|
|
|
render() {
|
|
|
|
return <Permission />;
|
|
|
|
},
|
|
|
|
},
|
2020-01-21 19:39:40 +00:00
|
|
|
Alerts: {
|
|
|
|
title: 'Alerts',
|
|
|
|
testId: 'alerts',
|
|
|
|
description: 'Alerts tests',
|
|
|
|
render() {
|
|
|
|
return <Alerts />;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Scrolling: {
|
|
|
|
title: 'Scrolling',
|
|
|
|
testId: 'scrolling',
|
|
|
|
description: 'Scrolling event test',
|
|
|
|
render() {
|
|
|
|
return <Scrolling />;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Background: {
|
|
|
|
title: 'Background',
|
|
|
|
testId: 'background',
|
|
|
|
description: 'Background color test',
|
|
|
|
render() {
|
|
|
|
return <Background />;
|
|
|
|
},
|
|
|
|
},
|
2020-04-29 16:09:22 +00:00
|
|
|
Downloads: {
|
|
|
|
title: 'Downloads',
|
|
|
|
testId: 'downloads',
|
|
|
|
description: 'File downloads test',
|
|
|
|
render() {
|
|
|
|
return <Downloads />;
|
|
|
|
},
|
|
|
|
},
|
2020-02-19 02:40:30 +00:00
|
|
|
Uploads: {
|
|
|
|
title: 'Uploads',
|
|
|
|
testId: 'uploads',
|
|
|
|
description: 'Upload test',
|
|
|
|
render() {
|
|
|
|
return <Uploads />;
|
|
|
|
},
|
|
|
|
},
|
2020-03-17 21:01:20 +00:00
|
|
|
Injection: {
|
|
|
|
title: 'Injection',
|
|
|
|
testId: 'injection',
|
|
|
|
description: 'Injection test',
|
|
|
|
render() {
|
|
|
|
return <Injection />;
|
|
|
|
},
|
|
|
|
},
|
2020-05-15 22:34:55 +00:00
|
|
|
PageLoad: {
|
|
|
|
title: 'LocalPageLoad',
|
|
|
|
testId: 'LocalPageLoad',
|
|
|
|
description: 'Local Page load test',
|
|
|
|
render() {
|
|
|
|
return <LocalPageLoad />;
|
|
|
|
},
|
|
|
|
},
|
2020-01-16 22:49:10 +00:00
|
|
|
};
|
|
|
|
|
2020-01-21 19:39:40 +00:00
|
|
|
type Props = {};
|
|
|
|
type State = {restarting: boolean, currentTest: Object};
|
|
|
|
|
|
|
|
export default class App extends Component<Props, State> {
|
|
|
|
state = {
|
|
|
|
restarting: false,
|
|
|
|
currentTest: TESTS.Alerts,
|
|
|
|
};
|
|
|
|
|
|
|
|
_simulateRestart = () => {
|
|
|
|
this.setState({restarting: true}, () => this.setState({restarting: false}));
|
|
|
|
};
|
|
|
|
|
|
|
|
_changeTest = testName => {
|
|
|
|
this.setState({currentTest: TESTS[testName]});
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {restarting, currentTest} = this.state;
|
|
|
|
return (
|
|
|
|
<SafeAreaView style={styles.container}>
|
|
|
|
<TouchableOpacity
|
|
|
|
style={styles.closeKeyboardView}
|
|
|
|
onPress={() => Keyboard.dismiss()}
|
|
|
|
testID="closeKeyboard"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<TouchableOpacity
|
|
|
|
testID="restart_button"
|
|
|
|
onPress={this._simulateRestart}
|
|
|
|
style={styles.restartButton}
|
|
|
|
activeOpacity={0.6}>
|
|
|
|
<Text>Simulate Restart</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
|
|
<View style={styles.testPickerContainer}>
|
2020-10-08 13:20:36 +00:00
|
|
|
<Button
|
|
|
|
testID="testType_permission"
|
|
|
|
title="Permission"
|
|
|
|
onPress={() => this._changeTest('Permission')}
|
|
|
|
/>
|
2020-01-21 19:39:40 +00:00
|
|
|
<Button
|
|
|
|
testID="testType_alerts"
|
|
|
|
title="Alerts"
|
|
|
|
onPress={() => this._changeTest('Alerts')}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
testID="testType_scrolling"
|
|
|
|
title="Scrolling"
|
|
|
|
onPress={() => this._changeTest('Scrolling')}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
testID="testType_background"
|
|
|
|
title="Background"
|
|
|
|
onPress={() => this._changeTest('Background')}
|
|
|
|
/>
|
2020-03-17 21:01:20 +00:00
|
|
|
<Button
|
|
|
|
testID="testType_injection"
|
|
|
|
title="Injection"
|
|
|
|
onPress={() => this._changeTest('Injection')}
|
|
|
|
/>
|
2020-05-15 22:34:55 +00:00
|
|
|
<Button
|
|
|
|
testID="testType_pageLoad"
|
|
|
|
title="LocalPageLoad"
|
|
|
|
onPress={() => this._changeTest('PageLoad')}
|
|
|
|
/>
|
2020-04-29 16:09:22 +00:00
|
|
|
{Platform.OS == "ios" && <Button
|
|
|
|
testID="testType_downloads"
|
|
|
|
title="Downloads"
|
|
|
|
onPress={() => this._changeTest('Downloads')}
|
|
|
|
/>}
|
2020-02-19 02:40:30 +00:00
|
|
|
{Platform.OS === 'android' && <Button
|
|
|
|
testID="testType_uploads"
|
|
|
|
title="Uploads"
|
|
|
|
onPress={() => this._changeTest('Uploads')}
|
|
|
|
/>}
|
2020-01-21 19:39:40 +00:00
|
|
|
</View>
|
|
|
|
|
|
|
|
{restarting ? null : (
|
|
|
|
<View
|
|
|
|
testID={`example-${currentTest.testId}`}
|
|
|
|
key={currentTest.title}
|
|
|
|
style={styles.exampleContainer}>
|
|
|
|
<Text style={styles.exampleTitle}>{currentTest.title}</Text>
|
|
|
|
<Text style={styles.exampleDescription}>
|
|
|
|
{currentTest.description}
|
|
|
|
</Text>
|
|
|
|
<View style={styles.exampleInnerContainer}>
|
|
|
|
{currentTest.render()}
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
backgroundColor: '#F5FCFF',
|
|
|
|
padding: 8,
|
|
|
|
},
|
|
|
|
exampleContainer: {
|
|
|
|
padding: 16,
|
|
|
|
backgroundColor: '#FFF',
|
|
|
|
borderColor: '#EEE',
|
|
|
|
borderTopWidth: 1,
|
|
|
|
borderBottomWidth: 1,
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
exampleTitle: {
|
|
|
|
fontSize: 18,
|
|
|
|
},
|
|
|
|
exampleDescription: {
|
|
|
|
color: '#333333',
|
|
|
|
marginBottom: 16,
|
|
|
|
},
|
|
|
|
exampleInnerContainer: {
|
|
|
|
borderColor: '#EEE',
|
|
|
|
borderTopWidth: 1,
|
|
|
|
paddingTop: 10,
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
restartButton: {
|
|
|
|
padding: 6,
|
|
|
|
fontSize: 16,
|
|
|
|
borderRadius: 5,
|
|
|
|
backgroundColor: '#F3F3F3',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignSelf: 'flex-end',
|
|
|
|
},
|
|
|
|
closeKeyboardView: {
|
|
|
|
width: 5,
|
|
|
|
height: 5,
|
|
|
|
},
|
|
|
|
testPickerContainer: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
flexWrap: 'wrap',
|
|
|
|
},
|
|
|
|
});
|