1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Make test actually test things

This commit is contained in:
Dean Herbert 2022-08-16 14:17:28 +09:00
parent 6761f869f9
commit 9a1a7bae89
2 changed files with 32 additions and 8 deletions

View File

@ -29,6 +29,7 @@ using osu.Game.Screens.Play;
using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Utils; using osu.Game.Utils;
using osuTK.Input; using osuTK.Input;
using SkipOverlay = osu.Game.Screens.Play.SkipOverlay;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
@ -98,7 +99,13 @@ namespace osu.Game.Tests.Visual.Gameplay
private void prepareBeatmap() private void prepareBeatmap()
{ {
var workingBeatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); var workingBeatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
// Add intro time to test quick retry skipping (TestQuickRetry).
workingBeatmap.BeatmapInfo.AudioLeadIn = 60000;
// Turn on epilepsy warning to test warning display (TestEpilepsyWarning).
workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning; workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning;
Beatmap.Value = workingBeatmap; Beatmap.Value = workingBeatmap;
foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>()) foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>())
@ -356,17 +363,32 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestQuickRetry() public void TestQuickRetry()
{ {
TestPlayer getCurrentPlayer() => loader.CurrentPlayer as TestPlayer;
bool checkSkipButtonVisible() => player.ChildrenOfType<SkipOverlay>().FirstOrDefault()?.IsButtonVisible == true;
TestPlayer previousPlayer = null;
AddStep("load dummy beatmap", () => resetPlayer(false)); AddStep("load dummy beatmap", () => resetPlayer(false));
AddUntilStep("wait for current", () => player.IsCurrentScreen());
AddStep("Restart map normally", () => player.Restart()); AddUntilStep("wait for current", () => getCurrentPlayer()?.IsCurrentScreen() == true);
AddUntilStep("wait for current", () => player.IsCurrentScreen()); AddStep("store previous player", () => previousPlayer = getCurrentPlayer());
AddStep("Restart map with quick retry hotkey", () => AddStep("Restart map normally", () => getCurrentPlayer().Restart());
{ AddUntilStep("wait for load", () => getCurrentPlayer()?.LoadedBeatmapSuccessfully == true);
InputManager.UseParentInput = true;
InputManager.PressKey(Key.Tilde); AddUntilStep("restart completed", () => getCurrentPlayer() != null && getCurrentPlayer() != previousPlayer);
}); AddStep("store previous player", () => previousPlayer = getCurrentPlayer());
AddUntilStep("skip button visible", checkSkipButtonVisible);
AddStep("press quick retry key", () => InputManager.PressKey(Key.Tilde));
AddUntilStep("restart completed", () => getCurrentPlayer() != null && getCurrentPlayer() != previousPlayer);
AddStep("release quick retry key", () => InputManager.ReleaseKey(Key.Tilde));
AddUntilStep("wait for load", () => getCurrentPlayer()?.LoadedBeatmapSuccessfully == true);
AddUntilStep("time reached zero", () => getCurrentPlayer()?.GameplayClockContainer.CurrentTime > 0);
AddUntilStep("skip button not visible", () => !checkSkipButtonVisible());
} }
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault(); private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();

View File

@ -46,6 +46,8 @@ namespace osu.Game.Screens.Play
[Resolved] [Resolved]
private IGameplayClock gameplayClock { get; set; } private IGameplayClock gameplayClock { get; set; }
internal bool IsButtonVisible => fadeContainer.State == Visibility.Visible && buttonContainer.State.Value == Visibility.Visible;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
/// <summary> /// <summary>