mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Add new tests and tidy up existing tests
This commit is contained in:
parent
52c9762651
commit
6db22366e2
@ -3,48 +3,63 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestSceneFailingLayer : OsuTestScene
|
public class TestSceneFailingLayer : OsuTestScene
|
||||||
{
|
{
|
||||||
private readonly FailingLayer layer;
|
private FailingLayer layer;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuConfigManager config { get; set; }
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
public TestSceneFailingLayer()
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
Child = layer = new FailingLayer();
|
AddStep("create layer", () => Child = layer = new FailingLayer());
|
||||||
|
AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
||||||
|
AddUntilStep("layer is visible", () => layer.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLayerConfig()
|
public void TestLayerDisabledViaConfig()
|
||||||
{
|
{
|
||||||
AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
|
||||||
AddWaitStep("wait for transition to finish", 5);
|
|
||||||
AddAssert("layer is enabled", () => layer.IsPresent);
|
|
||||||
|
|
||||||
AddStep("disable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
AddStep("disable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
||||||
AddWaitStep("wait for transition to finish", 5);
|
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||||
AddAssert("layer is disabled", () => !layer.IsPresent);
|
}
|
||||||
AddStep("restore layer enabling", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
|
||||||
|
[Test]
|
||||||
|
public void TestLayerVisibilityWithAccumulatingProcessor()
|
||||||
|
{
|
||||||
|
AddStep("bind accumulating processor", () => layer.BindHealthProcessor(new AccumulatingHealthProcessor(1)));
|
||||||
|
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLayerVisibilityWithDrainingProcessor()
|
||||||
|
{
|
||||||
|
AddStep("bind accumulating processor", () => layer.BindHealthProcessor(new DrainingHealthProcessor(1)));
|
||||||
|
AddWaitStep("wait for potential fade", 10);
|
||||||
|
AddAssert("layer is still visible", () => layer.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLayerFading()
|
public void TestLayerFading()
|
||||||
{
|
{
|
||||||
AddSliderStep("current health", 0.0, 1.0, 1.0, val => layer.Current.Value = val);
|
AddSliderStep("current health", 0.0, 1.0, 1.0, val =>
|
||||||
var box = layer.Child;
|
{
|
||||||
|
if (layer != null)
|
||||||
|
layer.Current.Value = val;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.10);
|
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
||||||
AddWaitStep("wait for fade to finish", 5);
|
AddUntilStep("layer fade is visible", () => layer.Child.Alpha > 0.1f);
|
||||||
AddAssert("layer fade is visible", () => box.IsPresent);
|
|
||||||
AddStep("set health to 1", () => layer.Current.Value = 1f);
|
AddStep("set health to 1", () => layer.Current.Value = 1f);
|
||||||
AddWaitStep("wait for fade to finish", 10);
|
AddUntilStep("layer fade is invisible", () => !layer.Child.IsPresent);
|
||||||
AddAssert("layer fade is invisible", () => !box.IsPresent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user