1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 19:27:24 +08:00

Refactor tests

This commit is contained in:
Dean Herbert 2020-04-21 12:26:43 +09:00
parent a91c63819b
commit 3b0099c687

View File

@ -46,46 +46,54 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestCancelCompletionOnRewind() public void TestCancelCompletionOnRewind()
{ {
cancelCompletionSteps(); complete();
cancel();
AddAssert("no attempt to push ranking", () => !((FakeRankingPushPlayer)Player).GotoRankingInvoked); checkNoRanking();
} }
[Test] [Test]
public void TestReCompleteAfterCancellation() public void TestReCompleteAfterCancellation()
{ {
cancelCompletionSteps(); complete();
cancel();
// Attempt completing again. complete();
AddStep("seek to completion again", () => track.Seek(5000));
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
AddUntilStep("attempted to push ranking", () => ((FakeRankingPushPlayer)Player).GotoRankingInvoked); AddUntilStep("attempted to push ranking", () => ((FakeRankingPushPlayer)Player).GotoRankingInvoked);
} }
/// <summary> /// <summary>
/// Tests whether can still pause after cancelling completion /// Tests whether can still pause after cancelling completion by reverting <see cref="IScreen.ValidForResume"/> back to true.
/// by reverting <see cref="IScreen.ValidForResume"/> back to true.
/// </summary> /// </summary>
[Test] [Test]
public void TestCanPauseAfterCancellation() public void TestCanPauseAfterCancellation()
{ {
cancelCompletionSteps(); complete();
cancel();
AddStep("pause", () => Player.Pause()); AddStep("pause", () => Player.Pause());
AddAssert("paused successfully", () => Player.GameplayClockContainer.IsPaused.Value); AddAssert("paused successfully", () => Player.GameplayClockContainer.IsPaused.Value);
checkNoRanking();
} }
private void cancelCompletionSteps() private void complete()
{ {
AddStep("seek to completion", () => track.Seek(5000)); AddStep("seek to completion", () => track.Seek(5000));
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value); AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
}
private void cancel()
{
AddStep("rewind to cancel", () => track.Seek(4000)); AddStep("rewind to cancel", () => track.Seek(4000));
AddUntilStep("completion cleared by processor", () => !Player.ScoreProcessor.HasCompleted.Value); AddUntilStep("completion cleared by processor", () => !Player.ScoreProcessor.HasCompleted.Value);
}
private void checkNoRanking()
{
// wait to ensure there was no attempt of pushing the results screen. // wait to ensure there was no attempt of pushing the results screen.
AddWaitStep("wait", resultsDisplayWaitCount); AddWaitStep("wait", resultsDisplayWaitCount);
AddAssert("no attempt to push ranking", () => !((FakeRankingPushPlayer)Player).GotoRankingInvoked);
} }
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)