-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Test predefined entering animation #5995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4ee75d7
Entering animation
Latropos 8034cdd
Merge
Latropos b06555c
More snapshots
Latropos 86d2d70
Fix snapshots for first example
Latropos 0ccebc7
Test entering on mount
Latropos fbf23f2
Add comment
Latropos b96d748
Fix styling
Latropos 71aa569
Unify test names
Latropos 2cc3c36
Fix types
Latropos beaff50
Speed tests up
Latropos 5a75d94
Speed tests up
Latropos 6548480
Revert files
Latropos 4269319
Delete only
Latropos e25825a
Fix snapshots
Latropos 67ea1a5
Merge with RollInLeft fix
Latropos 326a777
Update timing
Latropos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 128 additions & 1 deletion
129
app/src/examples/RuntimeTests/tests/layoutAnimations/entering/entering.snapshot.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
app/src/examples/RuntimeTests/tests/layoutAnimations/entering/predefinedEntering.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import Animated, { | ||
| FadeIn, | ||
| FadeInRight, | ||
| FadeInLeft, | ||
| FadeInUp, | ||
| FadeInDown, | ||
| BounceIn, | ||
| BounceInRight, | ||
| BounceInLeft, | ||
| BounceInUp, | ||
| BounceInDown, | ||
| FlipInEasyX, | ||
| FlipInEasyY, | ||
| FlipInXDown, | ||
| FlipInXUp, | ||
| FlipInYLeft, | ||
| FlipInYRight, | ||
| LightSpeedInRight, | ||
| LightSpeedInLeft, | ||
| PinwheelIn, | ||
| RotateInDownLeft, | ||
| RotateInDownRight, | ||
| RotateInUpLeft, | ||
| RotateInUpRight, | ||
| SlideInRight, | ||
| SlideInLeft, | ||
| SlideInUp, | ||
| SlideInDown, | ||
| StretchInX, | ||
| StretchInY, | ||
| ZoomIn, | ||
| ZoomInDown, | ||
| ZoomInEasyDown, | ||
| ZoomInEasyUp, | ||
| ZoomInLeft, | ||
| ZoomInRight, | ||
| ZoomInRotate, | ||
| ZoomInUp, | ||
| RollInRight, | ||
| RollInLeft, | ||
| } from 'react-native-reanimated'; | ||
| import React from 'react'; | ||
| import { | ||
| describe, | ||
| test, | ||
| expect, | ||
| mockAnimationTimer, | ||
| recordAnimationUpdates, | ||
| render, | ||
| wait, | ||
| unmockAnimationTimer, | ||
| clearRenderOutput, | ||
| } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi'; | ||
| import { | ||
| DurationEnteringSnapshots, | ||
| NoModifierEnteringSnapshots, | ||
| SpringifyEnteringSnapshots, | ||
| } from './entering.snapshot'; | ||
|
|
||
| const FADE_ENTERING = [FadeIn, FadeInRight, FadeInRight, FadeInLeft, FadeInUp, FadeInDown]; | ||
| const BOUNCE_ENTERING = [BounceIn, BounceInRight, BounceInLeft, BounceInUp, BounceInDown]; | ||
| const FLIP_ENTERING = [FlipInEasyX, FlipInEasyY, FlipInXDown, FlipInXUp, FlipInYLeft, FlipInYRight]; | ||
| const LIGHTSPEED_ENTERING = [LightSpeedInRight, LightSpeedInLeft]; | ||
| const PINWHEEL_ENTERING = [PinwheelIn]; | ||
| const ROLL_ENTERING = [RollInRight, RollInLeft]; //Don't test RollIn, until recording rotation snapshot gets fixed | ||
| const ROTATE_ENTERING = [RotateInDownLeft, RotateInDownRight, RotateInUpLeft, RotateInUpRight]; | ||
| const SLIDE_ENTERING = [SlideInRight, SlideInLeft, SlideInUp, SlideInDown]; | ||
| const STRETCH_ENTERING = [StretchInX, StretchInY]; | ||
|
|
||
| const ZOOM_ENTERING = [ | ||
| ZoomIn, | ||
| ZoomInDown, | ||
| ZoomInEasyDown, | ||
| ZoomInEasyUp, | ||
| ZoomInLeft, | ||
| ZoomInRight, | ||
| ZoomInRotate, | ||
| ZoomInUp, | ||
| ]; | ||
|
|
||
| const ENTERING_SETS: Array<[string, unknown[], number]> = [ | ||
| ['Fade', FADE_ENTERING, 1350], | ||
| ['Bounce', BOUNCE_ENTERING, 650], | ||
| ['Flip', FLIP_ENTERING, 1750], | ||
| ['LightSpeed', LIGHTSPEED_ENTERING, 1600], | ||
| ['Pinwheel', PINWHEEL_ENTERING, 1000], | ||
| ['Roll', ROLL_ENTERING, 1750], | ||
| ['Rotate', ROTATE_ENTERING, 1600], | ||
| ['Slide', SLIDE_ENTERING, 1800], | ||
| ['Stretch', STRETCH_ENTERING, 1000], | ||
| ['Zoom', ZOOM_ENTERING, 1800], | ||
| ]; | ||
|
|
||
| const EnteringOnMountComponent = ({ entering }: { entering: any }) => { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <Animated.View entering={entering} style={styles.animatedBox} /> | ||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| async function getSnapshotUpdates(entering: any, waitTime: number, duration: number | undefined, springify = false) { | ||
| await mockAnimationTimer(); | ||
|
|
||
| const updatesContainer = await recordAnimationUpdates(); | ||
| const springEntering = springify ? entering : entering.springify(); | ||
| const componentEntering = duration ? springEntering.duration(duration) : springEntering; | ||
|
|
||
| await render(<EnteringOnMountComponent entering={componentEntering} />); | ||
| await wait(waitTime); | ||
| const updates = updatesContainer.getUpdates(); | ||
| await unmockAnimationTimer(); | ||
| await clearRenderOutput(); | ||
|
|
||
| return updates; | ||
| } | ||
|
|
||
| describe('Test predefined entering', () => { | ||
| describe('Entering on mount, no modifiers', async () => { | ||
| test.each(ENTERING_SETS)('Test suite of ${0}In', async ([_setName, enteringSet, waitTime]) => { | ||
| for (const entering of enteringSet) { | ||
| const snapshotName = (entering as any).name; | ||
| const updates = await getSnapshotUpdates(entering, waitTime, undefined); | ||
| expect(updates).toMatchSnapshots( | ||
| NoModifierEnteringSnapshots[snapshotName as keyof typeof NoModifierEnteringSnapshots], | ||
| ); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe('Entering on mount, duration 100', async () => { | ||
| test.each(ENTERING_SETS)('Test suite of ${0}In', async ([_setName, enteringSet, _waitTime]) => { | ||
| for (const entering of enteringSet) { | ||
| const enteringName: string = (entering as any).name; | ||
| let updates = await getSnapshotUpdates(entering, 105, 100); | ||
| expect(updates).toMatchSnapshots( | ||
| DurationEnteringSnapshots[enteringName as keyof typeof DurationEnteringSnapshots], | ||
| ); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe('Entering on mount, springify', async () => { | ||
| test.each(ENTERING_SETS)('Test suite of ${0}In', async ([_setName, enteringSet, waitTime]) => { | ||
| const timeToWait = _setName === 'Bounce' ? 650 : waitTime * 0.3; | ||
| for (const entering of enteringSet) { | ||
| const snapshotName = (entering as any).name; | ||
| const updates = await getSnapshotUpdates(entering, timeToWait, undefined, true); | ||
| expect(updates).toMatchSnapshots( | ||
| SpringifyEnteringSnapshots[snapshotName as keyof typeof SpringifyEnteringSnapshots], | ||
| ); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| flexDirection: 'column', | ||
| }, | ||
| animatedBox: { | ||
| backgroundColor: 'royalblue', | ||
| height: 80, | ||
| margin: 40, | ||
| }, | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.