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.
|
|
|
|
|
|
|
|
#nullable enable
|
|
|
|
|
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 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-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-07 14:02:15 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2022-06-10 06:19:10 +00:00
|
|
|
int difficulty = i + 1;
|
|
|
|
|
|
|
|
checkDifficulty(difficulty);
|
|
|
|
clickUntilResults(true);
|
|
|
|
continueFromResults();
|
2022-06-07 14:02:15 +00:00
|
|
|
}
|
|
|
|
|
2022-06-10 06:19:10 +00:00
|
|
|
checkDifficulty(5);
|
|
|
|
clickUntilResults(false);
|
|
|
|
continueFromResults();
|
|
|
|
checkDifficulty(4);
|
|
|
|
|
|
|
|
clickUntilResults(false);
|
|
|
|
continueFromResults();
|
|
|
|
checkDifficulty(3);
|
|
|
|
|
|
|
|
clickUntilResults(true);
|
2022-06-07 14:34:19 +00:00
|
|
|
AddAssert("check at results", () => !latencyCertifier.ChildrenOfType<LatencyArea>().Any());
|
|
|
|
AddAssert("check no buttons", () => !latencyCertifier.ChildrenOfType<OsuButton>().Any());
|
2022-06-10 06:19:10 +00:00
|
|
|
checkDifficulty(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|