From 666d9b153cd583d6ae8915ae4e52832ddc7107aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 May 2025 16:00:20 +0900 Subject: [PATCH] Add failing test showing double filter on entering song select --- .../Visual/SongSelectV2/BeatmapCarouselTestScene.cs | 2 +- .../Visual/SongSelectV2/TestSceneSongSelect.cs | 9 +++++++++ osu.Game/Graphics/Carousel/Carousel.cs | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs b/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs index f9f7f3e89c..da339bbc3e 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs @@ -356,7 +356,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2 """); createHeader("carousel"); stats.AddParagraph($""" - sorting: {Carousel.IsFiltering} + filtering: {Carousel.IsFiltering} (total {Carousel.FilterCount} times) tracked: {Carousel.ItemsTracked} displayable: {Carousel.DisplayableItems} displayed: {Carousel.VisibleItems} diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelect.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelect.cs index b81484d3da..dcd745395b 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneSongSelect.cs @@ -78,6 +78,15 @@ namespace osu.Game.Tests.Visual.SongSelectV2 AddUntilStep("wait for results screen", () => Stack.CurrentScreen is ResultsScreen); } + [Test] + public void TestSingleFilterWhenEntering() + { + ImportBeatmapForRuleset(0); + LoadSongSelect(); + + AddAssert("single filter", () => Carousel.FilterCount, () => Is.EqualTo(1)); + } + [Test] public void TestCookieDoesNothingIfNothingSelected() { diff --git a/osu.Game/Graphics/Carousel/Carousel.cs b/osu.Game/Graphics/Carousel/Carousel.cs index 9da4d0e187..ce5d015775 100644 --- a/osu.Game/Graphics/Carousel/Carousel.cs +++ b/osu.Game/Graphics/Carousel/Carousel.cs @@ -71,6 +71,11 @@ namespace osu.Game.Graphics.Carousel /// public bool IsFiltering => !filterTask.IsCompleted; + /// + /// The number of times filter operations have been triggered. + /// + internal int FilterCount { get; private set; } + /// /// The number of displayable items currently being tracked (before filtering). /// @@ -187,6 +192,8 @@ namespace osu.Game.Graphics.Carousel /// Whether all existing drawable panels should be reset post filter. protected virtual Task> FilterAsync(bool clearExistingPanels = false) { + FilterCount++; + if (clearExistingPanels) filterReusesPanels.Invalidate();