diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 1a41bff84c..dc078aeeea 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -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(); } - /// - /// Check if the fade container is properly being faded when screen dim is enabled. - /// - [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()); - } - /// /// Check if the fade container is properly being reset when screen dim is disabled. /// @@ -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()); + } + + /// + /// Check if the fade container is properly being faded when screen dim is enabled. + /// + [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()); + } + + /// + /// Check if the fade container retains dim when pausing + /// + [Test] + public void PauseTest() + { + AddStep("Transition to Results", () => ((DimAccessiblePlayer)Player).TriggerExit()); + AddWaitStep(5, "Wait for dim"); + AddAssert("Screen is dimmed", () => ((DimAccessiblePlayer)Player).AssertDimState()); + } + + /// + /// Check if the fade container removes user dim when leaving the player + /// + [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 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; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a022088d18..2c0172b272 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -299,8 +299,6 @@ namespace osu.Game.Screens.Play this.Push(CreateResults(score)); - Background.UpdateDim.Value = false; - onCompletionEvent = null; }); }