diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs index 82417d09a7..1cb64b71fc 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs @@ -2,10 +2,12 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Input.Events; using osu.Framework.Input.States; +using osu.Framework.Logging; using osu.Framework.Testing.Input; using osu.Game.Rulesets.Osu.UI; using osuTK; @@ -17,22 +19,57 @@ public class TestSceneSmoke : OsuSkinnableTestScene [Test] public void TestSmoking() { - AddStep("Create smoke", () => + addStep("Create short smoke", 2_000); + addStep("Create medium smoke", 5_000); + addStep("Create long smoke", 10_000); + } + + private void addStep(string stepName, double duration) + { + var smokeContainers = new List(); + + AddStep(stepName, () => { - SetContents(_ => new SmokingInputManager + smokeContainers.Clear(); + SetContents(_ => { - RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.95f), - Child = new TestSmokeContainer { RelativeSizeAxes = Axes.Both }, + smokeContainers.Add(new TestSmokeContainer + { + Duration = duration, + RelativeSizeAxes = Axes.Both + }); + + return new SmokingInputManager + { + Duration = duration, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.95f), + Child = smokeContainers[^1], + }; }); }); + + AddUntilStep("Until skinnable expires", () => + { + if (smokeContainers.Count == 0) + return false; + + Logger.Log("How many: " + smokeContainers.Count); + + foreach (var smokeContainer in smokeContainers) + { + if (smokeContainer.Children.Count != 0) + return false; + } + + return true; + }); } - private const double spin_duration = 5_000; - private const float spin_angle = 4 * MathF.PI; - private class SmokingInputManager : ManualInputManager { + public double Duration { get; init; } + private double? startTime; public SmokingInputManager() @@ -51,9 +88,11 @@ protected override void Update() { base.Update(); + const float spin_angle = 4 * MathF.PI; + startTime ??= Time.Current; - float fraction = (float)((Time.Current - startTime) / spin_duration); + float fraction = (float)((Time.Current - startTime) / Duration); float angle = fraction * spin_angle; float radius = fraction * Math.Min(DrawSize.X, DrawSize.Y) / 2; @@ -65,24 +104,27 @@ protected override void Update() private class TestSmokeContainer : SmokeContainer { - private double? startTime; + public double Duration { get; init; } + private bool isPressing; private bool isFinished; + private double? startTime; + protected override void Update() { base.Update(); - startTime ??= Time.Current; + startTime ??= Time.Current + 0.1; - if (!isPressing && !isFinished && Time.Current > startTime + 0.1) + if (!isPressing && !isFinished && Time.Current > startTime) { OnPressed(new KeyBindingPressEvent(new InputState(), OsuAction.Smoke)); isPressing = true; isFinished = false; } - if (isPressing && Time.Current > startTime + spin_duration) + if (isPressing && Time.Current > startTime + Duration) { OnReleased(new KeyBindingReleaseEvent(new InputState(), OsuAction.Smoke)); isPressing = false;