Add visual test for background dimming

This commit is contained in:
David Zhao 2019-02-15 16:38:27 +09:00
parent 6da9f94ae3
commit ad9dae975d
2 changed files with 21 additions and 13 deletions

View File

@ -1 +0,0 @@
osu

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using NUnit.Framework.Internal; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -13,22 +13,25 @@ using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
[TestFixture]
public class TestCaseBackgroundScreenBeatmap : TestCasePlayer public class TestCaseBackgroundScreenBeatmap : TestCasePlayer
{ {
[BackgroundDependencyLoader]
private void load(OsuConfigManager manager)
{
LoadScreen(new DimAccessiblePlayer());
}
[Test] [Test]
public void EnableUserDimTest() public void EnableUserDimTest()
{ {
AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).EnableScreenDim()); AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).EnableScreenDim());
AddWaitStep(5, "Wait for dim");
AddAssert("Check screen dim", () => ((DimAccessiblePlayer)Player).AssertDimState()); AddAssert("Check screen dim", () => ((DimAccessiblePlayer)Player).AssertDimState());
} }
[Test]
public void DisableUserDimTest()
{
AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).DisableScreenDim());
AddWaitStep(5, "Wait for dim");
AddAssert("Check screen dim", () => ((DimAccessiblePlayer)Player).AssertUndimmed());
}
protected override Player CreatePlayer(Ruleset ruleset) => new DimAccessiblePlayer(); protected override Player CreatePlayer(Ruleset ruleset) => new DimAccessiblePlayer();
private class DimAccessiblePlayer : Player private class DimAccessiblePlayer : Player
@ -49,17 +52,23 @@ namespace osu.Game.Tests.Visual
return ((FadeAccessibleBackground)Background).AssertDimState(); return ((FadeAccessibleBackground)Background).AssertDimState();
} }
public bool AssertUndimmed()
{
return ((FadeAccessibleBackground)Background).AssertUndimmed();
}
private class FadeAccessibleBackground : BackgroundScreenBeatmap private class FadeAccessibleBackground : BackgroundScreenBeatmap
{ {
public bool AssertDimState() public bool AssertDimState()
{ {
return FadeContainer.Colour == OsuColour.Gray(BackgroundOpacity); return FadeContainer.Colour == OsuColour.Gray(BackgroundOpacity);
} }
}
}
}
internal class SetupAttribute : Attribute public bool AssertUndimmed()
{ {
return FadeContainer.Colour == OsuColour.Gray(1.0f);
}
}
}
} }
} }