modular-avatar/UnitTests~/RenameParametersTests/RenameParametersTests.cs
kaikoga 3667dc319a
chore: Wrap VRC dependencies and VRCAvatarDescriptors (#504)
* add version defines

* refactor: prefer BuildContext.ctor() overload taking GameObject

* wrap unit tests entirely with MA_VRCSDK3_AVATARS

* wrap unit tests smart with MA_VRCSDK3_AVATARS

* wrap runtime entirely with MA_VRCSDK3_AVATARS

* wrap VRC.SDKBase.IEditorOnly with MA_VRCSDK3_AVATARS

* wrap editor entirely with MA_VRCSDK3_AVATARS

* fix AvatarObjectReference.Get(Component)

* wrap editor smart with MA_VRCSDK3_AVATARS

* wrap BuildContext smart with MA_VRCSDK3_AVATARS

* wrap PluginDefinition smart with MA_VRCSDK3_AVATARS

* style: move conditional compiles one step outside
2023-11-10 15:37:56 +09:00

68 lines
2.4 KiB
C#

#if MA_VRCSDK3_AVATARS
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using VRC.SDK3.Avatars.Components;
using VRC.SDK3.Avatars.ScriptableObjects;
namespace modular_avatar_tests.RenameParametersTests
{
public class RenameParametersTests : TestBase
{
[Test]
public void RenameParametersRenamesParamDrivers()
{
var prefab = CreatePrefab("RenameParametersRenamesParamDrivers.prefab");
AvatarProcessor.ProcessAvatar(prefab);
var layer = findFxLayer(prefab, "test");
CheckDriver(layer.stateMachine.behaviours[0] as VRCAvatarParameterDriver);
var state = FindStateInLayer(layer, "s");
CheckDriver(state.behaviours[0] as VRCAvatarParameterDriver);
var subStateMachine = layer.stateMachine.stateMachines[0].stateMachine;
CheckDriver(subStateMachine.behaviours[0] as VRCAvatarParameterDriver);
var subState = FindStateInLayer(layer, "s");
CheckDriver(subState.behaviours[0] as VRCAvatarParameterDriver);
void CheckDriver(VRCAvatarParameterDriver driver)
{
Assert.AreEqual("param_new", driver.parameters[0].name);
}
}
[Test]
public void RenameInstalledMenu()
{
var prefab = CreatePrefab("RenameInstalledMenu.prefab");
AvatarProcessor.ProcessAvatar(prefab);
var menu = prefab.GetComponent<VRCAvatarDescriptor>().expressionsMenu;
Assert.AreEqual("test$$Internal_0", menu.controls[0].parameter.name);
Assert.AreEqual("test$$Internal_0", menu.controls[1].subMenu.controls[0].parameter.name);
}
[Test]
public void TestRecursiveMenu()
{
var menu = LoadAsset<VRCExpressionsMenu>("m1.asset");
var avatar = CreateRoot("root");
var child = CreateChild(avatar, "child");
var param = child.AddComponent<ModularAvatarParameters>();
param.parameters.Add(new ParameterConfig()
{
nameOrPrefix = "test",
internalParameter = true,
});
var installer = child.AddComponent<ModularAvatarMenuInstaller>();
installer.menuToAppend = menu;
AvatarProcessor.ProcessAvatar(avatar);
}
}
}
#endif