Skip to content

Commit 707433a

Browse files
Update tests and remove redundant test.
1 parent ca4c908 commit 707433a

1 file changed

Lines changed: 13 additions & 60 deletions

File tree

Assets/Tests/InputSystem/CoreTests_ActionsPriority.cs

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -186,32 +186,32 @@ public void Actions_Priority_BothActionsArePerformed_DueToKeyPressOrderForShortc
186186

187187
// We swap the order here of Action1 & Action2 so key presses are done backwards, binding before modifiers.
188188
// This causes the opposite keys foreach test case inside TwoInputActionTestCases to be pressed first.
189-
var action1 = twoInputActions.Action2;
190-
var action2 = twoInputActions.Action1;
189+
var smallerBindingAction = twoInputActions.Action2;
190+
var largerBindingAction = twoInputActions.Action1;
191191

192192
// Event though the priority is higher for action2 here, due to the order of the keys being pressed only Action1 will be fired.
193-
action1.Priority = 1;
194-
action2.Priority = 2;
193+
smallerBindingAction.Priority = 1;
194+
largerBindingAction.Priority = 2;
195195

196-
action1.m_ActionMap.Enable();
196+
smallerBindingAction.m_ActionMap.Enable();
197197

198-
Assert.That(action1.WasPerformedThisFrame(), Is.False);
199-
Assert.That(action2.WasPerformedThisFrame(), Is.False);
198+
Assert.That(smallerBindingAction.WasPerformedThisFrame(), Is.False);
199+
Assert.That(largerBindingAction.WasPerformedThisFrame(), Is.False);
200200

201-
PressBindingsForInputActions(keyboard, action1, action2);
201+
PressBindingsForInputActions(keyboard, smallerBindingAction, largerBindingAction);
202202

203203
// action1 is performed because action1 has a higher priority than action2.
204-
Assert.That(action1.WasPerformedThisFrame(), Is.True);
205-
Assert.That(action2.WasPerformedThisFrame(), Is.True);
204+
Assert.That(smallerBindingAction.WasPerformedThisFrame(), Is.True);
205+
Assert.That(largerBindingAction.WasPerformedThisFrame(), Is.True);
206206

207207
// Cleanup key presses
208-
ReleaseBindingsForActions(keyboard, action1, action2);
208+
ReleaseBindingsForActions(keyboard, smallerBindingAction, largerBindingAction);
209209

210210
// Update again to be sure released is true.
211211
InputSystem.Update();
212212

213-
Assert.That(action1.WasPerformedThisFrame(), Is.False);
214-
Assert.That(action2.WasPerformedThisFrame(), Is.False);
213+
Assert.That(smallerBindingAction.WasPerformedThisFrame(), Is.False);
214+
Assert.That(largerBindingAction.WasPerformedThisFrame(), Is.False);
215215
}
216216

217217
[Test]
@@ -263,53 +263,6 @@ public void Actions_Priority_BothActionsFire_WhenPriorityIsZero(TwoInputActionDa
263263
Assert.That(action2WasPerformed, Is.True);
264264
}
265265

266-
[Test] // TODO: Darren, Is this what we want in the future? Possibly not after talking to Hakan, we shouldn't disable priority with settings.
267-
[Category("Actions Priority")]
268-
[TestCase("ctrl", "shift", "x", false)]
269-
[TestCase("ctrl", "shift", "x", true)]
270-
public void Actions_Priority_ShortcutConsumeDisabled_BothPerformDespiteDifferentPriorities(string sharedModifier, string sharedModifier2, string binding1, bool legacyComposites)
271-
{
272-
var previousShortcutConsume = InputSystem.settings.shortcutKeysConsumeInput;
273-
try
274-
{
275-
InputSystem.settings.shortcutKeysConsumeInput = false;
276-
var keyboard = InputSystem.AddDevice<Keyboard>();
277-
278-
var map = new InputActionMap("map");
279-
var action1 = map.AddAction("action1");
280-
action1.AddCompositeBinding((legacyComposites ? "ButtonWithOneModifier" : "OneModifier") + "(overrideModifiersNeedToBePressedFirst)")
281-
.With("Modifier", "<Keyboard>/" + sharedModifier)
282-
.With(legacyComposites ? "Button" : "Binding", "<Keyboard>/" + binding1);
283-
284-
var action2 = map.AddAction("action2");
285-
action2.AddCompositeBinding((legacyComposites ? "ButtonWithOneModifier" : "OneModifier") + "(overrideModifiersNeedToBePressedFirst)")
286-
.With("Modifier", "<Keyboard>/" + sharedModifier2)
287-
.With(legacyComposites ? "Button" : "Binding", "<Keyboard>/" + binding1);
288-
289-
action1.Priority = 0;
290-
action2.Priority = 10;
291-
292-
map.Enable();
293-
294-
var action1WasPerformed = false;
295-
var action2WasPerformed = false;
296-
action1.performed += _ => action1WasPerformed = true;
297-
action2.performed += _ => action2WasPerformed = true;
298-
299-
Press((ButtonControl)keyboard[sharedModifier], queueEventOnly: true);
300-
Press((ButtonControl)keyboard[sharedModifier2], queueEventOnly: true);
301-
Press((ButtonControl)keyboard[binding1], queueEventOnly: true);
302-
InputSystem.Update();
303-
304-
Assert.That(action1WasPerformed, Is.True);
305-
Assert.That(action2WasPerformed, Is.True);
306-
}
307-
finally
308-
{
309-
InputSystem.settings.shortcutKeysConsumeInput = previousShortcutConsume;
310-
}
311-
}
312-
313266
private static IEnumerable<TwoInputActionDataWrapper<InputAction, InputAction>> TwoInputActionNoConflictingBindingTestCases()
314267
{
315268
InputActionMap map = new InputActionMap("map");

0 commit comments

Comments
 (0)