2022-03-01 14:40:19 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2022-03-01 15:15:13 +08:00
|
|
|
using System.Linq;
|
2022-03-01 14:40:19 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
2022-03-01 15:15:13 +08:00
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Overlays.Settings;
|
2023-06-07 03:11:24 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2023-06-07 02:36:44 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2022-03-01 15:15:13 +08:00
|
|
|
using osu.Game.Scoring;
|
2022-03-01 14:40:19 +08:00
|
|
|
using osu.Game.Screens.Play.PlayerSettings;
|
|
|
|
using osu.Game.Tests.Visual.Ranking;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TestSceneBeatmapOffsetControl : OsuTestScene
|
2022-03-01 14:40:19 +08:00
|
|
|
{
|
2022-03-01 15:15:13 +08:00
|
|
|
private BeatmapOffsetControl offsetControl;
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("Create control", () =>
|
|
|
|
{
|
|
|
|
Child = new PlayerSettingsGroup("Some settings")
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
offsetControl = new BeatmapOffsetControl()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-03-01 18:31:11 +08:00
|
|
|
[Test]
|
|
|
|
public void TestTooShortToDisplay()
|
|
|
|
{
|
|
|
|
AddStep("Set short reference score", () =>
|
|
|
|
{
|
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
|
|
|
{
|
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(0, 2)
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
}
|
|
|
|
|
2023-06-07 02:36:44 +08:00
|
|
|
[Test]
|
|
|
|
public void TestModRemovingTimedInputs()
|
|
|
|
{
|
|
|
|
AddStep("Set score with mod removing timed inputs", () =>
|
|
|
|
{
|
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
|
|
|
{
|
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(10),
|
2023-06-07 03:11:24 +08:00
|
|
|
Mods = new Mod[] { new OsuModRelax() }
|
2023-06-07 02:36:44 +08:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
}
|
|
|
|
|
2022-03-01 14:40:19 +08:00
|
|
|
[Test]
|
2022-03-04 11:55:35 +08:00
|
|
|
public void TestCalibrationFromZero()
|
2022-03-01 14:40:19 +08:00
|
|
|
{
|
2022-03-01 15:15:13 +08:00
|
|
|
const double average_error = -4.5;
|
|
|
|
|
|
|
|
AddAssert("Offset is neutral", () => offsetControl.Current.Value == 0);
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
AddStep("Set reference score", () =>
|
2022-03-01 14:40:19 +08:00
|
|
|
{
|
2022-03-01 15:15:13 +08:00
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
2022-03-01 14:40:19 +08:00
|
|
|
{
|
2022-03-01 15:15:13 +08:00
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error)
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-03-06 00:50:25 +08:00
|
|
|
AddUntilStep("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
2022-03-01 15:15:13 +08:00
|
|
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
2022-03-01 19:41:54 +08:00
|
|
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == -average_error);
|
2022-03-01 15:15:13 +08:00
|
|
|
|
2022-03-06 00:50:25 +08:00
|
|
|
AddUntilStep("Button is disabled", () => !offsetControl.ChildrenOfType<SettingsButton>().Single().Enabled.Value);
|
2022-03-01 15:15:13 +08:00
|
|
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
2022-03-01 14:40:19 +08:00
|
|
|
}
|
2022-03-04 11:55:35 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// When a beatmap offset was already set, the calibration should take it into account.
|
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void TestCalibrationFromNonZero()
|
|
|
|
{
|
|
|
|
const double average_error = -4.5;
|
|
|
|
const double initial_offset = -2;
|
|
|
|
|
|
|
|
AddStep("Set offset non-neutral", () => offsetControl.Current.Value = initial_offset);
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
AddStep("Set reference score", () =>
|
|
|
|
{
|
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
|
|
|
{
|
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error)
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-03-06 00:50:25 +08:00
|
|
|
AddUntilStep("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
2022-03-04 11:55:35 +08:00
|
|
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
|
|
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == initial_offset - average_error);
|
|
|
|
|
2022-03-06 00:50:25 +08:00
|
|
|
AddUntilStep("Button is disabled", () => !offsetControl.ChildrenOfType<SettingsButton>().Single().Enabled.Value);
|
2022-03-04 11:55:35 +08:00
|
|
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
}
|
2022-03-01 14:40:19 +08:00
|
|
|
}
|
|
|
|
}
|