1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 18:12:56 +08:00

Simplify input buttons/keys in tests

This commit is contained in:
Joehu 2020-11-05 06:41:56 -08:00
parent d7c30f9b42
commit ef3c918a3c
14 changed files with 46 additions and 113 deletions

View File

@ -280,8 +280,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
private void addClickStep(MouseButton button) private void addClickStep(MouseButton button)
{ {
AddStep($"press {button}", () => InputManager.PressButton(button)); AddStep($"click {button}", () => InputManager.Click(button));
AddStep($"release {button}", () => InputManager.ReleaseButton(button));
} }
private void assertPlaced(bool expected) => AddAssert($"slider {(expected ? "placed" : "not placed")}", () => (getSlider() != null) == expected); private void assertPlaced(bool expected) => AddAssert($"slider {(expected ? "placed" : "not placed")}", () => (getSlider() != null) == expected);

View File

@ -41,11 +41,11 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("store time", () => time = Player.GameplayClockContainer.GameplayClock.CurrentTime); AddStep("store time", () => time = Player.GameplayClockContainer.GameplayClock.CurrentTime);
// test seek via keyboard // 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); AddAssert("time seeked forward", () => Player.GameplayClockContainer.GameplayClock.CurrentTime > time + 2000);
AddStep("store time", () => time = Player.GameplayClockContainer.GameplayClock.CurrentTime); 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); AddAssert("time seeked backward", () => Player.GameplayClockContainer.GameplayClock.CurrentTime < time);
seekToBreak(0); seekToBreak(0);
@ -67,11 +67,5 @@ namespace osu.Game.Tests.Visual.Gameplay
BreakPeriod destBreak() => Beatmap.Value.Beatmap.Breaks.ElementAt(breakIndex); BreakPeriod destBreak() => Beatmap.Value.Beatmap.Breaks.ElementAt(breakIndex);
} }
private void press(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
} }
} }

View File

@ -86,7 +86,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
showOverlay(); showOverlay();
AddStep("Up arrow", () => press(Key.Up)); AddStep("Up arrow", () => InputManager.Key(Key.Up));
AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected.Value); AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected.Value);
} }
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
showOverlay(); showOverlay();
AddStep("Down arrow", () => press(Key.Down)); AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddAssert("First button selected", () => getButton(0).Selected.Value); AddAssert("First button selected", () => getButton(0).Selected.Value);
} }
@ -110,11 +110,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
AddStep("Show overlay", () => failOverlay.Show()); 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); 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); 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); 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("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); 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); 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); AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
} }
@ -177,7 +177,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
showOverlay(); showOverlay();
AddStep("Down arrow", () => press(Key.Down)); AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1))); AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
AddAssert("First button not selected", () => !getButton(0).Selected.Value); AddAssert("First button not selected", () => !getButton(0).Selected.Value);
AddAssert("Second button selected", () => getButton(1).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("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("Second button not selected", () => !getButton(1).Selected.Value);
AddAssert("First button selected", () => getButton(0).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("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
AddStep("Unhover second button", () => InputManager.MoveMouseTo(Vector2.Zero)); 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 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", () => AddStep("Select second button", () =>
{ {
press(Key.Down); InputManager.Key(Key.Down);
press(Key.Down); InputManager.Key(Key.Down);
}); });
bool triggered = false; bool triggered = false;
@ -256,7 +256,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
lastAction = pauseOverlay.OnRetry; lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true; pauseOverlay.OnRetry = () => triggered = true;
press(Key.Enter); InputManager.Key(Key.Enter);
}); });
AddAssert("Action was triggered", () => 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 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) private void press(GlobalAction action)
{ {
globalActionContainer.TriggerPressed(action); globalActionContainer.TriggerPressed(action);

View File

@ -32,11 +32,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestDefaultsWhenNotDatabased() public void TestDefaultsWhenNotDatabased()
{ {
AddStep("fire key", () => AddStep("fire key", () => InputManager.Key(Key.A));
{
InputManager.PressKey(Key.A);
InputManager.ReleaseKey(Key.A);
});
AddAssert("received key", () => receiver.ReceivedAction); AddAssert("received key", () => receiver.ReceivedAction);
} }

View File

@ -40,11 +40,7 @@ namespace osu.Game.Tests.Visual.Gameplay
void addPressKeyStep() void addPressKeyStep()
{ {
AddStep($"Press {testKey} key", () => AddStep($"Press {testKey} key", () => InputManager.Key(testKey));
{
InputManager.PressKey(testKey);
InputManager.ReleaseKey(testKey);
});
} }
addPressKeyStep(); addPressKeyStep();

View File

@ -59,11 +59,7 @@ namespace osu.Game.Tests.Visual.Gameplay
confirmClockRunning(false); confirmClockRunning(false);
confirmPauseOverlayShown(false); confirmPauseOverlayShown(false);
AddStep("click to resume", () => AddStep("click to resume", () => InputManager.Click(MouseButton.Left));
{
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
});
confirmClockRunning(true); confirmClockRunning(true);
} }

