diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelectCurrentSelectionInvalidated.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelectCurrentSelectionInvalidated.cs index 857691a399..4fbc8fabfb 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelectCurrentSelectionInvalidated.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelectCurrentSelectionInvalidated.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Screens.Select.Filter; using osu.Game.Screens.SelectV2; +using osuTK.Input; namespace osu.Game.Tests.Visual.SongSelectV2 { @@ -198,6 +199,42 @@ namespace osu.Game.Tests.Visual.SongSelectV2 assertPanelSelected(0); } + [Test] + public void TestDebounceNotBypassedOnUpdate() + { + BeatmapInfo? selectedBefore = null; + BeatmapInfo? selectedBeatmapDuringDebounce = null; + + // we're testing the song select side debounce, so let's make filtering immediate + AddStep("set filter debounce delay to zero", () => Carousel.DebounceDelay = 0); + + WaitForFiltering(); + + AddUntilStep("wait for global beatmap selection", () => !Beatmap.IsDefault); + + AddStep("store selection", () => selectedBefore = Beatmap.Value.BeatmapInfo); + + AddStep("traverse to next panel and update simultaneously", () => + { + InputManager.Key(Key.Right); + + Beatmaps.Delete(Beatmaps.GetAllUsableBeatmapSets().Last()); + + // check selection during debounce + Scheduler.AddDelayed(() => selectedBeatmapDuringDebounce = Beatmap.Value.BeatmapInfo, Screens.SelectV2.SongSelect.SELECTION_DEBOUNCE / 2f); + }); + + WaitForFiltering(); + + AddUntilStep("wait for pre-debounce selection", () => selectedBeatmapDuringDebounce, () => Is.Not.Null); + + AddAssert("selection during debounce didn't change", () => selectedBeatmapDuringDebounce, () => Is.EqualTo(selectedBefore)); + + // Due to nunit runs having limited precision this tends to fail when headless, even though you'd expect the previous step to fail. + // Interactively, things fail as expected. + AddUntilStep("selection has changed after debounce", () => selectedBeatmapDuringDebounce, () => Is.Not.EqualTo(Beatmap.Value.BeatmapInfo)); + } + private void waitForFiltering(int filterCount = 1) { AddUntilStep("wait for filter count", () => Carousel.FilterCount, () => Is.EqualTo(filterCount));