Skip to content
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

test: enable ShowFrameMarkers() test again for Unity 2022.2 or later #473

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Editor/Scripts/Features/ImageFolderPlayableAssetEditor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Unity.FilmInternalUtilities;
using UnityEditor;
using UnityEditor.Timeline;
using UnityEngine;
using UnityEngine.Assertions;
Expand All @@ -14,7 +15,11 @@ public override void OnClipChanged(TimelineClip clip) {

ImageFolderPlayableAsset<T> imageFolderPlayableAsset = clip.asset as ImageFolderPlayableAsset<T>;
Assert.IsNotNull(imageFolderPlayableAsset);
imageFolderPlayableAsset.RefreshPlayableFrames();

//Use delayCall to prevent marker creation during undo/redo process
EditorApplication.delayCall += () => {
imageFolderPlayableAsset.RefreshPlayableFrames();
};
}

//----------------------------------------------------------------------------------------------------------------------
Expand Down
20 changes: 8 additions & 12 deletions Tests/Editor/Scripts/FrameMarkerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,35 @@ internal class FrameMarkerTest {
[UnityTest]
public IEnumerator ShowFrameMarkers() {

//[Note-sin: 2022-12-21] Disabling test in Unity 2022 because this error "Assertion failed on expression: '!GetUndoManager().IsProcessing()'"
//The flow when this occurs:
//1. calling Undo.PerformUndo(); triggers ImageFolderPlayableAssetEditor.OnClipChanged()
//2. ImageFolderPlayableAssetEditor.OnClipChanged() may call TrackAsset.CreateMarker()
//3. TrackAsset.CreateMarker() has Undo-related calls in it, which seems to be incompatible if it is called during an undo process
#if !UNITY_2022_2_OR_NEWER
PlayableDirector director = EditorUtilityTest.NewSceneWithDirector();
TimelineClip clip = EditorUtilityTest.CreateTestSISTimelineClip(director);
StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset;
Assert.IsNotNull(sisAsset);
yield return null;
yield return YieldEditorUtility.WaitForFramesAndIncrementUndo(1);

//Show
SISClipData clipData = sisAsset.GetBoundClipData();
Assert.IsNotNull(clipData);

TrackAsset trackAsset = clip.GetParentTrack();
clipData.RequestFrameMarkers(true, true);
TimelineEditor.Refresh(RefreshReason.ContentsModified);
yield return null;
yield return YieldEditorUtility.WaitForFramesAndIncrementUndo(1);

Assert.AreEqual(TimelineUtility.CalculateNumFrames(clip), trackAsset.GetMarkerCount());
yield return null;
yield return YieldEditorUtility.WaitForFramesAndIncrementUndo(1);


//Undo showing FrameMarkers
EditorUtilityTest.UndoAndRefreshTimelineEditor(); yield return null;
EditorUtilityTest.UndoAndRefreshTimelineEditor();
yield return YieldEditorUtility.WaitForFramesAndIncrementUndo(1);

Assert.False(clipData.AreFrameMarkersRequested());
Assert.AreEqual(0, trackAsset.GetMarkerCount());


EditorUtilityTest.DestroyTestTimelineAssets(clip);
#endif
yield return null;
yield return YieldEditorUtility.WaitForFramesAndIncrementUndo(1);
}


Expand Down