From 80575402497fb8cad9b43eace3e6ac2f8b1e06dd Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Mon, 8 Jul 2024 17:05:05 +0200 Subject: [PATCH 1/9] Mock window dimensions --- .../RuntimeTestsApi.ts | 8 +++ .../TestRunner.ts | 54 ++++++++++++++++++- .../ReanimatedRuntimeTestsRunner/types.ts | 10 +++- .../entering/predefinedEntering.test.tsx | 7 ++- packages/react-native-reanimated/src/index.ts | 3 ++ .../animationBuilder/commonTypes.ts | 2 +- .../animationBuilder/index.ts | 1 + .../layoutReanimation/animationsManager.ts | 6 ++- 8 files changed, 86 insertions(+), 5 deletions(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts index 1de8953de76a..c7cd06be3d68 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts @@ -180,6 +180,14 @@ export async function unmockAnimationTimer() { await testRunner.unmockAnimationTimer(); } +export async function mockWindowSize() { + await testRunner.mockWindowSize(); +} + +export async function unmockWindowSize() { + await testRunner.unmockWindowSize(); +} + export async function setAnimationTimestamp(timestamp: number) { await testRunner.setAnimationTimestamp(timestamp); } diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index 498a8e8af009..3f1a6776e1c1 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -16,11 +16,18 @@ import type { import { ComparisonMode, DescribeDecorator, TestDecorator } from './types'; import { TestComponent } from './TestComponent'; import { EMPTY_LOG_PLACEHOLDER, applyMarkdown, color, formatString, indentNestingLevel } from './stringFormatUtils'; -import type { SharedValue } from 'react-native-reanimated'; +import type { + SharedValue, + LayoutAnimationStartFunction, + LayoutAnimationType, + SharedTransitionAnimationsValues, + LayoutAnimation, +} from 'react-native-reanimated'; import { makeMutable, runOnUI, runOnJS } from 'react-native-reanimated'; import { Matchers, nullableMatch } from './matchers/Matchers'; import { assertMockedAnimationTimestamp, assertTestCase, assertTestSuite } from './Asserts'; import { createUpdatesContainer } from './UpdatesContainer'; +export { Presets } from './Presets'; let callTrackerRegistryJS: Record = {}; const callTrackerRegistryUI = makeMutable>({}); @@ -558,6 +565,51 @@ export class TestRunner { }); } + public async unmockWindowSize() { + await this.runOnUIBlocking(() => { + 'worklet'; + if (global._LayoutAnimationsManager) { + global.LayoutAnimationsManager = global._LayoutAnimationsManager; + } + }); + } + + public async mockWindowSize() { + await this.runOnUIBlocking(() => { + 'worklet'; + const originalCreateAnimatedComponent = global.LayoutAnimationsManager; + + const createAnimatedComponentOnStart: LayoutAnimationStartFunction = ( + tag: number, + type: LayoutAnimationType, + _yogaValues: Partial, + config: (arg: Partial) => LayoutAnimation, + ) => { + originalCreateAnimatedComponent.start( + tag, + type, + { + targetGlobalOriginX: 40, + targetGlobalOriginY: 175.3333346048991, + targetHeight: 80.00000762939453, + targetOriginX: 40, + targetOriginY: 40, + targetWidth: 313, + windowHeight: 852, + windowWidth: 393, + }, + config, + ); + }; + + global._LayoutAnimationsManager = originalCreateAnimatedComponent; + global.LayoutAnimationsManager = { + start: createAnimatedComponentOnStart, + stop: originalCreateAnimatedComponent.stop, + }; + }); + } + public wait(delay: number) { return new Promise(resolve => { setTimeout(resolve, delay); diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts index 1e2f5cd5d385..1c6b46c4574a 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts @@ -1,5 +1,5 @@ import type { Component, Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react'; -import type { AnimatedStyle, StyleProps } from 'react-native-reanimated'; +import type { AnimatedStyle, StyleProps, LayoutAnimationStartFunction } from 'react-native-reanimated'; export type CallTracker = { UICallsCount: number; @@ -137,6 +137,14 @@ declare global { var _obtainPropPaper: (viewTag: number, propName: string) => string; var _obtainPropFabric: (shadowNodeWrapper: unknown, propName: string) => string; var __flushAnimationFrame: (frameTimestamp: number) => void; + var LayoutAnimationsManager: { + start: LayoutAnimationStartFunction; + stop: (tag: number) => void; + }; + var _LayoutAnimationsManager: { + start: LayoutAnimationStartFunction; + stop: (tag: number) => void; + }; } /* eslint-enable no-var */ diff --git a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx index 36cbd211e0e1..38c21e4c7efa 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx @@ -51,6 +51,8 @@ import { wait, unmockAnimationTimer, clearRenderOutput, + mockWindowSize, + unmockWindowSize, } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi'; import { DurationEnteringSnapshots, @@ -101,6 +103,7 @@ const EnteringOnMountComponent = ({ entering }: { entering: any }) => { async function getSnapshotUpdates(entering: any, waitTime: number, duration: number | undefined, springify = false) { await mockAnimationTimer(); + await mockWindowSize(); const updatesContainer = await recordAnimationUpdates(); const springEntering = springify ? entering : entering.springify(); @@ -109,13 +112,15 @@ async function getSnapshotUpdates(entering: any, waitTime: number, duration: num await render(); await wait(waitTime); const updates = updatesContainer.getUpdates(); + await unmockAnimationTimer(); + await unmockWindowSize(); await clearRenderOutput(); return updates; } -describe('Test predefined entering', () => { +describe.only('Test predefined entering', () => { describe('Entering on mount, no modifiers', () => { test.each(ENTERING_SETS)('Test suite of ${0}In', async ([_setName, enteringSet, waitTime]) => { for (const entering of enteringSet) { diff --git a/packages/react-native-reanimated/src/index.ts b/packages/react-native-reanimated/src/index.ts index 03b213772359..fb600b390779 100644 --- a/packages/react-native-reanimated/src/index.ts +++ b/packages/react-native-reanimated/src/index.ts @@ -118,6 +118,9 @@ export type { EntryExitAnimationFunction, LayoutAnimationsValues, LayoutAnimationFunction, + LayoutAnimationStartFunction, + LayoutAnimationType, + SharedTransitionAnimationsValues, ILayoutAnimationBuilder, IEntryExitAnimationBuilder, } from './layoutReanimation'; diff --git a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/commonTypes.ts b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/commonTypes.ts index 8ea5d5bb11ed..d18a1d9737fb 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/commonTypes.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/commonTypes.ts @@ -80,7 +80,7 @@ export type LayoutAnimationStartFunction = ( tag: number, type: LayoutAnimationType, yogaValues: Partial, - config: LayoutAnimationFunction + config: (arg: Partial) => LayoutAnimation ) => void; export interface ILayoutAnimationBuilder { diff --git a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/index.ts b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/index.ts index 75a8208704b1..5683e79459aa 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/index.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/index.ts @@ -20,4 +20,5 @@ export type { BaseBuilderAnimationConfig, LayoutAnimationAndConfig, IEntryExitAnimationBuilder, + SharedTransitionAnimationsValues, } from './commonTypes'; diff --git a/packages/react-native-reanimated/src/layoutReanimation/animationsManager.ts b/packages/react-native-reanimated/src/layoutReanimation/animationsManager.ts index bb9bd1750ca9..6ef89804a43c 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/animationsManager.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/animationsManager.ts @@ -7,6 +7,7 @@ import { runOnUIImmediately } from '../threads'; import type { SharedTransitionAnimationsValues, LayoutAnimation, + LayoutAnimationStartFunction, } from './animationBuilder/commonTypes'; const TAG_OFFSET = 1e9; @@ -34,7 +35,10 @@ function stopObservingProgress( global._notifyAboutEnd(tag, removeView); } -function createLayoutAnimationManager() { +function createLayoutAnimationManager(): { + start: LayoutAnimationStartFunction; + stop: (tag: number) => void; +} { 'worklet'; const currentAnimationForTag = new Map(); const mutableValuesForTag = new Map(); From 1cfae972c59b5fd48dc8d76474fc7690aa7d33b5 Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 9 Jul 2024 11:36:02 +0200 Subject: [PATCH 2/9] Mock window size --- .../ReanimatedRuntimeTestsRunner/TestRunner.ts | 7 +------ .../layoutAnimations/entering/predefinedEntering.test.tsx | 2 +- .../layoutAnimations/exiting/predefinedExiting.test.tsx | 5 +++++ .../layout/predefinedLayoutPosition.test.tsx | 5 +++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index 3f1a6776e1c1..c36de0687c6c 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -589,12 +589,7 @@ export class TestRunner { tag, type, { - targetGlobalOriginX: 40, - targetGlobalOriginY: 175.3333346048991, - targetHeight: 80.00000762939453, - targetOriginX: 40, - targetOriginY: 40, - targetWidth: 313, + ..._yogaValues, windowHeight: 852, windowWidth: 393, }, diff --git a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx index 38c21e4c7efa..fe0ffe0977ad 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx @@ -120,7 +120,7 @@ async function getSnapshotUpdates(entering: any, waitTime: number, duration: num return updates; } -describe.only('Test predefined entering', () => { +describe('Test predefined entering', () => { describe('Entering on mount, no modifiers', () => { test.each(ENTERING_SETS)('Test suite of ${0}In', async ([_setName, enteringSet, waitTime]) => { for (const entering of enteringSet) { diff --git a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx index 1546ff6442a0..71728f1c362c 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx @@ -51,6 +51,8 @@ import { wait, unmockAnimationTimer, clearRenderOutput, + mockWindowSize, + unmockWindowSize, } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi'; import { DurationExitingSnapshots, NoModifierExitingSnapshots, SpringifyExitingSnapshots } from './exiting.snapshot'; @@ -99,6 +101,7 @@ const ExitingComponent = ({ exiting }: { exiting: any }) => { async function getSnapshotUpdates(exiting: any, waitTime: number, duration: number | undefined, springify = false) { await mockAnimationTimer(); + await mockWindowSize(); const updatesContainer = await recordAnimationUpdates(); const springExiting = springify ? exiting : exiting.springify(); @@ -108,7 +111,9 @@ async function getSnapshotUpdates(exiting: any, waitTime: number, duration: numb await wait(waitTime); const updates = updatesContainer.getUpdates(); + await unmockAnimationTimer(); + await unmockWindowSize(); await clearRenderOutput(); return updates; diff --git a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx index 6765d835a45f..548a84e47a8e 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx @@ -18,6 +18,8 @@ import { unmockAnimationTimer, clearRenderOutput, getTestComponent, + mockWindowSize, + unmockWindowSize, } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi'; import { CurvedSnapshot, @@ -32,6 +34,7 @@ import { Direction, TransitionUpOrDown, TransitionLeftOrRight, TRANSITION_REF } async function getSnapshotUpdates(layout: any, direction: Direction, waitTime: number) { await mockAnimationTimer(); + await mockWindowSize(); const updatesContainer = await recordAnimationUpdates(); if (direction === Direction.UP || direction === Direction.DOWN) { @@ -42,7 +45,9 @@ async function getSnapshotUpdates(layout: any, direction: Direction, waitTime: n await wait(waitTime); const component = getTestComponent(TRANSITION_REF); const updates = updatesContainer.getUpdates(component); + await unmockAnimationTimer(); + await unmockWindowSize(); await clearRenderOutput(); return updates; From 17146adceb0ca44a96c219762b814c9d11fd2df2 Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 9 Jul 2024 11:36:51 +0200 Subject: [PATCH 3/9] Rename size to dimensions --- .../ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts | 8 ++++---- .../ReanimatedRuntimeTestsRunner/TestRunner.ts | 4 ++-- .../layoutAnimations/entering/predefinedEntering.test.tsx | 8 ++++---- .../layoutAnimations/exiting/predefinedExiting.test.tsx | 8 ++++---- .../layout/predefinedLayoutPosition.test.tsx | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts index c7cd06be3d68..2911aa97b779 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/RuntimeTestsApi.ts @@ -180,12 +180,12 @@ export async function unmockAnimationTimer() { await testRunner.unmockAnimationTimer(); } -export async function mockWindowSize() { - await testRunner.mockWindowSize(); +export async function mockWindowDimensions() { + await testRunner.mockWindowDimensions(); } -export async function unmockWindowSize() { - await testRunner.unmockWindowSize(); +export async function unmockWindowDimensions() { + await testRunner.unmockWindowDimensions(); } export async function setAnimationTimestamp(timestamp: number) { diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index c36de0687c6c..31008ce3ac80 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -565,7 +565,7 @@ export class TestRunner { }); } - public async unmockWindowSize() { + public async unmockWindowDimensions() { await this.runOnUIBlocking(() => { 'worklet'; if (global._LayoutAnimationsManager) { @@ -574,7 +574,7 @@ export class TestRunner { }); } - public async mockWindowSize() { + public async mockWindowDimensions() { await this.runOnUIBlocking(() => { 'worklet'; const originalCreateAnimatedComponent = global.LayoutAnimationsManager; diff --git a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx index fe0ffe0977ad..966939630055 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx @@ -51,8 +51,8 @@ import { wait, unmockAnimationTimer, clearRenderOutput, - mockWindowSize, - unmockWindowSize, + mockWindowDimensions, + unmockWindowDimensions, } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi'; import { DurationEnteringSnapshots, @@ -103,7 +103,7 @@ const EnteringOnMountComponent = ({ entering }: { entering: any }) => { async function getSnapshotUpdates(entering: any, waitTime: number, duration: number | undefined, springify = false) { await mockAnimationTimer(); - await mockWindowSize(); + await mockWindowDimensions(); const updatesContainer = await recordAnimationUpdates(); const springEntering = springify ? entering : entering.springify(); @@ -114,7 +114,7 @@ async function getSnapshotUpdates(entering: any, waitTime: number, duration: num const updates = updatesContainer.getUpdates(); await unmockAnimationTimer(); - await unmockWindowSize(); + await unmockWindowDimensions(); await clearRenderOutput(); return updates; diff --git a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx index 71728f1c362c..231b1d2dcb8e 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/exiting/predefinedExiting.test.tsx @@ -51,8 +51,8 @@ import { wait, unmockAnimationTimer, clearRenderOutput, - mockWindowSize, - unmockWindowSize, + mockWindowDimensions, + unmockWindowDimensions, } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi'; import { DurationExitingSnapshots, NoModifierExitingSnapshots, SpringifyExitingSnapshots } from './exiting.snapshot'; @@ -101,7 +101,7 @@ const ExitingComponent = ({ exiting }: { exiting: any }) => { async function getSnapshotUpdates(exiting: any, waitTime: number, duration: number | undefined, springify = false) { await mockAnimationTimer(); - await mockWindowSize(); + await mockWindowDimensions(); const updatesContainer = await recordAnimationUpdates(); const springExiting = springify ? exiting : exiting.springify(); @@ -113,7 +113,7 @@ async function getSnapshotUpdates(exiting: any, waitTime: number, duration: numb const updates = updatesContainer.getUpdates(); await unmockAnimationTimer(); - await unmockWindowSize(); + await unmockWindowDimensions(); await clearRenderOutput(); return updates; diff --git a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx index 548a84e47a8e..1a231591b013 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/layoutAnimations/layout/predefinedLayoutPosition.test.tsx @@ -18,8 +18,8 @@ import { unmockAnimationTimer, clearRenderOutput, getTestComponent, - mockWindowSize, - unmockWindowSize, + mockWindowDimensions, + unmockWindowDimensions, } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi'; import { CurvedSnapshot, @@ -34,7 +34,7 @@ import { Direction, TransitionUpOrDown, TransitionLeftOrRight, TRANSITION_REF } async function getSnapshotUpdates(layout: any, direction: Direction, waitTime: number) { await mockAnimationTimer(); - await mockWindowSize(); + await mockWindowDimensions(); const updatesContainer = await recordAnimationUpdates(); if (direction === Direction.UP || direction === Direction.DOWN) { @@ -47,7 +47,7 @@ async function getSnapshotUpdates(layout: any, direction: Direction, waitTime: n const updates = updatesContainer.getUpdates(component); await unmockAnimationTimer(); - await unmockWindowSize(); + await unmockWindowDimensions(); await clearRenderOutput(); return updates; From 099b72f29e3b864a558637282141c35eb2476ef9 Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 16 Jul 2024 10:17:49 +0200 Subject: [PATCH 4/9] Code review --- .../ReanimatedRuntimeTestsRunner/TestRunner.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index 31008ce3ac80..e51b8de6e5cd 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -577,7 +577,7 @@ export class TestRunner { public async mockWindowDimensions() { await this.runOnUIBlocking(() => { 'worklet'; - const originalCreateAnimatedComponent = global.LayoutAnimationsManager; + const originalLayoutAnimationsManager = global.LayoutAnimationsManager; const createAnimatedComponentOnStart: LayoutAnimationStartFunction = ( tag: number, @@ -585,7 +585,7 @@ export class TestRunner { _yogaValues: Partial, config: (arg: Partial) => LayoutAnimation, ) => { - originalCreateAnimatedComponent.start( + originalLayoutAnimationsManager.start( tag, type, { @@ -597,10 +597,10 @@ export class TestRunner { ); }; - global._LayoutAnimationsManager = originalCreateAnimatedComponent; + global._LayoutAnimationsManager = originalLayoutAnimationsManager; global.LayoutAnimationsManager = { start: createAnimatedComponentOnStart, - stop: originalCreateAnimatedComponent.stop, + stop: originalLayoutAnimationsManager.stop, }; }); } From c4f432af9be84e6593bf7af6df94945e8cad779b Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 16 Jul 2024 10:31:39 +0200 Subject: [PATCH 5/9] Fix merge --- .../RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index 391abe7201c2..e370f6141368 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -25,7 +25,7 @@ import type { import { Matchers, nullableMatch } from './matchers/Matchers'; import { assertMockedAnimationTimestamp, assertTestCase, assertTestSuite } from './Asserts'; import { createUpdatesContainer } from './UpdatesContainer'; -import { makeMutable, runOnJS, makeMutable, runOnJS } from 'react-native-reanimated'; +import { makeMutable, runOnJS } from 'react-native-reanimated'; import { RenderLock, SyncUIRunner } from './SyncUIRunner'; export { Presets } from './Presets'; From 1057330d8ee938d572beff3b48fa6e91b6a33810 Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 16 Jul 2024 10:36:43 +0200 Subject: [PATCH 6/9] Fix merge --- .../RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index e370f6141368..73338eb5adbc 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -509,7 +509,7 @@ export class TestRunner { } public async unmockWindowDimensions() { - await this.runOnUIBlocking(() => { + await this._syncUIRunner.runOnUIBlocking(() => { 'worklet'; if (global._LayoutAnimationsManager) { global.LayoutAnimationsManager = global._LayoutAnimationsManager; @@ -518,7 +518,7 @@ export class TestRunner { } public async mockWindowDimensions() { - await this.runOnUIBlocking(() => { + await this._syncUIRunner.runOnUIBlocking(() => { 'worklet'; const originalLayoutAnimationsManager = global.LayoutAnimationsManager; From a6fcea5f0e3d3db03ba0ffd1e8b068a2d1513e2a Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 16 Jul 2024 11:23:52 +0200 Subject: [PATCH 7/9] Code review --- .../RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index 73338eb5adbc..ac8638ccbb09 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -522,7 +522,7 @@ export class TestRunner { 'worklet'; const originalLayoutAnimationsManager = global.LayoutAnimationsManager; - const createAnimatedComponentOnStart: LayoutAnimationStartFunction = ( + const startLayoutAnimation: LayoutAnimationStartFunction = ( tag: number, type: LayoutAnimationType, _yogaValues: Partial, @@ -542,7 +542,7 @@ export class TestRunner { global._LayoutAnimationsManager = originalLayoutAnimationsManager; global.LayoutAnimationsManager = { - start: createAnimatedComponentOnStart, + start: startLayoutAnimation, stop: originalLayoutAnimationsManager.stop, }; }); From efa229e0dc4f425b164aaa7e80dc75472ca59080 Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 16 Jul 2024 13:12:33 +0200 Subject: [PATCH 8/9] Code review --- .../RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts | 4 ++-- .../RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index ac8638ccbb09..e992bc93db44 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -511,7 +511,7 @@ export class TestRunner { public async unmockWindowDimensions() { await this._syncUIRunner.runOnUIBlocking(() => { 'worklet'; - if (global._LayoutAnimationsManager) { + if (global.originalLayoutAnimationsManager) { global.LayoutAnimationsManager = global._LayoutAnimationsManager; } }); @@ -540,7 +540,7 @@ export class TestRunner { ); }; - global._LayoutAnimationsManager = originalLayoutAnimationsManager; + global.originalLayoutAnimationsManager = originalLayoutAnimationsManager; global.LayoutAnimationsManager = { start: startLayoutAnimation, stop: originalLayoutAnimationsManager.stop, diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts index 1c6b46c4574a..bd40d2f4110d 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/types.ts @@ -141,7 +141,7 @@ declare global { start: LayoutAnimationStartFunction; stop: (tag: number) => void; }; - var _LayoutAnimationsManager: { + var originalLayoutAnimationsManager: { start: LayoutAnimationStartFunction; stop: (tag: number) => void; }; From a029adf49921f3e16fd615151d27ca7d047f3e6a Mon Sep 17 00:00:00 2001 From: Aleksandra Cynk Date: Tue, 16 Jul 2024 13:14:47 +0200 Subject: [PATCH 9/9] Rename --- .../RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts index b821fcf9183a..d03c42410a6e 100644 --- a/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts +++ b/apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestRunner.ts @@ -517,7 +517,7 @@ export class TestRunner { await this._syncUIRunner.runOnUIBlocking(() => { 'worklet'; if (global.originalLayoutAnimationsManager) { - global.LayoutAnimationsManager = global._LayoutAnimationsManager; + global.LayoutAnimationsManager = global.originalLayoutAnimationsManager; } }); }