mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
1490ab12ef
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.
find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.
Reviewed By: TheSavior, yungsters
Differential Revision: D7007050
fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
74 lines
1.8 KiB
JavaScript
74 lines
1.8 KiB
JavaScript
/**
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @providesModule LayoutEventsTestApp
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var React = require('React');
|
|
var View = require('View');
|
|
|
|
var RecordingModule = require('NativeModules').Recording;
|
|
|
|
const LAYOUT_SPECS = [
|
|
[10, 10, 100, 100],
|
|
[10, 10, 50, 50],
|
|
[0, 0, 50, 50],
|
|
[0, 0, 50, 50],
|
|
];
|
|
|
|
class LayoutEventsTestApp extends React.Component {
|
|
|
|
constructor() {
|
|
super();
|
|
this.state = {
|
|
specNumber: 0,
|
|
};
|
|
this.numParentLayouts = 0;
|
|
}
|
|
|
|
handleOnLayout = (e) => {
|
|
var layout = e.nativeEvent.layout;
|
|
RecordingModule.record(layout.x + ',' + layout.y + '-' + layout.width + 'x' + layout.height);
|
|
|
|
if (this.state.specNumber >= LAYOUT_SPECS.length) {
|
|
// This will cause the test to fail
|
|
RecordingModule.record('Got an extraneous layout call');
|
|
} else {
|
|
this.setState({
|
|
specNumber: this.state.specNumber + 1,
|
|
});
|
|
}
|
|
};
|
|
|
|
handleParentOnLayout = (e) => {
|
|
if (this.numParentLayouts > 0) {
|
|
// This will cause the test to fail - the parent's layout doesn't change
|
|
// so we should only get the event once.
|
|
RecordingModule.record('Got an extraneous layout call on the parent');
|
|
}
|
|
this.numParentLayouts++;
|
|
};
|
|
|
|
render() {
|
|
const layout = LAYOUT_SPECS[this.state.specNumber];
|
|
return (
|
|
<View
|
|
onLayout={this.handleParentOnLayout}
|
|
testID="parent"
|
|
style={{left: 0, top: 0, width: 500, height: 500}}>
|
|
<View
|
|
onLayout={this.handleOnLayout}
|
|
testID="container"
|
|
style={{left: layout[0], top: layout[1], width: layout[2], height: layout[3]}}/>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = LayoutEventsTestApp;
|