Skip to content

Commit

Permalink
Update existing test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Oct 25, 2024
1 parent 7862073 commit e5562f4
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions osu.Framework.Tests/Visual/Input/TestSceneKeyBindingContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public void TestPressKeyBeforeKeyBindingContainerAdded()
AddAssert("ActionA released", () => releasedActions[0], () => Is.EqualTo(TestAction.ActionA));
}

/// <summary>
/// Unlike <see cref="TestPressKeyBeforeKeyBindingContainerAdded"/>, when an intermediate input manager is involved,
/// we expect the key binding container to be fed with any previously pressed key
/// (consider an osu!catch player pressing the left/right/dash keys before entering gameplay).
/// </summary>
[Test]
public void TestPressKeyBeforeKeyBindingContainerAdded_WithPassThroughInputManager()
{
Expand All @@ -142,15 +147,22 @@ public void TestPressKeyBeforeKeyBindingContainerAdded_WithPassThroughInputManag
};
});

AddAssert("only one action pressed", () => pressedActions, () => Has.Count.EqualTo(1));
AddAssert("ActionEnter pressed", () => pressedActions[0], () => Is.EqualTo(TestAction.ActionEnter));
AddAssert("no actions released", () => releasedActions, () => Is.Empty);

AddStep("press key A", () => InputManager.PressKey(Key.A));
AddAssert("only one action triggered", () => pressedActions, () => Has.Count.EqualTo(1));
AddAssert("ActionA triggered", () => pressedActions[0], () => Is.EqualTo(TestAction.ActionA));
AddAssert("two actions pressed", () => pressedActions, () => Has.Count.EqualTo(2));
AddAssert("ActionA pressed", () => pressedActions[1], () => Is.EqualTo(TestAction.ActionA));
AddAssert("no actions released", () => releasedActions, () => Is.Empty);

AddStep("release key A", () => InputManager.ReleaseKey(Key.A));
AddAssert("only one action triggered", () => pressedActions, () => Has.Count.EqualTo(1));
AddAssert("only one action released", () => releasedActions, () => Has.Count.EqualTo(1));
AddAssert("one action released", () => releasedActions, () => Has.Count.EqualTo(1));
AddAssert("ActionA released", () => releasedActions[0], () => Is.EqualTo(TestAction.ActionA));

AddStep("release enter", () => InputManager.ReleaseKey(Key.Enter));
AddAssert("two actions released", () => releasedActions, () => Has.Count.EqualTo(2));
AddAssert("ActionEnter released", () => releasedActions[1], () => Is.EqualTo(TestAction.ActionEnter));
}

[Test]
Expand Down

0 comments on commit e5562f4

Please sign in to comment.