diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsSongSelectV2.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsSongSelectV2.cs new file mode 100644 index 0000000000..0bbd2f5d92 --- /dev/null +++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsSongSelectV2.cs @@ -0,0 +1,89 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Extensions.ObjectExtensions; +using osu.Framework.Platform; +using osu.Framework.Testing; +using osu.Game.Beatmaps; +using osu.Game.Configuration; +using osu.Game.Database; +using osu.Game.Rulesets; +using osu.Game.Scoring; +using osu.Game.Screens.OnlinePlay.Playlists; +using osu.Game.Screens.SelectV2; +using osu.Game.Tests.Resources; +using osu.Game.Tests.Visual.OnlinePlay; + +namespace osu.Game.Tests.Visual.Playlists +{ + public class TestScenePlaylistsSongSelectV2 : OnlinePlayTestScene + { + private BeatmapManager beatmaps = null!; + private RealmRulesetStore rulesets = null!; + private OsuConfigManager config = null!; + private ScoreManager scoreManager = null!; + private RealmDetachedBeatmapStore beatmapStore = null!; + + private PlaylistsSongSelectV2 songSelect = null!; + + private BeatmapCarousel Carousel => songSelect.ChildrenOfType().Single(); + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); + + // These DI caches are required to ensure for interactive runs this test scene doesn't nuke all user beatmaps in the local install. + // At a point we have isolated interactive test runs enough, this can likely be removed. + dependencies.Cache(rulesets = new RealmRulesetStore(Realm)); + dependencies.Cache(Realm); + dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, null, Dependencies.Get(), Resources, Dependencies.Get(), Beatmap.Default)); + dependencies.Cache(config = new OsuConfigManager(LocalStorage)); + dependencies.Cache(scoreManager = new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, API, config)); + + dependencies.CacheAs(beatmapStore = new RealmDetachedBeatmapStore()); + + return dependencies; + } + + [BackgroundDependencyLoader] + private void load() + { + Add(beatmapStore); + } + + public override void SetUpSteps() + { + base.SetUpSteps(); + + ImportBeatmapForRuleset(0); + + AddStep("load screen", () => LoadScreen(songSelect = new PlaylistsSongSelectV2())); + AddUntilStep("wait for load", () => Stack.CurrentScreen == songSelect && songSelect.IsLoaded); + AddUntilStep("wait for filtering", () => !Carousel.IsFiltering); + } + + protected void ImportBeatmapForRuleset(params int[] rulesetIds) => ImportBeatmapForRuleset(_ => { }, 3, rulesetIds); + + protected void ImportBeatmapForRuleset(Action applyToBeatmap, int difficultyCount, params int[] rulesetIds) + { + int beatmapsCount = 0; + + AddStep($"import test map for ruleset {rulesetIds}", () => + { + beatmapsCount = songSelect.IsNull() ? 0 : Carousel.Filters.OfType().Single().SetItems.Count; + + var beatmapSet = TestResources.CreateTestBeatmapSetInfo(difficultyCount, rulesets.AvailableRulesets.Where(r => rulesetIds.Contains(r.OnlineID)).ToArray()); + applyToBeatmap(beatmapSet); + beatmaps.Import(beatmapSet); + }); + + // This is specifically for cases where the add is happening post song select load. + // For cases where song select is null, the assertions are provided by the load checks. + AddUntilStep("wait for imported to arrive in carousel", () => songSelect.IsNull() || Carousel.Filters.OfType().Single().SetItems.Count > beatmapsCount); + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.cs new file mode 100644 index 0000000000..375e22cf00 --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.cs @@ -0,0 +1,14 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Screens.SelectV2; + +namespace osu.Game.Screens.OnlinePlay.Playlists +{ + public class PlaylistsSongSelectV2 : SongSelect + { + protected override void OnStart() + { + } + } +} diff --git a/osu.Game/Tests/Visual/OnlinePlay/OnlinePlayTestScene.cs b/osu.Game/Tests/Visual/OnlinePlay/OnlinePlayTestScene.cs index 75932bbfef..3aa126c250 100644 --- a/osu.Game/Tests/Visual/OnlinePlay/OnlinePlayTestScene.cs +++ b/osu.Game/Tests/Visual/OnlinePlay/OnlinePlayTestScene.cs @@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay }); } - protected sealed override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DelegatedDependencyContainer(base.CreateChildDependencies(parent)); public override void SetUpSteps()