1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 18:23:04 +08:00

add tests

This commit is contained in:
Albie 2019-12-10 16:59:31 +00:00
parent 7864899249
commit 6c1ae3bc8a
2 changed files with 22 additions and 4 deletions

View File

@ -165,6 +165,21 @@ namespace osu.Game.Tests.Visual.Background
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
}
/// <summary>
/// Ensure <see cref="UserDimContainer"/> is able to disable user-defined display settings.
/// </summary>
[Test]
public void DisableUserDisplaySettingsTest()
{
performFullSetup();
AddStep("Enable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = true);
AddStep("Set user dim to max", () => player.DimmableStoryboard.)
waitForDim();
AddStep("Turn on IgnoreUserSettings", () => player.DimmableStoryboard.IgnoreUserSettings.Value = true);
waitForDim();
AddAssert("Check the background is undimmed", () => player.IsBackgroundUndimmed());
}
/// <summary>
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a storyboard.
/// </summary>
@ -352,6 +367,8 @@ namespace osu.Game.Tests.Visual.Background
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).Colour == Color4.White;
// Whether or not the player should be allowed to load.
public bool BlockLoad;

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osuTK.Graphics;
namespace osu.Game.Graphics.Containers
{
@ -22,7 +23,7 @@ namespace osu.Game.Graphics.Containers
public readonly Bindable<bool> EnableUserDim = new Bindable<bool>(true);
/// <summary>
/// Whether or not user-configured settings relating to visibility of elements should be ignored
/// Whether or not user-configured settings relating to brightness of elements should be ignored
/// </summary>
public readonly Bindable<bool> IgnoreUserSettings = new Bindable<bool>();
@ -36,14 +37,14 @@ namespace osu.Game.Graphics.Containers
/// </summary>
public bool ContentDisplayed { get; private set; }
public double DimLevel => EnableUserDim.Value && !IgnoreUserSettings.Value ? UserDimLevel.Value : 0;
protected Bindable<double> UserDimLevel { get; private set; }
protected Bindable<bool> ShowStoryboard { get; private set; }
protected Bindable<bool> ShowVideo { get; private set; }
protected double DimLevel => EnableUserDim.Value ? UserDimLevel.Value : 0;
protected override Container<Drawable> Content => dimContent;
private Container dimContent { get; }
@ -90,7 +91,7 @@ namespace osu.Game.Graphics.Containers
ContentDisplayed = ShowDimContent;
dimContent.FadeTo(ContentDisplayed ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
dimContent.FadeColour(OsuColour.Gray(1 - (float)DimLevel), BACKGROUND_FADE_DURATION, Easing.OutQuint);
dimContent.FadeColour(IgnoreUserSettings.Value ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint);
}
}
}