1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 18:43:04 +08:00

Add test covering required behaviour

See https://github.com/ppy/osu/issues/30885.
This commit is contained in:
Dean Herbert 2025-01-02 16:17:34 +09:00
parent 58dcb25bd5
commit 2d3595f768
No known key found for this signature in database

View File

@ -27,18 +27,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[SetUpSteps]
public void SetUpSteps()
{
AddStep("Create control", () =>
{
Child = new PlayerSettingsGroup("Some settings")
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
offsetControl = new BeatmapOffsetControl()
}
};
});
recreateControl();
}
[Test]
@ -123,13 +112,14 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestCalibrationFromZero()
{
ScoreInfo referenceScore = null!;
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", () =>
{
offsetControl.ReferenceScore.Value = new ScoreInfo
offsetControl.ReferenceScore.Value = referenceScore = new ScoreInfo
{
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error),
BeatmapInfo = Beatmap.Value.BeatmapInfo,
@ -143,6 +133,10 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("Button is disabled", () => !offsetControl.ChildrenOfType<SettingsButton>().Single().Enabled.Value);
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
recreateControl();
AddStep("Set same reference score", () => offsetControl.ReferenceScore.Value = referenceScore);
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
}
/// <summary>
@ -251,5 +245,21 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
}
private void recreateControl()
{
AddStep("Create control", () =>
{
Child = new PlayerSettingsGroup("Some settings")
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
offsetControl = new BeatmapOffsetControl()
}
};
});
}
}
}