diff --git a/osu.Game.Tests/Visual/Settings/TestSceneLatencyComparer.cs b/osu.Game.Tests/Visual/Settings/TestSceneLatencyComparer.cs index 8a5db7bd95..4706ecb149 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneLatencyComparer.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneLatencyComparer.cs @@ -3,17 +3,55 @@ #nullable enable +using System.Linq; using NUnit.Framework; +using osu.Framework.Testing; +using osu.Game.Graphics.UserInterface; using osu.Game.Screens; +using osuTK.Input; namespace osu.Game.Tests.Visual.Settings { public class TestSceneLatencyComparer : ScreenTestScene { - [Test] - public void TestBasic() + private LatencyComparerScreen latencyComparer = null!; + + public override void SetUpSteps() { - AddStep("Load screen", () => LoadScreen(new LatencyComparerScreen())); + base.SetUpSteps(); + AddStep("Load screen", () => LoadScreen(latencyComparer = new LatencyComparerScreen())); + } + + [Test] + public void TestCertification() + { + for (int i = 0; i < 4; i++) + { + clickCorrectUntilResults(); + AddAssert("check at results", () => !latencyComparer.ChildrenOfType().Any()); + AddStep("hit c to continue", () => InputManager.Key(Key.C)); + } + + AddAssert("check at results", () => !latencyComparer.ChildrenOfType().Any()); + + AddAssert("check no buttons", () => !latencyComparer.ChildrenOfType().Any()); + } + + private void clickCorrectUntilResults() + { + AddUntilStep("click correct button until results", () => + { + var latencyArea = latencyComparer + .ChildrenOfType() + .SingleOrDefault(a => a.TargetFrameRate == 0); + + // reached results + if (latencyArea == null) + return true; + + latencyArea.ChildrenOfType().Single().TriggerClick(); + return false; + }); } } } diff --git a/osu.Game/Screens/LatencyComparerScreen.cs b/osu.Game/Screens/LatencyComparerScreen.cs index c1e514687a..45e62646b1 100644 --- a/osu.Game/Screens/LatencyComparerScreen.cs +++ b/osu.Game/Screens/LatencyComparerScreen.cs @@ -358,7 +358,7 @@ Do whatever you need to try and perceive the difference in latency, then choose Origin = Anchor.Centre, Action = () => changeDifficulty(Math.Max(difficultyLevel - 1, 1)), }, - new Button(Key.R) + new Button(Key.C) { Text = $"Continue towards certification at this level ({certificationRemaining} more)", Anchor = Anchor.Centre, @@ -438,14 +438,15 @@ Do whatever you need to try and perceive the difference in latency, then choose private Drawable? background; private readonly Key key; - private readonly int targetFrameRate; + + public readonly int TargetFrameRate; public readonly BindableBool IsActiveArea = new BindableBool(); public LatencyArea(Key key, int targetFrameRate) { this.key = key; - this.targetFrameRate = targetFrameRate; + TargetFrameRate = targetFrameRate; RelativeSizeAxes = Axes.Both; Masking = true; @@ -505,7 +506,7 @@ Do whatever you need to try and perceive the difference in latency, then choose public override bool UpdateSubTree() { double elapsed = Clock.CurrentTime - lastFrameTime; - if (targetFrameRate > 0 && elapsed < 1000.0 / targetFrameRate) + if (TargetFrameRate > 0 && elapsed < 1000.0 / TargetFrameRate) return false; lastFrameTime = Clock.CurrentTime;