2015-11-19 21:32:37 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
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.
|
2018-05-10 22:44:55 +00:00
|
|
|
*
|
|
|
|
* @format
|
2015-11-19 21:32:37 +00:00
|
|
|
*/
|
2018-05-10 22:44:55 +00:00
|
|
|
|
2015-11-19 21:32:37 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const React = require('react');
|
|
|
|
const createReactClass = require('create-react-class');
|
|
|
|
const ReactNative = require('react-native');
|
|
|
|
const RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
|
|
|
|
const Subscribable = require('Subscribable');
|
|
|
|
const TimerMixin = require('react-timer-mixin');
|
2015-11-19 21:32:37 +00:00
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const {View} = ReactNative;
|
2015-11-19 21:32:37 +00:00
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const {TestModule} = ReactNative.NativeModules;
|
2015-11-19 21:32:37 +00:00
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const reactViewWidth = 101;
|
|
|
|
const reactViewHeight = 102;
|
|
|
|
const newReactViewWidth = 201;
|
|
|
|
const newReactViewHeight = 202;
|
2015-11-19 21:32:37 +00:00
|
|
|
|
2018-05-14 07:09:36 +00:00
|
|
|
const ReactContentSizeUpdateTest = createReactClass({
|
2017-07-07 21:24:25 +00:00
|
|
|
displayName: 'ReactContentSizeUpdateTest',
|
2018-05-10 22:44:55 +00:00
|
|
|
mixins: [Subscribable.Mixin, TimerMixin],
|
2015-11-19 21:32:37 +00:00
|
|
|
|
2018-02-08 18:26:45 +00:00
|
|
|
UNSAFE_componentWillMount: function() {
|
2015-11-19 21:32:37 +00:00
|
|
|
this.addListenerOn(
|
|
|
|
RCTNativeAppEventEmitter,
|
|
|
|
'rootViewDidChangeIntrinsicSize',
|
2018-05-10 22:44:55 +00:00
|
|
|
this.rootViewDidChangeIntrinsicSize,
|
2015-11-19 21:32:37 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
height: reactViewHeight,
|
|
|
|
width: reactViewWidth,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
updateViewSize: function() {
|
|
|
|
this.setState({
|
|
|
|
height: newReactViewHeight,
|
|
|
|
width: newReactViewWidth,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
2018-05-10 22:44:55 +00:00
|
|
|
this.setTimeout(() => {
|
|
|
|
this.updateViewSize();
|
|
|
|
}, 1000);
|
2015-11-19 21:32:37 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
rootViewDidChangeIntrinsicSize: function(intrinsicSize) {
|
2018-05-10 22:44:55 +00:00
|
|
|
if (
|
|
|
|
intrinsicSize.height === newReactViewHeight &&
|
|
|
|
intrinsicSize.width === newReactViewWidth
|
|
|
|
) {
|
2015-11-19 21:32:37 +00:00
|
|
|
TestModule.markTestPassed(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2018-05-10 22:44:55 +00:00
|
|
|
<View style={{height: this.state.height, width: this.state.width}} />
|
2015-11-19 21:32:37 +00:00
|
|
|
);
|
2018-05-10 22:44:55 +00:00
|
|
|
},
|
2015-11-19 21:32:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
ReactContentSizeUpdateTest.displayName = 'ReactContentSizeUpdateTest';
|
|
|
|
|
|
|
|
module.exports = ReactContentSizeUpdateTest;
|