Refactor InterruptibleRendering Fantom test to use dispatchNativeEvent (#50957)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50957

Changelog: [internal]

Now we can use the higher level API for event dispatching in this test.

Reviewed By: javache

Differential Revision: D73663626

fbshipit-source-id: 961af26f62128f093c71ad14f457ac8544348415
This commit is contained in:
Rubén Norte
2025-04-28 06:55:25 -07:00
committed by Facebook GitHub Bot
parent a120c5c4db
commit 9ae7f7fcc1
2 changed files with 25 additions and 27 deletions
+3 -1
View File
@@ -348,7 +348,9 @@ export function dispatchNativeEvent(
enqueueNativeEvent(node, type, payload, options);
});
runWorkLoop();
if (!flushingQueue) {
runWorkLoop();
}
}
export type ScrollEventOptions = {
@@ -43,18 +43,16 @@ describe('discrete event category', () => {
if (interruptRendering) {
interruptRendering = false;
const element = ensureReactNativeElement(textInputRef.current);
Fantom.runOnUIThread(() => {
Fantom.enqueueNativeEvent(
element,
'change',
{
text: 'update from native',
},
{
category: NativeEventCategory.Discrete,
},
);
});
Fantom.dispatchNativeEvent(
element,
'change',
{
text: 'update from native',
},
{
category: NativeEventCategory.Discrete,
},
);
// We must schedule a task that is run right after the above native event is
// processed to be able to observe the results of rendering.
Fantom.scheduleTask(afterUpdate);
@@ -149,21 +147,19 @@ describe('continuous event category', () => {
if (interruptRendering) {
interruptRendering = false;
const element = ensureReactNativeElement(textInputRef.current);
Fantom.runOnUIThread(() => {
Fantom.enqueueNativeEvent(
element,
'selectionChange',
{
selection: {
start: 1,
end: 5,
},
Fantom.dispatchNativeEvent(
element,
'selectionChange',
{
selection: {
start: 1,
end: 5,
},
{
category: NativeEventCategory.Continuous,
},
);
});
},
{
category: NativeEventCategory.Continuous,
},
);
}
useEffect(() => {
effectMock({text, deferredText});