View File

@ -158,8 +158,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("much move with press", () => moveFunction = Scheduler.AddDelayed(() => AddStep("much move with press", () => moveFunction = Scheduler.AddDelayed(() =>
{ {
InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(-1, 0)); InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(-1, 0));
InputManager.PressButton(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
}, 10, true)); }, 10, true));
AddWaitStep("move", 10); AddWaitStep("move", 10);
AddStep("stop move", () => moveFunction.Cancel()); AddStep("stop move", () => moveFunction.Cancel());

View File

@ -65,10 +65,8 @@ namespace osu.Game.Tests.Visual.Menus
AddStep($"switch to ruleset {i} via shortcut", () => AddStep($"switch to ruleset {i} via shortcut", () =>
{ {
InputManager.PressKey(Key.ControlLeft); InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(numberKey); InputManager.Key(numberKey);
InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(numberKey);
}); });
AddUntilStep("ruleset switched", () => rulesetSelector.Current.Value.Equals(expected)); AddUntilStep("ruleset switched", () => rulesetSelector.Current.Value.Equals(expected));

View File

@ -71,11 +71,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void press(Key down) private void press(Key down)
{ {
AddStep($"press {down}", () => AddStep($"press {down}", () => InputManager.Key(down));
{
InputManager.PressKey(down);
InputManager.ReleaseKey(down);
});
} }
[Test] [Test]

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Navigation
if (withUserPause) if (withUserPause)
AddStep("pause", () => Game.Dependencies.Get<MusicController>().Stop(true)); AddStep("pause", () => Game.Dependencies.Get<MusicController>().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 player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
AddUntilStep("wait for fail", () => player.HasFailed); AddUntilStep("wait for fail", () => player.HasFailed);
@ -122,11 +122,11 @@ namespace osu.Game.Tests.Visual.Navigation
public void TestOpenOptionsAndExitWithEscape() public void TestOpenOptionsAndExitWithEscape()
{ {
AddUntilStep("Wait for options to load", () => Game.Settings.IsLoaded); 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("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition));
AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left)); AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left));
AddAssert("Options overlay was opened", () => Game.Settings.State.Value == Visibility.Visible); 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); 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", () => AddStep("Change ruleset to osu!taiko", () =>
{ {
InputManager.PressKey(Key.ControlLeft); InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Number2); InputManager.Key(Key.Number2);
InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.Number2);
}); });
AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1); AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1);
@ -181,10 +179,8 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("Change ruleset to osu!taiko", () => AddStep("Change ruleset to osu!taiko", () =>
{ {
InputManager.PressKey(Key.ControlLeft); InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Number2); InputManager.Key(Key.Number2);
InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.Number2);
}); });
AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1); AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1);
@ -193,7 +189,7 @@ namespace osu.Game.Tests.Visual.Navigation
} }
private void pushEscape() => private void pushEscape() =>
AddStep("Press escape", () => pressAndRelease(Key.Escape)); AddStep("Press escape", () => InputManager.Key(Key.Escape));
private void exitViaEscapeAndConfirm() private void exitViaEscapeAndConfirm()
{ {
@ -208,12 +204,6 @@ namespace osu.Game.Tests.Visual.Navigation
ConfirmAtMainMenu(); ConfirmAtMainMenu();
} }
private void pressAndRelease(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
private class TestSongSelect : PlaySongSelect private class TestSongSelect : PlaySongSelect
{ {
public ModSelectOverlay ModSelectOverlay => ModSelect; public ModSelectOverlay ModSelectOverlay => ModSelect;

View File

@ -103,11 +103,7 @@ namespace osu.Game.Tests.Visual.Online
public void TestChannelShortcutKeys() public void TestChannelShortcutKeys()
{ {
AddStep("Join channels", () => channels.ForEach(channel => channelManager.JoinChannel(channel))); AddStep("Join channels", () => channels.ForEach(channel => channelManager.JoinChannel(channel)));
AddStep("Close channel selector", () => AddStep("Close channel selector", () => InputManager.Key(Key.Escape));
{
InputManager.PressKey(Key.Escape);
InputManager.ReleaseKey(Key.Escape);
});
AddUntilStep("Wait for close", () => chatOverlay.SelectionOverlayState == Visibility.Hidden); AddUntilStep("Wait for close", () => chatOverlay.SelectionOverlayState == Visibility.Hidden);
for (int zeroBasedIndex = 0; zeroBasedIndex < 10; ++zeroBasedIndex) for (int zeroBasedIndex = 0; zeroBasedIndex < 10; ++zeroBasedIndex)
@ -216,9 +212,8 @@ namespace osu.Game.Tests.Visual.Online
{ {
var channelKey = Key.Number0 + number; var channelKey = Key.Number0 + number;
InputManager.PressKey(Key.AltLeft); InputManager.PressKey(Key.AltLeft);
InputManager.PressKey(channelKey); InputManager.Key(channelKey);
InputManager.ReleaseKey(Key.AltLeft); InputManager.ReleaseKey(Key.AltLeft);
InputManager.ReleaseKey(channelKey);
} }
private void clickDrawable(Drawable d) private void clickDrawable(Drawable d)

View File

@ -51,8 +51,7 @@ namespace osu.Game.Tests.Visual.Settings
clickDelegate = Scheduler.AddDelayed(() => clickDelegate = Scheduler.AddDelayed(() =>
{ {
InputManager.PressButton(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
if (++buttonClicks == 2) if (++buttonClicks == 2)
{ {

View File

@ -98,10 +98,8 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select next and enter", () => AddStep("select next and enter", () =>
{ {
InputManager.PressKey(Key.Down); InputManager.Key(Key.Down);
InputManager.ReleaseKey(Key.Down); InputManager.Key(Key.Enter);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
@ -123,10 +121,8 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select next and enter", () => AddStep("select next and enter", () =>
{ {
InputManager.PressKey(Key.Enter); InputManager.Key(Key.Enter);
InputManager.ReleaseKey(Key.Enter); InputManager.Key(Key.Down);
InputManager.PressKey(Key.Down);
InputManager.ReleaseKey(Key.Down);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
@ -151,11 +147,9 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>() InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap)); .First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap));
InputManager.PressButton(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.PressKey(Key.Enter); InputManager.Key(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
@ -182,8 +176,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.PressButton(MouseButton.Left); InputManager.PressButton(MouseButton.Left);
InputManager.PressKey(Key.Enter); InputManager.Key(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
InputManager.ReleaseButton(MouseButton.Left); InputManager.ReleaseButton(MouseButton.Left);
}); });
@ -567,10 +560,8 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("press ctrl+enter", () => AddStep("press ctrl+enter", () =>
{ {
InputManager.PressKey(Key.ControlLeft); InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Enter); InputManager.Key(Key.Enter);
InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.Enter);
}); });
AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader);
@ -617,8 +608,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
InputManager.MoveMouseTo(difficultyIcon); InputManager.MoveMouseTo(difficultyIcon);
InputManager.PressButton(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
}); });
AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon)); AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon));
@ -647,8 +637,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
InputManager.MoveMouseTo(filteredIcon); InputManager.MoveMouseTo(filteredIcon);
InputManager.PressButton(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
}); });
AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmap == filteredBeatmap); AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmap == filteredBeatmap);
@ -691,8 +680,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
InputManager.MoveMouseTo(difficultyIcon); InputManager.MoveMouseTo(difficultyIcon);
InputManager.PressButton(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
}); });
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);
@ -738,8 +726,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
InputManager.MoveMouseTo(groupIcon); InputManager.MoveMouseTo(groupIcon);
InputManager.PressButton(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
}); });
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.UserInterface
}); });
AddStep("enter text", () => commentEditor.Current.Value = "text"); 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("text committed", () => commentEditor.CommittedText == "text");
AddAssert("button is loading", () => commentEditor.IsLoading); AddAssert("button is loading", () => commentEditor.IsLoading);
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface
InputManager.Click(MouseButton.Left); 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("no text committed", () => commentEditor.CommittedText == null);
AddAssert("button is not loading", () => !commentEditor.IsLoading); AddAssert("button is not loading", () => !commentEditor.IsLoading);
@ -101,12 +101,6 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("cancel action fired", () => cancellableCommentEditor.Cancelled); AddAssert("cancel action fired", () => cancellableCommentEditor.Cancelled);
} }
private void press(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
private class TestCommentEditor : CommentEditor private class TestCommentEditor : CommentEditor
{ {
public new Bindable<string> Current => base.Current; public new Bindable<string> Current => base.Current;