mirror of
https://github.com/ppy/osu
synced 2025-02-12 16:17:16 +00:00
Add full testing flow for BeatmapOffsetControl
This commit is contained in:
parent
2901d2a650
commit
fab09575ec
@ -1,8 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Play.PlayerSettings;
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
using osu.Game.Tests.Visual.Ranking;
|
using osu.Game.Tests.Visual.Ranking;
|
||||||
|
|
||||||
@ -10,18 +14,46 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
public class TestSceneBeatmapOffsetControl : OsuTestScene
|
public class TestSceneBeatmapOffsetControl : OsuTestScene
|
||||||
{
|
{
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDisplay()
|
public void TestDisplay()
|
||||||
{
|
{
|
||||||
Child = new PlayerSettingsGroup("Some settings")
|
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", () =>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new BeatmapOffsetControl(TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(-4.5))
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error)
|
||||||
}
|
};
|
||||||
};
|
});
|
||||||
|
|
||||||
|
AddAssert("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
||||||
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == average_error);
|
||||||
|
|
||||||
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
||||||
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user