modular-avatar/UnitTests~/MergeAnimatorTests/MergeSingleTests.cs
kaikoga efa263b551
chore: Fix non-VRChat support (for MA 1.10.5) (#1324)
* feat: add version defines for VRCSDK

* chore: early return if VRCSDK project but not VRChat avatar
2024-10-27 10:06:35 -07:00

54 lines
1.7 KiB
C#

#if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
using nadena.dev.ndmf;
using NUnit.Framework;
using UnityEngine;
using BuildContext = nadena.dev.ndmf.BuildContext;
namespace UnitTests.MergeAnimatorTests
{
internal class MergeSingleTests : TestBase
{
[Test]
public void NoErrorWhenAnimatorIsNull()
{
var av = CreateRoot("root");
var merge = av.AddComponent<ModularAvatarMergeAnimator>();
var ctx = new BuildContext(av, null);
ctx.ActivateExtensionContext<ModularAvatarContext>();
ctx.ActivateExtensionContext<AnimationServicesContext>();
var errors = ErrorReport.CaptureErrors(() => new MergeAnimatorProcessor().OnPreprocessAvatar(av, ctx));
Assert.IsEmpty(errors);
}
[Test]
public void MergeAnimationOverrideController()
{
var av = CreateRoot("root");
var merge = av.AddComponent<ModularAvatarMergeAnimator>();
merge.animator = LoadAsset<AnimatorOverrideController>("AOC_Override.overrideController");
var ctx = new BuildContext(av, null);
ctx.ActivateExtensionContext<ModularAvatarContext>();
ctx.ActivateExtensionContext<AnimationServicesContext>();
var errors = ErrorReport.CaptureErrors(() => new MergeAnimatorProcessor().OnPreprocessAvatar(av, ctx));
Assert.IsEmpty(errors);
var state = FindStateInLayer(findFxLayer(av, "Target"), "Anim1");
Assert.IsTrue(state.motion.name.StartsWith("Anim2"));
}
}
}
#endif