From c57a2d29508fe8a777a332eea8d90721d0364f46 Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Sun, 26 Jul 2026 23:38:41 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E9=9A=94=E7=A6=BB=E5=B8=A7=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E5=AF=BC=E5=85=A5=E6=B5=8B=E8=AF=95=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../EditMode/FrameAnimationImportTests.cs | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Assets/Tests/FrameAnimation/EditMode/FrameAnimationImportTests.cs b/Assets/Tests/FrameAnimation/EditMode/FrameAnimationImportTests.cs index cfe7495bb..52671b638 100644 --- a/Assets/Tests/FrameAnimation/EditMode/FrameAnimationImportTests.cs +++ b/Assets/Tests/FrameAnimation/EditMode/FrameAnimationImportTests.cs @@ -11,22 +11,30 @@ namespace AibisDream.FrameAnimation.Tests.EditMode { public sealed class FrameAnimationImportTests { - private const string TestRoot = "Assets/Tests/FrameAnimation/GeneratedImportTests"; - private const string TexturePath = TestRoot + "/Atlas.png"; - private const string JsonPath = TestRoot + "/Atlas.json"; - private const string GraphPath = TestRoot + "/ImportGraph.asset"; + private string TestRoot { get; set; } + private string TexturePath => TestRoot + "/Atlas.png"; + private string JsonPath => TestRoot + "/Atlas.json"; + private string GraphPath => TestRoot + "/ImportGraph.asset"; [SetUp] public void SetUp() { - AssetDatabase.DeleteAsset(TestRoot); + TestRoot = + $"Assets/Tests/FrameAnimation/GeneratedImportTests_{Guid.NewGuid():N}"; EnsureFolder(TestRoot); } [TearDown] public void TearDown() { - AssetDatabase.DeleteAsset(TestRoot); + if (!string.IsNullOrEmpty(TestRoot)) + { + Assert.That( + AssetDatabase.DeleteAsset(TestRoot), + Is.True, + $"Failed to delete test asset folder: {TestRoot}"); + } + AssetDatabase.Refresh(); } @@ -329,7 +337,7 @@ namespace AibisDream.FrameAnimation.Tests.EditMode Assert.That(graph.Clips, Is.Empty); } - private static FrameAnimationGraph CreateWritableGraph(string json) + private FrameAnimationGraph CreateWritableGraph(string json) { CreateTexture(); WriteJson(json); @@ -347,7 +355,7 @@ namespace AibisDream.FrameAnimation.Tests.EditMode return graph; } - private static void CreateTexture() + private void CreateTexture() { var texture = new Texture2D(4, 2, TextureFormat.RGBA32, false); var pixels = Enumerable.Range(0, 8) @@ -360,7 +368,7 @@ namespace AibisDream.FrameAnimation.Tests.EditMode AssetDatabase.ImportAsset(TexturePath, ImportAssetOptions.ForceSynchronousImport); } - private static void WriteJson(string json) + private void WriteJson(string json) { File.WriteAllText(JsonPath, json, new UTF8Encoding(false)); AssetDatabase.ImportAsset(JsonPath, ImportAssetOptions.ForceSynchronousImport);