清理各个 Component 里的判断以及调用规范
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ namespace SepCore.InputModule.Tests
|
||||
public void SetUp()
|
||||
{
|
||||
_gameObject = new GameObject("InputModuleTest");
|
||||
_component = _gameObject.AddComponent<InputModuleComponent>();
|
||||
_component = InputModuleTestFactory.CreateComponent(_gameObject);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
+4
-1
@@ -17,7 +17,7 @@ namespace SepCore.InputModule.Tests
|
||||
public void SetUp()
|
||||
{
|
||||
_gameObject = new GameObject("InputModuleEventTest");
|
||||
_component = _gameObject.AddComponent<InputModuleComponent>();
|
||||
_component = InputModuleTestFactory.CreateComponent(_gameObject);
|
||||
_component.OnInit();
|
||||
}
|
||||
|
||||
@@ -185,6 +185,9 @@ namespace SepCore.InputModule.Tests
|
||||
public void RegisterListener_NullCallback_DoesNotThrow()
|
||||
{
|
||||
Assert.DoesNotThrow(() => _component.RegisterListener(InputActionId.Pause, null));
|
||||
|
||||
Dictionary<InputActionId, Action<InputCommand>> listeners = GetPrivateListenersDictionary();
|
||||
Assert.That(listeners.ContainsKey(InputActionId.Pause), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
+3
-2
@@ -17,7 +17,7 @@ namespace SepCore.InputModule.Tests
|
||||
{
|
||||
base.Setup();
|
||||
_gameObject = new GameObject("InputModuleRebindTest");
|
||||
_component = _gameObject.AddComponent<InputModuleComponent>();
|
||||
_component = InputModuleTestFactory.CreateComponent(_gameObject);
|
||||
_component.OnInit();
|
||||
}
|
||||
|
||||
@@ -202,7 +202,8 @@ namespace SepCore.InputModule.Tests
|
||||
InputAction confirmAction = _component.RuntimeActions.FindAction($"{nameof(InputContextId.UI)}/{nameof(InputActionId.Confirm)}");
|
||||
confirmAction.ApplyBindingOverride(0, "<Keyboard>/space");
|
||||
|
||||
InputBindingSnapshot snapshot = _component.SaveBindingOverrides();
|
||||
string overridesJson = _component.RuntimeActions.SaveBindingOverridesAsJson();
|
||||
InputBindingSnapshot snapshot = new InputBindingSnapshot(overridesJson);
|
||||
|
||||
_component.ResetAllBindingsToDefaults();
|
||||
Assert.That(confirmAction.bindings[0].overridePath, Is.Null);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ namespace SepCore.InputModule.Tests
|
||||
public void SetUp()
|
||||
{
|
||||
_gameObject = new GameObject("InputModuleDebuggerReflectionTest");
|
||||
_component = _gameObject.AddComponent<InputModuleComponent>();
|
||||
_component = InputModuleTestFactory.CreateComponent(_gameObject);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Reflection;
|
||||
using SepCore.InputModule.Runtime;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.InputModule.Tests
|
||||
{
|
||||
internal static class InputModuleTestFactory
|
||||
{
|
||||
public static InputModuleComponent CreateComponent(GameObject gameObject)
|
||||
{
|
||||
InputModuleComponent component = gameObject.AddComponent<InputModuleComponent>();
|
||||
typeof(InputModuleComponent)
|
||||
.GetField("_loadBindingOverridesOnInit", BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
.SetValue(component, false);
|
||||
return component;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e4066e709bd03646a983938f9b9b525
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user