2015-03-25 02:34:12 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-03-25 02:34:12 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-11-18 16:25:30 +00:00
|
|
|
*
|
2018-05-10 22:44:55 +00:00
|
|
|
* @format
|
2015-11-18 16:25:30 +00:00
|
|
|
* @flow
|
2015-03-25 02:34:12 +00:00
|
|
|
*/
|
2018-05-10 22:44:55 +00:00
|
|
|
|
2015-03-25 02:34:12 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const React = require('react');
|
|
|
|
const ReactNative = require('react-native');
|
2017-09-06 10:25:01 +00:00
|
|
|
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
|
|
|
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
|
|
|
* run Flow. */
|
2018-05-14 07:09:36 +00:00
|
|
|
const requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
|
2015-11-18 16:25:30 +00:00
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const {StyleSheet, View} = ReactNative;
|
|
|
|
const {TestModule} = ReactNative.NativeModules;
|
2015-03-25 02:34:12 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class SimpleSnapshotTest extends React.Component<{}> {
|
2015-03-25 02:34:12 +00:00
|
|
|
componentDidMount() {
|
|
|
|
if (!TestModule.verifySnapshot) {
|
|
|
|
throw new Error('TestModule.verifySnapshot not defined.');
|
|
|
|
}
|
|
|
|
requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-03-25 02:34:12 +00:00
|
|
|
|
2018-05-10 22:44:55 +00:00
|
|
|
done = (success: boolean) => {
|
2015-06-17 14:09:23 +00:00
|
|
|
TestModule.markTestPassed(success);
|
2016-07-26 08:00:02 +00:00
|
|
|
};
|
2015-03-25 02:34:12 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<View style={{backgroundColor: 'white', padding: 100}}>
|
|
|
|
<View style={styles.box1} />
|
|
|
|
<View style={styles.box2} />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-03-25 02:34:12 +00:00
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const styles = StyleSheet.create({
|
2015-03-25 02:34:12 +00:00
|
|
|
box1: {
|
|
|
|
width: 80,
|
|
|
|
height: 50,
|
|
|
|
backgroundColor: 'red',
|
|
|
|
},
|
|
|
|
box2: {
|
|
|
|
top: -10,
|
|
|
|
left: 20,
|
|
|
|
width: 70,
|
|
|
|
height: 90,
|
|
|
|
backgroundColor: 'blue',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2015-06-24 02:12:51 +00:00
|
|
|
SimpleSnapshotTest.displayName = 'SimpleSnapshotTest';
|
|
|
|
|
2015-03-25 02:34:12 +00:00
|
|
|
module.exports = SimpleSnapshotTest;
|