2019-02-15 15:17:01 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2019-02-15 15:38:27 +08:00
|
|
|
using NUnit.Framework;
|
2019-02-15 15:17:01 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Screens;
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
{
|
2019-02-15 15:38:27 +08:00
|
|
|
[TestFixture]
|
2019-02-15 15:17:01 +08:00
|
|
|
public class TestCaseBackgroundScreenBeatmap : TestCasePlayer
|
|
|
|
{
|
2019-02-15 15:50:37 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Check if the fade container is properly being faded when screen dim is enabled.
|
|
|
|
/// </summary>
|
2019-02-15 15:17:01 +08:00
|
|
|
[Test]
|
|
|
|
public void EnableUserDimTest()
|
|
|
|
{
|
|
|
|
AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).EnableScreenDim());
|
2019-02-15 15:38:27 +08:00
|
|
|
AddWaitStep(5, "Wait for dim");
|
2019-02-15 15:17:01 +08:00
|
|
|
AddAssert("Check screen dim", () => ((DimAccessiblePlayer)Player).AssertDimState());
|
|
|
|
}
|
|
|
|
|
2019-02-15 15:50:37 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Check if the fade container is properly being reset when screen dim is disabled.
|
|
|
|
/// </summary>
|
2019-02-15 15:38:27 +08:00
|
|
|
[Test]
|
|
|
|
public void DisableUserDimTest()
|
|
|
|
{
|
|
|
|
AddStep("Test User Dimming", () => ((DimAccessiblePlayer)Player).DisableScreenDim());
|
|
|
|
AddWaitStep(5, "Wait for dim");
|
|
|
|
AddAssert("Check screen dim", () => ((DimAccessiblePlayer)Player).AssertUndimmed());
|
|
|
|
}
|
|
|
|
|
2019-02-15 15:17:01 +08:00
|
|
|
protected override Player CreatePlayer(Ruleset ruleset) => new DimAccessiblePlayer();
|
|
|
|
|
|
|
|
private class DimAccessiblePlayer : Player
|
|
|
|
{
|
|
|
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground();
|
|
|
|
public void EnableScreenDim()
|
|
|
|
{
|
|
|
|
Background.UpdateDim.Value = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DisableScreenDim()
|
|
|
|
{
|
|
|
|
Background.UpdateDim.Value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool AssertDimState()
|
|
|
|
{
|
|
|
|
return ((FadeAccessibleBackground)Background).AssertDimState();
|
|
|
|
}
|
|
|
|
|
2019-02-15 15:38:27 +08:00
|
|
|
public bool AssertUndimmed()
|
|
|
|
{
|
|
|
|
return ((FadeAccessibleBackground)Background).AssertUndimmed();
|
|
|
|
}
|
|
|
|
|
2019-02-15 15:17:01 +08:00
|
|
|
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
|
|
|
{
|
|
|
|
public bool AssertDimState()
|
|
|
|
{
|
|
|
|
return FadeContainer.Colour == OsuColour.Gray(BackgroundOpacity);
|
|
|
|
}
|
2019-02-15 15:38:27 +08:00
|
|
|
|
|
|
|
public bool AssertUndimmed()
|
|
|
|
{
|
|
|
|
return FadeContainer.Colour == OsuColour.Gray(1.0f);
|
|
|
|
}
|
2019-02-15 15:17:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|