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