From 62356cb57efe6e89127e102a77af85ee1e1630a0 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 26 Jan 2022 14:17:59 +0900 Subject: [PATCH] =?UTF-8?q?Test=20=E3=81=AE=20Dispose=20=E3=81=8C=E8=B6=B3?= =?UTF-8?q?=E3=82=8A=E3=81=AA=E3=81=84=E3=81=A8=E3=81=93=E3=82=8D=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/UniGLTF/Tests/UniGLTF/MeshTests.cs | 44 ++++++++++---------- Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs | 5 +-- Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs | 4 +- Assets/VRM/Tests/VrmDividedMeshTests.cs | 14 ++++--- Assets/VRM10/Tests/ApiSampleTests.cs | 14 ++++--- Assets/VRM10/Tests/MigrationTests.cs | 3 +- 6 files changed, 43 insertions(+), 41 deletions(-) diff --git a/Assets/UniGLTF/Tests/UniGLTF/MeshTests.cs b/Assets/UniGLTF/Tests/UniGLTF/MeshTests.cs index 0337f0bd8..41f2c97fa 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/MeshTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/MeshTests.cs @@ -137,30 +137,32 @@ namespace UniGLTF : MeshExporter_SharedVertexBuffer.Export(data, unityMesh, Materials, axisInverter, meshExportSettings) ; - var parsed = GltfData.CreateFromGltfDataForTest(data.GLTF, data.BinBytes); - + using (var parsed = GltfData.CreateFromGltfDataForTest(data.GLTF, data.BinBytes)) { - var indices = parsed.GetIndices(gltfMesh.primitives[0].indices); - Assert.AreEqual(0, indices[0]); - Assert.AreEqual(1, indices[1]); - Assert.AreEqual(5, indices[2]); - Assert.AreEqual(5, indices[3]); - Assert.AreEqual(1, indices[4]); - Assert.AreEqual(4, indices[5]); - } - { - var indices = parsed.GetIndices(gltfMesh.primitives[1].indices); - Assert.AreEqual(1, indices[0]); - Assert.AreEqual(2, indices[1]); - Assert.AreEqual(4, indices[2]); - Assert.AreEqual(4, indices[3]); - Assert.AreEqual(2, indices[4]); - Assert.AreEqual(3, indices[5]); - } + { + var indices = parsed.GetIndices(gltfMesh.primitives[0].indices); + Assert.AreEqual(0, indices[0]); + Assert.AreEqual(1, indices[1]); + Assert.AreEqual(5, indices[2]); + Assert.AreEqual(5, indices[3]); + Assert.AreEqual(1, indices[4]); + Assert.AreEqual(4, indices[5]); + } - var positions = parsed.GetArrayFromAccessor(gltfMesh.primitives[0].attributes.POSITION); - Assert.AreEqual(6, positions.Length); + { + var indices = parsed.GetIndices(gltfMesh.primitives[1].indices); + Assert.AreEqual(1, indices[0]); + Assert.AreEqual(2, indices[1]); + Assert.AreEqual(4, indices[2]); + Assert.AreEqual(4, indices[3]); + Assert.AreEqual(2, indices[4]); + Assert.AreEqual(3, indices[5]); + } + + var positions = parsed.GetArrayFromAccessor(gltfMesh.primitives[0].attributes.POSITION); + Assert.AreEqual(6, positions.Length); + } } [Test] diff --git a/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs b/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs index 00baf6061..6f8e6ba84 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs @@ -88,10 +88,7 @@ namespace UniGLTF return; } - // parse - var data = new GlbFileParser(path.FullName).Parse(); - - // load + using (var data = new GlbFileParser(path.FullName).Parse()) using (var context = new ImporterContext(data)) { var instance = context.Load(); diff --git a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs index 0a90b7d38..a0392b6a9 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs @@ -115,9 +115,7 @@ namespace UniGLTF } // parse - var parsed = GltfData.CreateFromExportForTest(data); - - // import + using (var parsed = GltfData.CreateFromExportForTest(data)) using (var context = new ImporterContext(parsed)) using (var loaded = context.Load()) { diff --git a/Assets/VRM/Tests/VrmDividedMeshTests.cs b/Assets/VRM/Tests/VrmDividedMeshTests.cs index 2903d7d38..f23744e49 100644 --- a/Assets/VRM/Tests/VrmDividedMeshTests.cs +++ b/Assets/VRM/Tests/VrmDividedMeshTests.cs @@ -21,13 +21,15 @@ namespace VRM static GameObject Load(byte[] bytes, string path) { - var gltf = new GlbLowLevelParser(path, bytes).Parse(); - var data = new VRMData(gltf); - using (var loader = new VRMImporterContext(data)) + using (var gltf = new GlbLowLevelParser(path, bytes).Parse()) { - var loaded = loader.Load(); - loaded.ShowMeshes(); - return loaded.gameObject; + var data = new VRMData(gltf); + using (var loader = new VRMImporterContext(data)) + { + var loaded = loader.Load(); + loaded.ShowMeshes(); + return loaded.gameObject; + } } } diff --git a/Assets/VRM10/Tests/ApiSampleTests.cs b/Assets/VRM10/Tests/ApiSampleTests.cs index 08a8b8a67..9ac34e0dd 100644 --- a/Assets/VRM10/Tests/ApiSampleTests.cs +++ b/Assets/VRM10/Tests/ApiSampleTests.cs @@ -40,14 +40,16 @@ namespace UniVRM10.Test Debug.Log($"load: {path}"); Assert.IsTrue(Vrm10Data.TryParseOrMigrate(path, true, out Vrm10Data result)); + using (result) + { + var go = BuildGameObject(result, true); + Debug.Log(go); - var go = BuildGameObject(result, true); - Debug.Log(go); + // export + var vrmBytes = Vrm10Exporter.Export(go, new EditorTextureSerializer()); - // export - var vrmBytes = Vrm10Exporter.Export(go, new EditorTextureSerializer()); - - Debug.Log($"export {vrmBytes.Length} bytes"); + Debug.Log($"export {vrmBytes.Length} bytes"); + } } } } diff --git a/Assets/VRM10/Tests/MigrationTests.cs b/Assets/VRM10/Tests/MigrationTests.cs index 4a491433d..1a3adb2a4 100644 --- a/Assets/VRM10/Tests/MigrationTests.cs +++ b/Assets/VRM10/Tests/MigrationTests.cs @@ -198,7 +198,7 @@ namespace UniVRM10 { try { - Vrm10Data.TryParseOrMigrate(gltf.FullName, true, out Vrm10Data vrm); + Assert.True(Vrm10Data.TryParseOrMigrate(gltf.FullName, true, out Vrm10Data vrm)); using (vrm) using (var loader = new Vrm10Importer(vrm)) { @@ -263,6 +263,7 @@ namespace UniVRM10 public void MigrateMeta() { Assert.True(Vrm10Data.TryParseOrMigrate(AliciaPath, true, out Vrm10Data vrm)); + vrm.Dispose(); } } }