Skip to content

Commit

Permalink
test: fix tests and various bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
poi-vrc committed Aug 24, 2023
1 parent 419a762 commit 3abef52
Show file tree
Hide file tree
Showing 42 changed files with 4,181 additions and 2,866 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Chocopoi.DressingTools.Tests.Cabinet
{
public class CabinetApplierTest : DTTestBase
public class CabinetApplierTest : DTEditorTestBase
{
private static void ApplyCabinet(DTReport report, DTCabinet cabinet)
{
Expand Down
15 changes: 1 addition & 14 deletions Assets/_DTDevOnly/Tests/Editor/Cabinet/DTCabinetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Chocopoi.DressingTools.Tests.Cabinet
{
public class DTCabinetTest : DTTestBase
public class DTCabinetTest : DTEditorTestBase
{
private static void ApplyCabinet(DTReport report, DTCabinet cabinet)
{
Expand Down Expand Up @@ -80,18 +80,5 @@ public void ApplyInEditorMode_AppliesNormally()

Assert.False(report.HasLogType(DTReportLogType.Error), "Should have no errors");
}

[UnityTest]
public IEnumerator ApplyInPlayModeOnLoad_AppliesNormally()
{
var avatarRoot = InstantiateEditorTestPrefab("DTTest_PhysBoneAvatarWithWearable.prefab");
yield return null;
// we are unable to check DTReport logs so we just check is the armature empty here
var wearableRoot = avatarRoot.transform.Find("DTTest_PhysBoneWearable");
Assert.NotNull(wearableRoot);
var armature = wearableRoot.transform.Find("Armature");
Assert.NotNull(armature);
Assert.AreEqual(0, armature.childCount);
}
}
}
34 changes: 34 additions & 0 deletions Assets/_DTDevOnly/Tests/Editor/DTEditorTestBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Collections.Generic;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;

namespace Chocopoi.DressingTools.Tests
{
// a test script base containing utility functions
public class DTEditorTestBase : DTRuntimeTestBase
{
protected T LoadEditorTestAsset<T>(string relativePath) where T : Object
{
// load test asset from resources folder
var path = "Assets/_DTDevOnly/Tests/Editor/Resources/" + GetType().Name + "/" + relativePath;
var obj = AssetDatabase.LoadAssetAtPath<T>(path);
Assert.NotNull(obj, "Could not find test asset at path:" + path);
return obj;
}

protected GameObject InstantiateEditorTestPrefab(string relativePath, Transform parent = null)
{
// load test prefab and instantiate it
var prefab = LoadEditorTestAsset<GameObject>(relativePath);
var obj = Object.Instantiate(prefab);
instantiatedGameObjects.Add(obj);

if (parent)
{
obj.transform.parent = parent;
}
return obj;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Chocopoi.DressingTools.Tests
{
public class DTRuntimeUtilsTest : DTTestBase
public class DTEditorUtilsTest : DTEditorTestBase
{
public class DummyClass1 { }
public class DummyClass2 { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Chocopoi.DressingTools.Tests.Dresser.Default
{
public class DefaultDresserTest : DTTestBase
public class DefaultDresserTest : DTEditorTestBase
{
[Test]
public void NotDTDefaultDresserSettings_ReturnsCorrectErrorCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Chocopoi.DressingTools.Tests.Dresser.Default.Hooks
{
public class ArmatureHookTest : DTTestBase
public class ArmatureHookTest : DTEditorTestBase
{
private static bool EvaluateHook(GameObject avatarRoot, GameObject wearableRoot, out DTReport report, out List<BoneMapping> boneMappings, DefaultDresserDynamicsOption dynamicsOption = DefaultDresserDynamicsOption.RemoveDynamicsAndUseParentConstraint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Chocopoi.DressingTools.Tests.Dresser.Default.Hooks
{
public class NoMissingScriptsHookTest : DTTestBase
public class NoMissingScriptsHookTest : DTEditorTestBase
{
private bool EvaluateHook(GameObject avatarRoot, GameObject wearableRoot, out DTReport report)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Chocopoi.DressingTools.Tests.Dresser
{
public class DresserRegistryTest : DTTestBase
public class DresserRegistryTest : DTEditorTestBase
{
[Test]
public void GetDresserByTypeNameTest()
Expand Down
Loading

0 comments on commit 3abef52

Please sign in to comment.