modular-avatar/UnitTests~/SyncedLayerHandling/SyncedLayerHandling.cs
bd_ ddbc3b164b
chore: restructure repository to put package at top-level (#477)
* chore: rearrange package structure to have the package at the root

* ci: update CI workflows

* ci: fixing workflow bugs

* ci: recurse building .zip package

* ci: more fixes

* ci: add back in the nadena.dev VPM repo

* ci: fix tests
2023-10-08 15:39:57 +09:00

97 lines
3.5 KiB
C#

using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using VRC.SDK3.Avatars.Components;
namespace modular_avatar_tests.SyncedLayerHandling
{
public class SyncedLayerHandling : TestBase
{
[Test]
public void WhenSyncedLayerIsOnBaseController_SyncedConfigIsPreserved()
{
var prefab = CreatePrefab("BaseController.prefab");
AvatarProcessor.ProcessAvatar(prefab);
var mainLayer = findFxLayer(prefab, "main");
var syncLayer = findFxLayer(prefab, "sync");
Assert.AreEqual(1, syncLayer.syncedLayerIndex);
var m1State = FindStateInLayer(mainLayer, "m1");
var m2State = FindStateInLayer(mainLayer, "m2");
var m1Override = syncLayer.GetOverrideMotion(m1State);
var m2Override = syncLayer.GetOverrideMotion(m2State);
Assert.True(m1State.motion.name.Contains("m1"));
Assert.True(m2State.motion.name.Contains("m2"));
Assert.True(m1Override.name.Contains("m3"));
Assert.True(m2Override.name.Contains("m4"));
}
[Test]
public void WhenSyncedLayerIsOnMergedController_SyncedConfigIsPreserved()
{
var prefab = CreatePrefab("MergedController.prefab");
AvatarProcessor.ProcessAvatar(prefab);
var mainLayer = findFxLayer(prefab, "main");
var syncLayer = findFxLayer(prefab, "sync");
Assert.AreEqual(2, syncLayer.syncedLayerIndex);
var m1State = FindStateInLayer(mainLayer, "m1");
var m2State = FindStateInLayer(mainLayer, "m2");
var m1Override = syncLayer.GetOverrideMotion(m1State);
var m2Override = syncLayer.GetOverrideMotion(m2State);
Assert.True(m1State.motion.name.Contains("m1"));
Assert.True(m2State.motion.name.Contains("m2"));
Assert.True(m1Override.name.Contains("m3"));
Assert.True(m2Override.name.Contains("m4"));
}
[Test]
public void WhenSyncedLayerIsOnBaseController_LayerControlBehaviorsArePreserved()
{
var prefab = CreatePrefab("BaseController.prefab");
AvatarProcessor.ProcessAvatar(prefab);
var mainLayer = findFxLayer(prefab, "main");
var syncLayer = findFxLayer(prefab, "sync");
Assert.AreEqual(1, syncLayer.syncedLayerIndex);
var m1State = FindStateInLayer(mainLayer, "m1");
var overrides = syncLayer.GetOverrideBehaviours(m1State);
Assert.AreEqual(1, overrides.Length);
var layercontrol = overrides[0] as VRCAnimatorLayerControl;
Assert.NotNull(layercontrol);
Assert.AreEqual(1, layercontrol.layer);
}
[Test]
public void WhenSyncedLayerIsOnMergedController_LayerControlBehaviorsAreAdjusted()
{
var prefab = CreatePrefab("MergedController.prefab");
AvatarProcessor.ProcessAvatar(prefab);
var mainLayer = findFxLayer(prefab, "main");
var syncLayer = findFxLayer(prefab, "sync");
Assert.AreEqual(2, syncLayer.syncedLayerIndex);
var m1State = FindStateInLayer(mainLayer, "m1");
var overrides = syncLayer.GetOverrideBehaviours(m1State);
Assert.AreEqual(1, overrides.Length);
var layercontrol = overrides[0] as VRCAnimatorLayerControl;
Assert.NotNull(layercontrol);
Assert.AreEqual(2, layercontrol.layer);
}
}
}