-
Notifications
You must be signed in to change notification settings - Fork 328
FIX: ISXB-1674 - Input actions asset not converted correctly when upgrading from 1.14.1 (Regression) #2244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
FIX: ISXB-1674 - Input actions asset not converted correctly when upgrading from 1.14.1 (Regression) #2244
Changes from 17 commits
a260324
00b37a5
d637adf
4e76813
a8ba533
ff05b1d
829c4aa
9467adf
3e490f1
a31d971
817ff0e
2914bf7
6daabc9
6aca9db
f3f7ea5
f5b06da
6b4c75a
64076cb
f042f1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using UnityEngine; | ||
using UnityEngine.InputSystem; | ||
using UnityEngine.InputSystem.Editor; | ||
using UnityEngine.InputSystem.Processors; | ||
using UnityEngine.TestTools; | ||
using UnityEngine.UIElements; | ||
|
||
|
@@ -108,5 +109,69 @@ public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset() | |
|
||
yield return null; | ||
} | ||
|
||
[Test] | ||
AswinRajGopal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[Description("Regression test for case ISXB-1674")] | ||
public void Migration_ShouldProduceValidActionAsset_WithEnumProcessorConverted() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you document what the intent of this test case is inline in code? My interpretation is that you want to verify that processors defined in a certain way in .inputaction json are parsed/preserved correctly when imported (with migration)? If this is the case I suggest you convert this into a functional test instead of doing a lot of string comparisons. Here is a rough example (coded directly into web interface so it may contain errors but hope you get the idea): const string legacyJson = "<as before>"; // Consider including binding in JSON to avoid writing code for it
var asset = InputActionAsset.FromJson(legacyJson);
var gamepad = InputSystem.AddDevice<Gamepad>();
var action = asset.FindAction("Player/Move");
action.Enable();
// Make sure deadzone processor is applied
Set(gamepad.leftStick, new Vector2(InputSystem.settings.defaultDeadzoneMin * 0.9f, 0.0f));
Assert.That(action.ReadValue<Vector2>(), Is.Equal(Vecto2.zero)); // Filtered by deadzone
// Make sure invert processor is applied
Set(gamepad.leftStick, new Vector2(1.0f, 0.0f));
Assert.That(action.ReadValue<Vector2>(), Is.Equal(-Vector2.right)); // Inverted
// Make sure custom processor is applied
Set(gamepad.leftStick, new Vector2(0.5f, 0.0f));
Assert.That(action.ReadValue<Vector2>(), Is.Equal(something)); // Not sure how custom should change value, so change this to what is appropriate Ideally order dependency can be proven through the same test case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure I'll change it into a functional test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you see any pros/cons with changing approach? Would such a functional test miss some aspect of this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My view about authoring a regression test is to cover only the migration case where we actually verify that a JSON with a custom processor and some neighboring processors like stickdeadzone or invertVector are parsed properly after migration. The functional tests already exists which covers most of the functionals in the input system generic tests. However it will be robust to club both of these for this case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, that is also fine so keep this if you want. Not sure @LeoUnity has additional perspective? |
||
{ | ||
const string k_Json = @" | ||
{ | ||
""name"": ""InputSystem_Actions"", | ||
""maps"": [ | ||
{ | ||
""name"": ""Player"", | ||
""id"": ""df70fa95-8a34-4494-b137-73ab6b9c7d37"", | ||
""actions"": [ | ||
{ | ||
""name"": ""Move"", | ||
""type"": ""Value"", | ||
""id"": ""938a78a0-f8c6-4b2e-b8a7-d3c26d83a4e9"", | ||
""expectedControlType"": ""Vector2"", | ||
""processors"": ""StickDeadzone,InvertVector2(invertX=false),Custom(SomeEnum=1)"", | ||
""interactions"": """", | ||
""initialStateCheck"": true | ||
} | ||
], | ||
""bindings"": [ | ||
{ | ||
""name"": """", | ||
""id"": ""c9a175a0-a5ed-4e2c-b3a9-1d4d3d3a7a9a"", | ||
""path"": ""<Gamepad>/leftStick"", | ||
""interactions"": """", | ||
""processors"": """", | ||
""groups"": """", | ||
""action"": ""Move"", | ||
""isComposite"": false, | ||
""isPartOfComposite"": false | ||
} | ||
] | ||
} | ||
], | ||
""controlSchemes"": [] | ||
}"; | ||
|
||
var asset = InputActionAsset.FromJson(k_Json); | ||
|
||
// Enable the action to call rebinding | ||
asset.FindAction("Move").Enable(); | ||
|
||
var map = asset.FindActionMap("Player"); | ||
|
||
// Directly tests the outcome of the migration and parsing logic, which is the core goal. | ||
var instantiatedProcessors = map.m_State.processors; | ||
Assert.That(map.m_State.totalProcessorCount, Is.EqualTo(3), "Should create exactly three processors."); | ||
|
||
// Verify the order and type of each processor. | ||
Assert.That(instantiatedProcessors[0], Is.TypeOf<StickDeadzoneProcessor>(), "First processor should be StickDeadzone."); | ||
Assert.That(instantiatedProcessors[1], Is.TypeOf<InvertVector2Processor>(), "Second processor should be InvertVector2."); | ||
Assert.That(instantiatedProcessors[2], Is.TypeOf<CustomProcessor>(), "Third processor should be the custom type."); | ||
|
||
// Verify the specific data for processors with parameters. | ||
var invertProcessor = (InvertVector2Processor)instantiatedProcessors[1]; | ||
Assert.That(invertProcessor.invertX, Is.False, "invertX parameter should be false."); | ||
|
||
var customProcessor = (CustomProcessor)instantiatedProcessors[2]; | ||
Assert.That(customProcessor.SomeEnum, Is.EqualTo(SomeEnum.OptionB), "Enum parameter should be parsed correctly to OptionB."); | ||
} | ||
} | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.