1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-11 03:37:20 +08:00

Make TestSceneSongSelect work with local database

It was pointless before.
This commit is contained in:
Dean Herbert 2025-02-28 17:55:11 +09:00
parent 89b6d7caee
commit 8fc744e9dc
No known key found for this signature in database

View File

@ -9,16 +9,10 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Platform;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods; using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Mania; using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -29,7 +23,6 @@ using osu.Game.Screens;
using osu.Game.Screens.Footer; using osu.Game.Screens.Footer;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.SelectV2.Footer; using osu.Game.Screens.SelectV2.Footer;
using osu.Game.Tests.Resources;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Tests.Visual.SongSelectV2 namespace osu.Game.Tests.Visual.SongSelectV2
@ -42,8 +35,6 @@ namespace osu.Game.Tests.Visual.SongSelectV2
[Cached] [Cached]
private readonly OsuLogo logo; private readonly OsuLogo logo;
private BeatmapManager beatmapManager = null!;
protected override bool UseOnlineAPI => true; protected override bool UseOnlineAPI => true;
public TestSceneSongSelect() public TestSceneSongSelect()
@ -66,32 +57,12 @@ namespace osu.Game.Tests.Visual.SongSelectV2
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, IAPIProvider onlineAPI) private void load()
{ {
BeatmapStore beatmapStore; RealmDetachedBeatmapStore beatmapStore;
BeatmapUpdater beatmapUpdater;
BeatmapDifficultyCache difficultyCache;
// These DI caches are required to ensure for interactive runs this test scene doesn't nuke all user beatmaps in the local install. Dependencies.CacheAs<BeatmapStore>(beatmapStore = new RealmDetachedBeatmapStore());
// At a point we have isolated interactive test runs enough, this can likely be removed.
Dependencies.Cache(new RealmRulesetStore(Realm));
Dependencies.Cache(Realm);
Dependencies.Cache(difficultyCache = new BeatmapDifficultyCache());
Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, onlineAPI, Audio, Resources, host, Beatmap.Default, difficultyCache));
Dependencies.CacheAs(beatmapUpdater = new BeatmapUpdater(beatmapManager, difficultyCache, onlineAPI, LocalStorage));
Dependencies.CacheAs(beatmapStore = new RealmDetachedBeatmapStore());
beatmapManager.ProcessBeatmap = (set, scope) => beatmapUpdater.Process(set, scope);
MusicController music;
Dependencies.Cache(music = new MusicController());
// required to get bindables attached
Add(difficultyCache);
Add(music);
Add(beatmapStore); Add(beatmapStore);
Dependencies.Cache(new OsuConfigManager(LocalStorage));
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -109,7 +80,6 @@ namespace osu.Game.Tests.Visual.SongSelectV2
AddStep("load screen", () => Stack.Push(new Screens.SelectV2.SongSelectV2())); AddStep("load screen", () => Stack.Push(new Screens.SelectV2.SongSelectV2()));
AddUntilStep("wait for load", () => Stack.CurrentScreen is Screens.SelectV2.SongSelectV2 songSelect && songSelect.IsLoaded); AddUntilStep("wait for load", () => Stack.CurrentScreen is Screens.SelectV2.SongSelectV2 songSelect && songSelect.IsLoaded);
AddStep("import test beatmap", () => beatmapManager.Import(TestResources.GetTestBeatmapForImport()));
} }
[Test] [Test]