Add test cases for transitioning into pause overlay and into results

This commit is contained in:
David Zhao 2019-02-18 19:53:55 +09:00
parent b353b69587
commit af049004dd
2 changed files with 60 additions and 23 deletions

View File

@ -10,6 +10,9 @@ using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Play;
using osu.Game.Screens.Select;
using osu.Game.Users;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual
{
@ -26,17 +29,6 @@ namespace osu.Game.Tests.Visual
((DimAccessiblePlayer)Player).UpdateBindables();
}
/// <summary>
/// Check if the fade container is properly being faded when screen dim is enabled.
/// </summary>
[Test]
public void EnableUserDimTest()
{
AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).DimEnabled.Value = true);
AddWaitStep(5, "Wait for dim");
AddAssert("Check screen dim", () => ((DimAccessiblePlayer)Player).AssertDimState());
}
/// <summary>
/// Check if the fade container is properly being reset when screen dim is disabled.
/// </summary>
@ -45,11 +37,53 @@ namespace osu.Game.Tests.Visual
{
AddStep("Test User Undimming", () => ((DimAccessiblePlayer)Player).DimEnabled.Value = false);
AddWaitStep(5, "Wait for dim");
AddAssert("Check screen dim", () => ((DimAccessiblePlayer)Player).AssertUndimmed());
AddAssert("Screen is undimmed", () => ((DimAccessiblePlayer)Player).AssertUndimmed());
}
/// <summary>
/// Check if the fade container is properly being faded when screen dim is enabled.
/// </summary>
[Test]
public void EnableUserDimTest()
{
AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).DimEnabled.Value = true);
AddWaitStep(5, "Wait for dim");
AddAssert("Screen is dimmed", () => ((DimAccessiblePlayer)Player).AssertDimState());
}
/// <summary>
/// Check if the fade container retains dim when pausing
/// </summary>
[Test]
public void PauseTest()
{
AddStep("Transition to Results", () => ((DimAccessiblePlayer)Player).TriggerExit());
AddWaitStep(5, "Wait for dim");
AddAssert("Screen is dimmed", () => ((DimAccessiblePlayer)Player).AssertDimState());
}
/// <summary>
/// Check if the fade container removes user dim when leaving the player
/// </summary>
[Test]
public void TransitionTest()
{
AddStep("Transition to Results", () => LoadScreen(new FadeAccesibleResults(new ScoreInfo { User = new User { Username = "osu!" }})));
AddWaitStep(5, "Wait for dim");
AddAssert("Screen is undimmed", () => ((DimAccessiblePlayer)Player).AssertUndimmed());
}
protected override Player CreatePlayer(Ruleset ruleset) => new DimAccessiblePlayer();
private class FadeAccesibleResults : SoloResults
{
public FadeAccesibleResults(ScoreInfo score) : base(score)
{
}
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground();
}
private class DimAccessiblePlayer : Player
{
public Bindable<bool> DimEnabled;
@ -71,17 +105,22 @@ namespace osu.Game.Tests.Visual
return ((FadeAccessibleBackground)Background).AssertUndimmed();
}
private class FadeAccessibleBackground : BackgroundScreenBeatmap
public void TriggerExit()
{
public bool AssertDimState()
{
return FadeContainer.Colour == OsuColour.Gray(1 - (float)DimLevel);
}
OnExiting(new PlaySongSelect());
}
}
public bool AssertUndimmed()
{
return FadeContainer.Colour == OsuColour.Gray(1.0f);
}
private class FadeAccessibleBackground : BackgroundScreenBeatmap
{
public bool AssertDimState()
{
return FadeContainer.Colour == OsuColour.Gray(1 - (float)DimLevel);
}
public bool AssertUndimmed()
{
return FadeContainer.Colour == Color4.White;
}
}
}

View File

@ -299,8 +299,6 @@ namespace osu.Game.Screens.Play
this.Push(CreateResults(score));
Background.UpdateDim.Value = false;
onCompletionEvent = null;
});
}