osu/osu.Game.Tests/Visual/Settings/TestSceneLatencyCertifierSc...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.8 KiB
C#
Raw Normal View History

// 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.
#nullable enable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
2022-06-07 14:10:08 +00:00
using osu.Game.Screens.Utility;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Settings
{
2022-06-07 14:34:19 +00:00
public class TestSceneLatencyCertifierScreen : ScreenTestScene
{
2022-06-07 14:34:19 +00:00
private LatencyCertifierScreen latencyCertifier = null!;
public override void SetUpSteps()
{
base.SetUpSteps();
2022-06-07 14:34:19 +00:00
AddStep("Load screen", () => LoadScreen(latencyCertifier = new LatencyCertifierScreen()));
}
[Test]
public void TestCertification()
{
for (int i = 0; i < 4; i++)
{
clickCorrectUntilResults();
2022-06-07 14:34:19 +00:00
AddAssert("check at results", () => !latencyCertifier.ChildrenOfType<LatencyArea>().Any());
AddStep("hit c to continue", () => InputManager.Key(Key.C));
}
2022-06-07 14:34:19 +00:00
AddAssert("check at results", () => !latencyCertifier.ChildrenOfType<LatencyArea>().Any());
2022-06-07 14:34:19 +00:00
AddAssert("check no buttons", () => !latencyCertifier.ChildrenOfType<OsuButton>().Any());
}
private void clickCorrectUntilResults()
{
AddUntilStep("click correct button until results", () =>
{
2022-06-07 14:34:19 +00:00
var latencyArea = latencyCertifier
2022-06-07 14:10:08 +00:00
.ChildrenOfType<LatencyArea>()
.SingleOrDefault(a => a.TargetFrameRate == 0);
// reached results
if (latencyArea == null)
return true;
latencyArea.ChildrenOfType<OsuButton>().Single().TriggerClick();
return false;
});
}
}
}