diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderPlacementBlueprint.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderPlacementBlueprint.cs index a452f93676..67a2e5a47c 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderPlacementBlueprint.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderPlacementBlueprint.cs @@ -280,8 +280,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor private void addClickStep(MouseButton button) { - AddStep($"press {button}", () => InputManager.PressButton(button)); - AddStep($"release {button}", () => InputManager.ReleaseButton(button)); + AddStep($"click {button}", () => InputManager.Click(button)); } private void assertPlaced(bool expected) => AddAssert($"slider {(expected ? "placed" : "not placed")}", () => (getSlider() != null) == expected); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs index 4743317fdd..e198a8504b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs @@ -41,11 +41,11 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("store time", () => time = Player.GameplayClockContainer.GameplayClock.CurrentTime); // test seek via keyboard - AddStep("seek with right arrow key", () => press(Key.Right)); + AddStep("seek with right arrow key", () => InputManager.Key(Key.Right)); AddAssert("time seeked forward", () => Player.GameplayClockContainer.GameplayClock.CurrentTime > time + 2000); AddStep("store time", () => time = Player.GameplayClockContainer.GameplayClock.CurrentTime); - AddStep("seek with left arrow key", () => press(Key.Left)); + AddStep("seek with left arrow key", () => InputManager.Key(Key.Left)); AddAssert("time seeked backward", () => Player.GameplayClockContainer.GameplayClock.CurrentTime < time); seekToBreak(0); @@ -67,11 +67,5 @@ namespace osu.Game.Tests.Visual.Gameplay BreakPeriod destBreak() => Beatmap.Value.Beatmap.Breaks.ElementAt(breakIndex); } - - private void press(Key key) - { - InputManager.PressKey(key); - InputManager.ReleaseKey(key); - } } } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs index fc9cbb073e..d69ac665cc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs @@ -86,7 +86,7 @@ namespace osu.Game.Tests.Visual.Gameplay { showOverlay(); - AddStep("Up arrow", () => press(Key.Up)); + AddStep("Up arrow", () => InputManager.Key(Key.Up)); AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected.Value); } @@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.Gameplay { showOverlay(); - AddStep("Down arrow", () => press(Key.Down)); + AddStep("Down arrow", () => InputManager.Key(Key.Down)); AddAssert("First button selected", () => getButton(0).Selected.Value); } @@ -110,11 +110,11 @@ namespace osu.Game.Tests.Visual.Gameplay { AddStep("Show overlay", () => failOverlay.Show()); - AddStep("Up arrow", () => press(Key.Up)); + AddStep("Up arrow", () => InputManager.Key(Key.Up)); AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value); - AddStep("Up arrow", () => press(Key.Up)); + AddStep("Up arrow", () => InputManager.Key(Key.Up)); AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value); - AddStep("Up arrow", () => press(Key.Up)); + AddStep("Up arrow", () => InputManager.Key(Key.Up)); AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value); } @@ -126,11 +126,11 @@ namespace osu.Game.Tests.Visual.Gameplay { AddStep("Show overlay", () => failOverlay.Show()); - AddStep("Down arrow", () => press(Key.Down)); + AddStep("Down arrow", () => InputManager.Key(Key.Down)); AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value); - AddStep("Down arrow", () => press(Key.Down)); + AddStep("Down arrow", () => InputManager.Key(Key.Down)); AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value); - AddStep("Down arrow", () => press(Key.Down)); + AddStep("Down arrow", () => InputManager.Key(Key.Down)); AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value); } @@ -177,7 +177,7 @@ namespace osu.Game.Tests.Visual.Gameplay { showOverlay(); - AddStep("Down arrow", () => press(Key.Down)); + AddStep("Down arrow", () => InputManager.Key(Key.Down)); AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1))); AddAssert("First button not selected", () => !getButton(0).Selected.Value); AddAssert("Second button selected", () => getButton(1).Selected.Value); @@ -195,7 +195,7 @@ namespace osu.Game.Tests.Visual.Gameplay }); AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1))); - AddStep("Up arrow", () => press(Key.Up)); + AddStep("Up arrow", () => InputManager.Key(Key.Up)); AddAssert("Second button not selected", () => !getButton(1).Selected.Value); AddAssert("First button selected", () => getButton(0).Selected.Value); } @@ -210,7 +210,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1))); AddStep("Unhover second button", () => InputManager.MoveMouseTo(Vector2.Zero)); - AddStep("Down arrow", () => press(Key.Down)); + AddStep("Down arrow", () => InputManager.Key(Key.Down)); AddAssert("First button selected", () => getButton(0).Selected.Value); // Initial state condition } @@ -246,8 +246,8 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("Select second button", () => { - press(Key.Down); - press(Key.Down); + InputManager.Key(Key.Down); + InputManager.Key(Key.Down); }); bool triggered = false; @@ -256,7 +256,7 @@ namespace osu.Game.Tests.Visual.Gameplay { lastAction = pauseOverlay.OnRetry; pauseOverlay.OnRetry = () => triggered = true; - press(Key.Enter); + InputManager.Key(Key.Enter); }); AddAssert("Action was triggered", () => @@ -290,12 +290,6 @@ namespace osu.Game.Tests.Visual.Gameplay private DialogButton getButton(int index) => pauseOverlay.Buttons.Skip(index).First(); - private void press(Key key) - { - InputManager.PressKey(key); - InputManager.ReleaseKey(key); - } - private void press(GlobalAction action) { globalActionContainer.TriggerPressed(action); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs index db65e91d17..6de85499c5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs @@ -32,11 +32,7 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestDefaultsWhenNotDatabased() { - AddStep("fire key", () => - { - InputManager.PressKey(Key.A); - InputManager.ReleaseKey(Key.A); - }); + AddStep("fire key", () => InputManager.Key(Key.A)); AddAssert("received key", () => receiver.ReceivedAction); } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs index d7a3f80256..87ab42fe60 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs @@ -40,11 +40,7 @@ namespace osu.Game.Tests.Visual.Gameplay void addPressKeyStep() { - AddStep($"Press {testKey} key", () => - { - InputManager.PressKey(testKey); - InputManager.ReleaseKey(testKey); - }); + AddStep($"Press {testKey} key", () => InputManager.Key(testKey)); } addPressKeyStep(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index ac0e8eb0d4..46dd91710a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -59,11 +59,7 @@ namespace osu.Game.Tests.Visual.Gameplay confirmClockRunning(false); confirmPauseOverlayShown(false); - AddStep("click to resume", () => - { - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); - }); + AddStep("click to resume", () => InputManager.Click(MouseButton.Left)); confirmClockRunning(true); } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs index 47dd47959d..b72960931f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs @@ -158,8 +158,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("much move with press", () => moveFunction = Scheduler.AddDelayed(() => { InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(-1, 0)); - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); + InputManager.Click(MouseButton.Left); }, 10, true)); AddWaitStep("move", 10); AddStep("stop move", () => moveFunction.Cancel()); diff --git a/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs b/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs index 2a4486812c..57d60cea9e 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs @@ -65,10 +65,8 @@ namespace osu.Game.Tests.Visual.Menus AddStep($"switch to ruleset {i} via shortcut", () => { InputManager.PressKey(Key.ControlLeft); - InputManager.PressKey(numberKey); - + InputManager.Key(numberKey); InputManager.ReleaseKey(Key.ControlLeft); - InputManager.ReleaseKey(numberKey); }); AddUntilStep("ruleset switched", () => rulesetSelector.Current.Value.Equals(expected)); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs index b1f6ee3e3a..e33d15cfff 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs @@ -71,11 +71,7 @@ namespace osu.Game.Tests.Visual.Multiplayer private void press(Key down) { - AddStep($"press {down}", () => - { - InputManager.PressKey(down); - InputManager.ReleaseKey(down); - }); + AddStep($"press {down}", () => InputManager.Key(down)); } [Test] diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs index 5963f806c6..d87854a7ea 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs @@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Navigation if (withUserPause) AddStep("pause", () => Game.Dependencies.Get().Stop(true)); - AddStep("press enter", () => pressAndRelease(Key.Enter)); + AddStep("press enter", () => InputManager.Key(Key.Enter)); AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null); AddUntilStep("wait for fail", () => player.HasFailed); @@ -122,11 +122,11 @@ namespace osu.Game.Tests.Visual.Navigation public void TestOpenOptionsAndExitWithEscape() { AddUntilStep("Wait for options to load", () => Game.Settings.IsLoaded); - AddStep("Enter menu", () => pressAndRelease(Key.Enter)); + AddStep("Enter menu", () => InputManager.Key(Key.Enter)); AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition)); AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left)); AddAssert("Options overlay was opened", () => Game.Settings.State.Value == Visibility.Visible); - AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape)); + AddStep("Hide options overlay using escape", () => InputManager.Key(Key.Escape)); AddAssert("Options overlay was closed", () => Game.Settings.State.Value == Visibility.Hidden); } @@ -158,10 +158,8 @@ namespace osu.Game.Tests.Visual.Navigation AddStep("Change ruleset to osu!taiko", () => { InputManager.PressKey(Key.ControlLeft); - InputManager.PressKey(Key.Number2); - + InputManager.Key(Key.Number2); InputManager.ReleaseKey(Key.ControlLeft); - InputManager.ReleaseKey(Key.Number2); }); AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType().Single().Current.Value.ID == 1); @@ -181,10 +179,8 @@ namespace osu.Game.Tests.Visual.Navigation AddStep("Change ruleset to osu!taiko", () => { InputManager.PressKey(Key.ControlLeft); - InputManager.PressKey(Key.Number2); - + InputManager.Key(Key.Number2); InputManager.ReleaseKey(Key.ControlLeft); - InputManager.ReleaseKey(Key.Number2); }); AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType().Single().Current.Value.ID == 1); @@ -193,7 +189,7 @@ namespace osu.Game.Tests.Visual.Navigation } private void pushEscape() => - AddStep("Press escape", () => pressAndRelease(Key.Escape)); + AddStep("Press escape", () => InputManager.Key(Key.Escape)); private void exitViaEscapeAndConfirm() { @@ -208,12 +204,6 @@ namespace osu.Game.Tests.Visual.Navigation ConfirmAtMainMenu(); } - private void pressAndRelease(Key key) - { - InputManager.PressKey(key); - InputManager.ReleaseKey(key); - } - private class TestSongSelect : PlaySongSelect { public ModSelectOverlay ModSelectOverlay => ModSelect; diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs index 0025a26baf..fca642ad6c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs @@ -103,11 +103,7 @@ namespace osu.Game.Tests.Visual.Online public void TestChannelShortcutKeys() { AddStep("Join channels", () => channels.ForEach(channel => channelManager.JoinChannel(channel))); - AddStep("Close channel selector", () => - { - InputManager.PressKey(Key.Escape); - InputManager.ReleaseKey(Key.Escape); - }); + AddStep("Close channel selector", () => InputManager.Key(Key.Escape)); AddUntilStep("Wait for close", () => chatOverlay.SelectionOverlayState == Visibility.Hidden); for (int zeroBasedIndex = 0; zeroBasedIndex < 10; ++zeroBasedIndex) @@ -216,9 +212,8 @@ namespace osu.Game.Tests.Visual.Online { var channelKey = Key.Number0 + number; InputManager.PressKey(Key.AltLeft); - InputManager.PressKey(channelKey); + InputManager.Key(channelKey); InputManager.ReleaseKey(Key.AltLeft); - InputManager.ReleaseKey(channelKey); } private void clickDrawable(Drawable d) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs index 987a4a67fe..8330b9b360 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs @@ -51,8 +51,7 @@ namespace osu.Game.Tests.Visual.Settings clickDelegate = Scheduler.AddDelayed(() => { - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); + InputManager.Click(MouseButton.Left); if (++buttonClicks == 2) { diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index cd97ffe9e7..aa531ba106 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -98,10 +98,8 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("select next and enter", () => { - InputManager.PressKey(Key.Down); - InputManager.ReleaseKey(Key.Down); - InputManager.PressKey(Key.Enter); - InputManager.ReleaseKey(Key.Enter); + InputManager.Key(Key.Down); + InputManager.Key(Key.Enter); }); AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); @@ -123,10 +121,8 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("select next and enter", () => { - InputManager.PressKey(Key.Enter); - InputManager.ReleaseKey(Key.Enter); - InputManager.PressKey(Key.Down); - InputManager.ReleaseKey(Key.Down); + InputManager.Key(Key.Enter); + InputManager.Key(Key.Down); }); AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); @@ -151,11 +147,9 @@ namespace osu.Game.Tests.Visual.SongSelect InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType() .First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap)); - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); + InputManager.Click(MouseButton.Left); - InputManager.PressKey(Key.Enter); - InputManager.ReleaseKey(Key.Enter); + InputManager.Key(Key.Enter); }); AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); @@ -182,8 +176,7 @@ namespace osu.Game.Tests.Visual.SongSelect InputManager.PressButton(MouseButton.Left); - InputManager.PressKey(Key.Enter); - InputManager.ReleaseKey(Key.Enter); + InputManager.Key(Key.Enter); InputManager.ReleaseButton(MouseButton.Left); }); @@ -567,10 +560,8 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("press ctrl+enter", () => { InputManager.PressKey(Key.ControlLeft); - InputManager.PressKey(Key.Enter); - + InputManager.Key(Key.Enter); InputManager.ReleaseKey(Key.ControlLeft); - InputManager.ReleaseKey(Key.Enter); }); AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); @@ -617,8 +608,7 @@ namespace osu.Game.Tests.Visual.SongSelect { InputManager.MoveMouseTo(difficultyIcon); - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); + InputManager.Click(MouseButton.Left); }); AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon)); @@ -647,8 +637,7 @@ namespace osu.Game.Tests.Visual.SongSelect { InputManager.MoveMouseTo(filteredIcon); - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); + InputManager.Click(MouseButton.Left); }); AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmap == filteredBeatmap); @@ -691,8 +680,7 @@ namespace osu.Game.Tests.Visual.SongSelect { InputManager.MoveMouseTo(difficultyIcon); - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); + InputManager.Click(MouseButton.Left); }); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3); @@ -738,8 +726,7 @@ namespace osu.Game.Tests.Visual.SongSelect { InputManager.MoveMouseTo(groupIcon); - InputManager.PressButton(MouseButton.Left); - InputManager.ReleaseButton(MouseButton.Left); + InputManager.Click(MouseButton.Left); }); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3); diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs index d0a2ca83e3..920b437f57 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs @@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.UserInterface }); AddStep("enter text", () => commentEditor.Current.Value = "text"); - AddStep("press Enter", () => press(Key.Enter)); + AddStep("press Enter", () => InputManager.Key(Key.Enter)); AddAssert("text committed", () => commentEditor.CommittedText == "text"); AddAssert("button is loading", () => commentEditor.IsLoading); @@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface InputManager.Click(MouseButton.Left); }); - AddStep("press Enter", () => press(Key.Enter)); + AddStep("press Enter", () => InputManager.Key(Key.Enter)); AddAssert("no text committed", () => commentEditor.CommittedText == null); AddAssert("button is not loading", () => !commentEditor.IsLoading); @@ -101,12 +101,6 @@ namespace osu.Game.Tests.Visual.UserInterface AddAssert("cancel action fired", () => cancellableCommentEditor.Cancelled); } - private void press(Key key) - { - InputManager.PressKey(key); - InputManager.ReleaseKey(key); - } - private class TestCommentEditor : CommentEditor { public new Bindable Current => base.Current;