From 2b45a9b7c629fd9f8df01fc35db37da7f8b511c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jan 2024 17:10:16 +0900 Subject: [PATCH 1/3] Add failing test coverage showing collection dropdown crash --- .../Visual/SongSelect/TestSceneFilterControl.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs index 94c6130f15..58183acb93 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; @@ -76,6 +77,20 @@ namespace osu.Game.Tests.Visual.SongSelect assertCollectionDropdownContains("2"); } + [Test] + public void TestCollectionsCleared() + { + AddStep("add collection", () => writeAndRefresh(r => r.Add(new BeatmapCollection(name: "1")))); + AddStep("add collection", () => writeAndRefresh(r => r.Add(new BeatmapCollection(name: "2")))); + AddStep("add collection", () => writeAndRefresh(r => r.Add(new BeatmapCollection(name: "3")))); + + AddAssert("check count 5", () => control.ChildrenOfType().Single().ChildrenOfType().Count(), () => Is.EqualTo(5)); + + AddStep("delete all collections", () => writeAndRefresh(r => r.RemoveAll())); + + AddAssert("check count 2", () => control.ChildrenOfType().Single().ChildrenOfType().Count(), () => Is.EqualTo(2)); + } + [Test] public void TestCollectionRemovedFromDropdown() { From 0a522d260becbbcc2e7d2835b763208ea76a6d4a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jan 2024 17:10:30 +0900 Subject: [PATCH 2/3] Fix collection dropdown crashing when all collections are deleted at once --- osu.Game/Collections/CollectionDropdown.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Collections/CollectionDropdown.cs b/osu.Game/Collections/CollectionDropdown.cs index 8d83ed3ec9..249a0c35e7 100644 --- a/osu.Game/Collections/CollectionDropdown.cs +++ b/osu.Game/Collections/CollectionDropdown.cs @@ -74,7 +74,7 @@ namespace osu.Game.Collections } else { - foreach (int i in changes.DeletedIndices) + foreach (int i in changes.DeletedIndices.OrderByDescending(i => i)) filters.RemoveAt(i + 1); foreach (int i in changes.InsertedIndices) From 96c472b870790825e6acbc692a425612f97efb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 15 Jan 2024 12:33:25 +0100 Subject: [PATCH 3/3] Remove unused using directive --- osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs index 58183acb93..a639d50eee 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation;