mirror of
https://github.com/ppy/osu
synced 2025-01-17 11:30:52 +00:00
Add test cases for transitioning into pause overlay and into results
This commit is contained in:
parent
b353b69587
commit
af049004dd
@ -10,6 +10,9 @@ using osu.Game.Scoring;
|
|||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -26,17 +29,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
((DimAccessiblePlayer)Player).UpdateBindables();
|
((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>
|
/// <summary>
|
||||||
/// Check if the fade container is properly being reset when screen dim is disabled.
|
/// Check if the fade container is properly being reset when screen dim is disabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -45,11 +37,53 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
AddStep("Test User Undimming", () => ((DimAccessiblePlayer)Player).DimEnabled.Value = false);
|
AddStep("Test User Undimming", () => ((DimAccessiblePlayer)Player).DimEnabled.Value = false);
|
||||||
AddWaitStep(5, "Wait for dim");
|
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();
|
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
|
private class DimAccessiblePlayer : Player
|
||||||
{
|
{
|
||||||
public Bindable<bool> DimEnabled;
|
public Bindable<bool> DimEnabled;
|
||||||
@ -71,17 +105,22 @@ namespace osu.Game.Tests.Visual
|
|||||||
return ((FadeAccessibleBackground)Background).AssertUndimmed();
|
return ((FadeAccessibleBackground)Background).AssertUndimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
public void TriggerExit()
|
||||||
{
|
{
|
||||||
public bool AssertDimState()
|
OnExiting(new PlaySongSelect());
|
||||||
{
|
}
|
||||||
return FadeContainer.Colour == OsuColour.Gray(1 - (float)DimLevel);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public bool AssertUndimmed()
|
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
||||||
{
|
{
|
||||||
return FadeContainer.Colour == OsuColour.Gray(1.0f);
|
public bool AssertDimState()
|
||||||
}
|
{
|
||||||
|
return FadeContainer.Colour == OsuColour.Gray(1 - (float)DimLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AssertUndimmed()
|
||||||
|
{
|
||||||
|
return FadeContainer.Colour == Color4.White;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,8 +299,6 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
this.Push(CreateResults(score));
|
this.Push(CreateResults(score));
|
||||||
|
|
||||||
Background.UpdateDim.Value = false;
|
|
||||||
|
|
||||||
onCompletionEvent = null;
|
onCompletionEvent = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user