1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 00:02:54 +08:00
osu-lazer/osu.Game.Tests/Visual/Settings/TestSceneLatencyCertifierScreen.cs

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

95 lines
3.0 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.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
2022-06-07 22:10:08 +08:00
using osu.Game.Screens.Utility;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Settings
{
2022-06-07 22:34:19 +08:00
public partial class TestSceneLatencyCertifierScreen : ScreenTestScene
{
2022-06-07 22:34:19 +08:00
private LatencyCertifierScreen latencyCertifier = null!;
public override void SetUpSteps()
{
base.SetUpSteps();
2022-06-07 23:36:19 +08:00
2022-06-07 22:34:19 +08:00
AddStep("Load screen", () => LoadScreen(latencyCertifier = new LatencyCertifierScreen()));
2022-06-07 23:36:19 +08:00
AddUntilStep("wait for load", () => latencyCertifier.IsLoaded);
}
2022-06-11 21:21:22 +08:00
[Test]
public void TestSimple()
{
AddStep("set visual mode to simple", () => latencyCertifier.VisualMode.Value = LatencyVisualMode.Simple);
}
2022-06-10 17:18:18 +08:00
[Test]
public void TestCircleGameplay()
{
AddStep("set visual mode to circles", () => latencyCertifier.VisualMode.Value = LatencyVisualMode.CircleGameplay);
}
[Test]
public void TestScrollingGameplay()
{
AddStep("set visual mode to scrolling", () => latencyCertifier.VisualMode.Value = LatencyVisualMode.ScrollingGameplay);
}
2022-06-11 20:36:41 +08:00
[Test]
public void TestCycleVisualModes()
{
AddRepeatStep("cycle mode", () => InputManager.Key(Key.Space), 6);
}
[Test]
public void TestCertification()
{
checkDifficulty(1);
clickUntilResults(true);
continueFromResults();
checkDifficulty(2);
clickUntilResults(false);
continueFromResults();
checkDifficulty(1);
clickUntilResults(true);
2022-06-07 22:34:19 +08:00
AddAssert("check at results", () => !latencyCertifier.ChildrenOfType<LatencyArea>().Any());
checkDifficulty(1);
}
private void continueFromResults()
{
AddAssert("check at results", () => !latencyCertifier.ChildrenOfType<LatencyArea>().Any());
AddStep("hit enter to continue", () => InputManager.Key(Key.Enter));
}
private void checkDifficulty(int difficulty)
{
AddAssert($"difficulty is {difficulty}", () => latencyCertifier.DifficultyLevel == difficulty);
}
private void clickUntilResults(bool clickCorrect)
{
AddUntilStep("click correct button until results", () =>
{
2022-06-07 22:34:19 +08:00
var latencyArea = latencyCertifier
2022-06-07 22:10:08 +08:00
.ChildrenOfType<LatencyArea>()
.SingleOrDefault(a => clickCorrect ? a.TargetFrameRate == null : a.TargetFrameRate != null);
// reached results
if (latencyArea == null)
return true;
latencyArea.ChildrenOfType<OsuButton>().Single().TriggerClick();
return false;
});
}
}
}