2015-10-19 20:24:01 +03:00
|
|
|
/**
|
2021-12-31 02:08:43 +03:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2015-10-19 20:24:01 +03:00
|
|
|
*
|
2018-02-17 05:24:55 +03: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 19:25:30 +03:00
|
|
|
*
|
2018-05-11 01:44:55 +03:00
|
|
|
* @format
|
2018-08-09 18:32:04 +03:00
|
|
|
* @flow strict-local
|
2015-10-19 20:24:01 +03:00
|
|
|
*/
|
2018-05-11 01:44:55 +03:00
|
|
|
|
2015-10-19 20:24:01 +03:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-14 10:09:36 +03:00
|
|
|
const React = require('react');
|
|
|
|
const ReactNative = require('react-native');
|
2018-11-04 21:39:44 +03:00
|
|
|
const {Image} = ReactNative;
|
2018-05-14 10:09:36 +03:00
|
|
|
const {TestModule} = ReactNative.NativeModules;
|
2015-10-19 20:24:01 +03:00
|
|
|
|
2019-11-21 20:38:13 +03:00
|
|
|
class ImageSnapshotTest extends React.Component<{...}> {
|
2022-08-03 22:43:58 +03:00
|
|
|
componentDidMount(): void {
|
2015-10-19 20:24:01 +03:00
|
|
|
if (!TestModule.verifySnapshot) {
|
|
|
|
throw new Error('TestModule.verifySnapshot not defined.');
|
|
|
|
}
|
2016-07-26 11:00:02 +03:00
|
|
|
}
|
2015-10-19 20:24:01 +03:00
|
|
|
|
2019-08-09 20:06:53 +03:00
|
|
|
done: (success: boolean) => void = (success: boolean) => {
|
2015-10-19 20:24:01 +03:00
|
|
|
TestModule.markTestPassed(success);
|
2016-07-26 11:00:02 +03:00
|
|
|
};
|
2015-10-19 20:24:01 +03:00
|
|
|
|
2019-08-09 20:06:53 +03:00
|
|
|
render(): React.Node {
|
2015-10-19 20:24:01 +03:00
|
|
|
return (
|
|
|
|
<Image
|
2016-11-23 08:01:34 +03:00
|
|
|
source={require('./blue_square.png')}
|
|
|
|
defaultSource={require('./red_square.png')}
|
2018-05-11 01:44:55 +03:00
|
|
|
onLoad={() => TestModule.verifySnapshot(this.done)}
|
|
|
|
/>
|
2015-10-19 20:24:01 +03:00
|
|
|
);
|
|
|
|
}
|
2016-07-26 11:00:02 +03:00
|
|
|
}
|
2015-10-19 20:24:01 +03:00
|
|
|
|
|
|
|
ImageSnapshotTest.displayName = 'ImageSnapshotTest';
|
|
|
|
|
|
|
|
module.exports = ImageSnapshotTest;
|