From 9b77b958e00a49b666a73555e779700a188409e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 May 2025 15:48:41 +0900 Subject: [PATCH] Add failing tests showing carousel incorrectly requesting start when traversing single items --- .../SongSelectV2/BeatmapCarouselTestScene.cs | 20 +++++++ .../TestSceneBeatmapCarouselNoGrouping.cs | 52 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs b/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs index f9f7f3e89c..9c109bc782 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs @@ -191,6 +191,12 @@ namespace osu.Game.Tests.Visual.SongSelectV2 protected void CheckNoSelection() => AddAssert("has no selection", () => Carousel.CurrentSelection, () => Is.Null); protected void CheckHasSelection() => AddAssert("has selection", () => Carousel.CurrentSelection, () => Is.Not.Null); + protected void CheckRequestPresentCount(int expected) => + AddAssert($"check present count is {expected}", () => Carousel.RequestPresentBeatmapCount, () => Is.EqualTo(expected)); + + protected void CheckActivationCount(int expected) => + AddAssert($"check activation count is {expected}", () => Carousel.ActivationCount, () => Is.EqualTo(expected)); + protected void CheckDisplayedBeatmapsCount(int expected) { AddAssert($"{expected} diffs displayed", () => Carousel.MatchedBeatmapsCount, () => Is.EqualTo(expected)); @@ -375,6 +381,9 @@ namespace osu.Game.Tests.Visual.SongSelectV2 public partial class TestBeatmapCarousel : BeatmapCarousel { + public int ActivationCount { get; private set; } + public int RequestPresentBeatmapCount { get; private set; } + public int FilterDelay = 0; public IEnumerable PostFilterBeatmaps = null!; @@ -385,6 +394,17 @@ namespace osu.Game.Tests.Visual.SongSelectV2 public new BeatmapSetInfo? ExpandedBeatmapSet => base.ExpandedBeatmapSet; public new GroupDefinition? ExpandedGroup => base.ExpandedGroup; + public TestBeatmapCarousel() + { + RequestPresentBeatmap = _ => RequestPresentBeatmapCount++; + } + + protected override void HandleItemActivated(CarouselItem item) + { + ActivationCount++; + base.HandleItemActivated(item); + } + protected override async Task> FilterAsync(bool clearExistingPanels = false) { var items = await base.FilterAsync(clearExistingPanels); diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselNoGrouping.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselNoGrouping.cs index e72a373d63..d0ecb2c05a 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselNoGrouping.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselNoGrouping.cs @@ -190,6 +190,58 @@ namespace osu.Game.Tests.Visual.SongSelectV2 WaitForSelection(4, 0); } + [Test] + public void TestSingleItemTraversal() + { + CheckNoSelection(); + AddBeatmaps(1, 3); + + WaitForSelection(0, 0); + CheckActivationCount(0); + + SelectNextGroup(); + WaitForSelection(0, 0); + + // In the case of a grouped beatmap set, the header gets activated and re-selects the recommended difficulty. + // This is probably fine. + CheckActivationCount(1); + // We don't want it to request present though, which would start gameplay. + CheckRequestPresentCount(0); + + SelectPrevGroup(); + WaitForSelection(0, 0); + + CheckActivationCount(1); + CheckRequestPresentCount(0); + } + + [Test] + public void TestSingleItemTraversal_DifficultySplit() + { + SortBy(SortMode.Difficulty); + + CheckNoSelection(); + AddBeatmaps(1, 1); + + WaitForSelection(0, 0); + CheckActivationCount(0); + + SelectNextGroup(); + WaitForSelection(0, 0); + + // In the case of a grouped beatmap set, the header gets activated and re-selects the recommended difficulty. + // This is probably fine. + CheckActivationCount(0); + // We don't want it to request present though, which would start gameplay. + CheckRequestPresentCount(0); + + SelectPrevGroup(); + WaitForSelection(0, 0); + + CheckActivationCount(0); + CheckRequestPresentCount(0); + } + [Test] public void TestEmptyTraversal() {