Skip to content

Commit 4c06cc6

Browse files
Fix broken tests after changes to complexity.
1 parent 808decb commit 4c06cc6

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ public void Actions_WhenShortcutsEnabled_CanConsumeInput(bool legacyComposites)
233233
action2.Enable();
234234

235235
// State monitors on the space key (all end up in the same group):
236-
// action3 complexity=3
237-
// action2 complexity=2
238-
// action1 complexity=1
239-
// action4 complexity=1
240-
// action5 complexity=1
236+
action3.Priority = 3;
237+
action2.Priority = 2;
238+
action1.Priority = 1;
239+
action4.Priority = 1;
240+
action5.Priority = 1;
241241

242242
action1.AddBinding("<Keyboard>/space");
243243
action2.AddCompositeBinding(legacyComposites ? "ButtonWithOneModifier" : "OneModifier")
@@ -526,6 +526,9 @@ public void Actions_WhenShortcutsAreEnabled_CanHaveShortcutsWithButtonsUsingInit
526526
.With("Modifier", "<Keyboard>/shift")
527527
.With("Binding", "<Keyboard>/space");
528528

529+
// We now need to set priority for this test to act as it used to with complexity.
530+
action2.Priority = 1;
531+
529532
action1.wantsInitialStateCheck = true;
530533
action2.wantsInitialStateCheck = true;
531534

@@ -1695,6 +1698,8 @@ public void Actions_CanDisableAndEnable_FromCallbackWhileOtherCompositeBindingIs
16951698
.With("Binding", "<Keyboard>/space")
16961699
.With("Modifier", "<Keyboard>/ctrl");
16971700
actionWithModifier.performed += _ => ++ withModiferReceivedCalls;
1701+
actionWithModifier.Priority = 1;
1702+
16981703

16991704
var actionWithoutModifier = map.AddAction("One", type: InputActionType.Button, binding: "<Keyboard>/space");
17001705
actionWithoutModifier.performed += _ => actionWithModifier.Disable();
@@ -11605,9 +11610,9 @@ public void Actions_DisablingAllActions_RemovesAllTheirStateMonitors()
1160511610

1160611611
// Not the most elegant test as we reach into internals here but with the
1160711612
// current API, it's not possible to enumerate monitors from outside.
11608-
Assert.That(InputSystem.manager.m_StateChangeMonitors,
11613+
Assert.That(InputSystem.manager.m_StateMonitors.m_MonitorsPerDevice,
1160911614
Has.All.Matches(
11610-
(InputManager.StateChangeMonitorsForDevice x) => x.memoryRegions.All(r => r.sizeInBits == 0)));
11615+
(InputManagerStateMonitors.StateChangeMonitorsForDevice x) => x.memoryRegions.All(r => r.sizeInBits == 0)));
1161111616
}
1161211617

1161311618
// https://fogbugz.unity3d.com/f/cases/1367442/
@@ -12499,6 +12504,9 @@ public void Actions_ImprovedShortcutSupport_ConsumesWASD(bool shortcutsEnabled)
1249912504
.With("Left", "<Keyboard>/a")
1250012505
.With("Right", "<Keyboard>/d");
1250112506

12507+
// Change test to use Priority.
12508+
action1.Priority = 1;
12509+
1250212510
var map2 = new InputActionMap("map2");
1250312511
var action2 = map2.AddAction(name: "action2");
1250412512
action2.AddCompositeBinding("2DVector")
@@ -12524,10 +12532,11 @@ public void Actions_ImprovedShortcutSupport_ConsumesWASD(bool shortcutsEnabled)
1252412532
action2.started += ctx => action2Count++;
1252512533
action3.started += ctx => action3Count++;
1252612534

12535+
1252712536
Press(keyboard.wKey);
1252812537
if (shortcutsEnabled)
1252912538
{
12530-
// First action with the most bindings is the ONLY one to trigger
12539+
// This is now handled by priority
1253112540
Assert.That(action1Count, Is.EqualTo(1));
1253212541
Assert.That(action2Count, Is.EqualTo(0));
1253312542
Assert.That(action3Count, Is.EqualTo(0));

0 commit comments

Comments
 (0)