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