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';
|
|
|
|
|
|
|
|
var React = require('react-native');
|
|
|
|
var {
|
|
|
|
Image,
|
|
|
|
View,
|
|
|
|
} = React;
|
2015-11-18 16:25:30 +00:00
|
|
|
var { TestModule } = React.NativeModules;
|
2015-10-19 17:24:01 +00:00
|
|
|
|
|
|
|
var ImageSnapshotTest = React.createClass({
|
|
|
|
componentDidMount() {
|
|
|
|
if (!TestModule.verifySnapshot) {
|
|
|
|
throw new Error('TestModule.verifySnapshot not defined.');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-11-18 16:25:30 +00:00
|
|
|
done(success : boolean) {
|
2015-10-19 17:24:01 +00:00
|
|
|
TestModule.markTestPassed(success);
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Image
|
|
|
|
source={require('image!blue_square')}
|
|
|
|
defaultSource={require('image!red_square')}
|
|
|
|
onLoad={() => TestModule.verifySnapshot(this.done)} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ImageSnapshotTest.displayName = 'ImageSnapshotTest';
|
|
|
|
|
|
|
|
module.exports = ImageSnapshotTest;
|