mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
add fantom test for view culling inside <Modal /> (#49860)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49860 changelog: [internal] now that Fantom supports tests with <Modal />, add a test to cover scenario where <ScrollView /> is inside of <Modal />. Reviewed By: rubennorte, rshest Differential Revision: D70696834 fbshipit-source-id: 5f51917ac5c6a2cf451906e302ee2b62c15449ea
This commit is contained in:
committed by
Facebook GitHub Bot
parent
faafd8c2a8
commit
eeef060762
Vendored
+67
@@ -14,6 +14,7 @@
|
||||
import '../../../Core/InitializeCore.js';
|
||||
import ensureInstance from '../../../../src/private/utilities/ensureInstance';
|
||||
import ReactNativeElement from '../../../../src/private/webapis/dom/nodes/ReactNativeElement';
|
||||
import Modal from '../../../Modal/Modal';
|
||||
import View from '../../View/View';
|
||||
import ScrollView from '../ScrollView';
|
||||
import Fantom from '@react-native/fantom';
|
||||
@@ -949,3 +950,69 @@ test('view flattening with culling', () => {
|
||||
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
|
||||
]);
|
||||
});
|
||||
|
||||
test('culling inside of Modal', () => {
|
||||
const root = Fantom.createRoot({viewportWidth: 100, viewportHeight: 100});
|
||||
let maybeNode;
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(
|
||||
// <ScrollView /> is scrolled down and if it wasn't for the Modal,
|
||||
// the content would be culled.
|
||||
<ScrollView
|
||||
contentOffset={{x: 0, y: 100}}
|
||||
style={{height: 100, width: 100}}>
|
||||
<Modal
|
||||
ref={(node: ?React.ElementRef<typeof Modal>) => {
|
||||
maybeNode = node;
|
||||
}}
|
||||
/>
|
||||
</ScrollView>,
|
||||
);
|
||||
});
|
||||
|
||||
const element = ensureInstance(maybeNode, ReactNativeElement);
|
||||
|
||||
Fantom.runOnUIThread(() => {
|
||||
Fantom.enqueueModalSizeUpdate(element, {
|
||||
width: 100,
|
||||
height: 100,
|
||||
});
|
||||
});
|
||||
Fantom.runWorkLoop();
|
||||
|
||||
expect(root.takeMountingManagerLogs()).toEqual([
|
||||
'Update {type: "RootView", nativeID: (root)}',
|
||||
'Create {type: "ScrollView", nativeID: (N/A)}',
|
||||
'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}',
|
||||
'Create {type: "View", nativeID: (N/A)}',
|
||||
'Create {type: "ModalHostView", nativeID: (root)}',
|
||||
'Create {type: "View", nativeID: (N/A)}',
|
||||
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
|
||||
'Insert {type: "ModalHostView", parentNativeID: (N/A), index: 0, nativeID: (root)}',
|
||||
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}',
|
||||
]);
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(
|
||||
<ScrollView
|
||||
contentOffset={{x: 0, y: 100}}
|
||||
style={{height: 100, width: 100}}>
|
||||
<Modal
|
||||
ref={(node: ?React.ElementRef<typeof Modal>) => {
|
||||
maybeNode = node;
|
||||
}}>
|
||||
<View
|
||||
nativeID={'child'}
|
||||
style={{height: 10, width: 10, marginTop: 45}}
|
||||
/>
|
||||
</Modal>
|
||||
</ScrollView>,
|
||||
);
|
||||
});
|
||||
|
||||
expect(root.takeMountingManagerLogs()).toEqual([
|
||||
'Create {type: "View", nativeID: "child"}',
|
||||
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user