2022-03-01 06:40:19 +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-03-01 07:15:13 +00:00
|
|
|
using System.Linq;
|
2022-03-01 06:40:19 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
2022-03-01 07:15:13 +00:00
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Overlays.Settings;
|
2023-06-06 19:11:24 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2023-06-06 18:36:44 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2022-03-01 07:15:13 +00:00
|
|
|
using osu.Game.Scoring;
|
2022-03-01 06:40:19 +00:00
|
|
|
using osu.Game.Screens.Play.PlayerSettings;
|
2023-12-27 18:14:17 +00:00
|
|
|
using osu.Game.Tests.Resources;
|
2022-03-01 06:40:19 +00:00
|
|
|
using osu.Game.Tests.Visual.Ranking;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
|
|
|
public partial class TestSceneBeatmapOffsetControl : OsuTestScene
|
|
|
|
{
|
2024-06-15 09:26:57 +00:00
|
|
|
private BeatmapOffsetControl offsetControl = null!;
|
2022-03-01 07:15:13 +00:00
|
|
|
|
|
|
|
[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 10:31:11 +00:00
|
|
|
[Test]
|
|
|
|
public void TestTooShortToDisplay()
|
|
|
|
{
|
|
|
|
AddStep("Set short reference score", () =>
|
|
|
|
{
|
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
|
|
|
{
|
2023-12-27 18:14:17 +00:00
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(0, 2),
|
|
|
|
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestScoreFromDifferentBeatmap()
|
|
|
|
{
|
|
|
|
AddStep("Set short reference score", () =>
|
|
|
|
{
|
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
|
|
|
{
|
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(10),
|
|
|
|
BeatmapInfo = TestResources.CreateTestBeatmapSetInfo().Beatmaps.First(),
|
2022-03-01 10:31:11 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
}
|
|
|
|
|
2023-06-06 18:36:44 +00:00
|
|
|
[Test]
|
|
|
|
public void TestModRemovingTimedInputs()
|
|
|
|
{
|
|
|
|
AddStep("Set score with mod removing timed inputs", () =>
|
|
|
|
{
|
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
|
|
|
{
|
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(10),
|
2023-12-27 18:14:17 +00:00
|
|
|
Mods = new Mod[] { new OsuModRelax() },
|
|
|
|
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
2023-06-06 18:36:44 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
}
|
|
|
|
|
2022-03-01 06:40:19 +00:00
|
|
|
[Test]
|
2022-03-04 03:55:35 +00:00
|
|
|
public void TestCalibrationFromZero()
|
2022-03-01 06:40:19 +00:00
|
|
|
{
|
2022-03-01 07:15:13 +00: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 06:40:19 +00:00
|
|
|
{
|
2022-03-01 07:15:13 +00:00
|
|
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
2022-03-01 06:40:19 +00:00
|
|
|
{
|
2023-12-27 18:14:17 +00:00
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error),
|
|
|
|
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
2022-03-01 07:15:13 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-03-05 16:50:25 +00:00
|
|
|
AddUntilStep("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
2022-03-01 07:15:13 +00:00
|
|
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
2022-03-01 11:41:54 +00:00
|
|
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == -average_error);
|
2022-03-01 07:15:13 +00:00
|
|
|
|
2022-03-05 16:50:25 +00:00
|
|
|
AddUntilStep("Button is disabled", () => !offsetControl.ChildrenOfType<SettingsButton>().Single().Enabled.Value);
|
2022-03-01 07:15:13 +00:00
|
|
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
2022-03-01 06:40:19 +00:00
|
|
|
}
|
2022-03-04 03:55:35 +00: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
|
|
|
|
{
|
2023-12-27 18:14:17 +00:00
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error),
|
|
|
|
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
2022-03-04 03:55:35 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2022-03-05 16:50:25 +00:00
|
|
|
AddUntilStep("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
2022-03-04 03:55:35 +00:00
|
|
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
|
|
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == initial_offset - average_error);
|
|
|
|
|
2022-03-05 16:50:25 +00:00
|
|
|
AddUntilStep("Button is disabled", () => !offsetControl.ChildrenOfType<SettingsButton>().Single().Enabled.Value);
|
2022-03-04 03:55:35 +00:00
|
|
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
|
|
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
}
|
2024-06-14 11:07:27 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCalibrationNoChange()
|
|
|
|
{
|
|
|
|
const double average_error = 0;
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error),
|
|
|
|
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
|
|
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
|
|
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == -average_error);
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
2022-03-01 06:40:19 +00:00
|
|
|
}
|
|
|
|
}
|