1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 04:02:57 +08:00

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.
using System;
using NUnit.Framework.Internal;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Configuration;
using osu.Game.Graphics;
@ -13,22 +13,25 @@ using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
{
[TestFixture]
public class TestCaseBackgroundScreenBeatmap : TestCasePlayer
{
[BackgroundDependencyLoader]
private void load(OsuConfigManager manager)
{
LoadScreen(new DimAccessiblePlayer());
}
[Test]
public void EnableUserDimTest()
{
AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).EnableScreenDim());
AddWaitStep(5, "Wait for dim");
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();
private class DimAccessiblePlayer : Player
@ -49,17 +52,23 @@ namespace osu.Game.Tests.Visual
return ((FadeAccessibleBackground)Background).AssertDimState();
}
public bool AssertUndimmed()
{
return ((FadeAccessibleBackground)Background).AssertUndimmed();
}
private class FadeAccessibleBackground : BackgroundScreenBeatmap
{
public bool AssertDimState()
{
return FadeContainer.Colour == OsuColour.Gray(BackgroundOpacity);
}
public bool AssertUndimmed()
{
return FadeContainer.Colour == OsuColour.Gray(1.0f);
}
}
}
}
internal class SetupAttribute : Attribute
{
}
}