-
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 7 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 |
---|---|---|
|
@@ -108,5 +108,58 @@ public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset() | |
|
||
yield return null; | ||
} | ||
|
||
[Test] | ||
AswinRajGopal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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? |
||
{ | ||
var legacyJson = @" | ||
AswinRajGopal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
{ | ||
""name"": ""InputSystem_Actions"", | ||
""maps"": [ | ||
{ | ||
""name"": ""Player"", | ||
""id"": ""df70fa95-8a34-4494-b137-73ab6b9c7d37"", | ||
""actions"": [ | ||
{ | ||
""name"": ""Move"", | ||
""type"": ""Value"", | ||
""id"": ""351f2ccd-1f9f-44bf-9bec-d62ac5c5f408"", | ||
""expectedControlType"": ""Vector2"", | ||
""processors"": ""StickDeadzone,InvertVector2(invertX=false),Custom(SomeEnum=1)"", | ||
""interactions"": """", | ||
""initialStateCheck"": true | ||
} | ||
] | ||
} | ||
], | ||
""controlSchemes"": [], | ||
""version"": 0 | ||
}"; | ||
|
||
// Parse and migrate the legacy JSON | ||
var asset = InputActionAsset.FromJson(legacyJson); | ||
|
||
// Object is valid after migration | ||
Assert.That(asset, Is.Not.Null, "Migration failed to produce a valid InputActionAsset."); | ||
|
||
var map = asset.FindActionMap("Player"); | ||
Assert.That(map, Is.Not.Null, "Expected Player map to exist."); | ||
|
||
var action = map.FindAction("Move"); | ||
Assert.That(action, Is.Not.Null, "Expected Move action to exist."); | ||
AswinRajGopal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
var processors = action.processors; | ||
|
||
// Verify processor order and that enum was converted properly | ||
Assert.That(processors, Does.Contain("StickDeadzone"), "StickDeadzone processor missing."); | ||
Assert.That(processors, Does.Contain("InvertVector2(invertX=false)"), "InvertVector2 missing."); | ||
Assert.That(processors, Does.Contain("Custom(SomeEnum=20)"), "Custom(SomeEnum=1) should migrate to SomeEnum=20 (OptionB)."); | ||
AswinRajGopal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
// Verify To JSON | ||
var toJson = asset.ToJson(); | ||
var reloaded = InputActionAsset.FromJson(toJson); | ||
Assert.That(reloaded, Is.Not.Null, "Reloaded asset after migration is null."); | ||
Assert.That(reloaded.FindAction("Player/Move"), Is.Not.Null, "Reloaded asset did not contain expected Move action."); | ||
} | ||
} | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.