mirror of
https://github.com/ppy/osu.git
synced 2026-05-22 23:00:52 +08:00
Add test demonstrating failure scenario
This commit is contained in:
@@ -10,10 +10,12 @@ using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Leaderboards;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens;
|
||||
@@ -24,6 +26,7 @@ using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.SelectV2;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
@@ -271,6 +274,33 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddUntilStep("selected beatmap is still osu! ruleset", () => Game.Beatmap.Value.BeatmapInfo, () => Is.EqualTo(selectedBeatmap));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Note: This test was written to demonstrate the failure described at https://github.com/ppy/osu/issues/35023,
|
||||
/// but because the failure scenario there entailed a race condition, it was possible for the test to pass regardless
|
||||
/// unless <see cref="SongSelect.SELECTION_DEBOUNCE"/> was increased.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPresentFromResults()
|
||||
{
|
||||
BeatmapSetInfo beatmapToPresent = null!;
|
||||
BeatmapSetInfo beatmapToPlay = null!;
|
||||
AddStep("manually insert beatmap to be presented", () =>
|
||||
{
|
||||
Game.Realm.Write(r =>
|
||||
{
|
||||
var beatmapSet = TestResources.CreateTestBeatmapSetInfo(3, [r.Find<RulesetInfo>("osu")]);
|
||||
r.Add(beatmapSet);
|
||||
beatmapToPresent = beatmapSet.Detach();
|
||||
});
|
||||
});
|
||||
AddStep("import beatmap", () => beatmapToPlay = BeatmapImportHelper.LoadQuickOszIntoOsu(Game).GetResultSafely());
|
||||
AddStep("set global beatmap", () => Game.Beatmap.Value = Game.BeatmapManager.GetWorkingBeatmap(beatmapToPlay.Beatmaps.First()));
|
||||
playToResults();
|
||||
AddStep("present beatmap from results", () => Game.PresentBeatmap(beatmapToPresent));
|
||||
AddUntilStep("back at song select", () => Game.ScreenStack.CurrentScreen is SoloSongSelect);
|
||||
AddUntilStep("presented beatmap is current", () => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapToPresent));
|
||||
}
|
||||
|
||||
private Func<Player> playToResults()
|
||||
{
|
||||
var player = playToCompletion();
|
||||
|
||||
Reference in New Issue
Block a user