2015-10-19 17:24:01 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-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.
|
2015-11-18 16:25:30 +00:00
|
|
|
*
|
|
|
|
* @flow
|
2015-10-19 17:24:01 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-04-09 03:36:40 +00:00
|
|
|
var React = require('react');
|
|
|
|
var ReactNative = require('react-native');
|
2015-10-19 17:24:01 +00:00
|
|
|
var {
|
|
|
|
Image,
|
|
|
|
View,
|
2016-04-09 03:36:40 +00:00
|
|
|
} = ReactNative;
|
|
|
|
var { TestModule } = ReactNative.NativeModules;
|
2015-10-19 17:24:01 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
class ImageSnapshotTest extends React.Component {
|
2015-10-19 17:24:01 +00:00
|
|
|
componentDidMount() {
|
|
|
|
if (!TestModule.verifySnapshot) {
|
|
|
|
throw new Error('TestModule.verifySnapshot not defined.');
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-10-19 17:24:01 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
done = (success : boolean) => {
|
2015-10-19 17:24:01 +00:00
|
|
|
TestModule.markTestPassed(success);
|
2016-07-26 08:00:02 +00:00
|
|
|
};
|
2015-10-19 17:24:01 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Image
|
2016-11-23 05:01:34 +00:00
|
|
|
source={require('./blue_square.png')}
|
|
|
|
defaultSource={require('./red_square.png')}
|
2015-10-19 17:24:01 +00:00
|
|
|
onLoad={() => TestModule.verifySnapshot(this.done)} />
|
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-10-19 17:24:01 +00:00
|
|
|
|
|
|
|
ImageSnapshotTest.displayName = 'ImageSnapshotTest';
|
|
|
|
|
|
|
|
module.exports = ImageSnapshotTest;
|