1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-10 21:40:34 +08:00

Merge pull request #32152 from peppy/song-select-v2-test

Make `TestSceneSongSelect` work with local database
This commit is contained in:
Dan Balasescu 2025-03-03 16:21:11 +09:00 committed by GitHub
commit 9c28ac4a72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,16 +9,10 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Mods;
@ -29,7 +23,6 @@ using osu.Game.Screens;
using osu.Game.Screens.Footer;
using osu.Game.Screens.Menu;
using osu.Game.Screens.SelectV2.Footer;
using osu.Game.Tests.Resources;
using osuTK.Input;
namespace osu.Game.Tests.Visual.SongSelectV2
@ -42,8 +35,6 @@ namespace osu.Game.Tests.Visual.SongSelectV2
[Cached]
private readonly OsuLogo logo;
private BeatmapManager beatmapManager = null!;
protected override bool UseOnlineAPI => true;
public TestSceneSongSelect()
@ -66,32 +57,12 @@ namespace osu.Game.Tests.Visual.SongSelectV2
}
[BackgroundDependencyLoader]
private void load(GameHost host, IAPIProvider onlineAPI)
private void load()
{
BeatmapStore beatmapStore;
BeatmapUpdater beatmapUpdater;
BeatmapDifficultyCache difficultyCache;
RealmDetachedBeatmapStore beatmapStore;
// 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(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);
Dependencies.CacheAs<BeatmapStore>(beatmapStore = new RealmDetachedBeatmapStore());
Add(beatmapStore);
Dependencies.Cache(new OsuConfigManager(LocalStorage));
}
protected override void LoadComplete()
@ -109,7 +80,6 @@ namespace osu.Game.Tests.Visual.SongSelectV2
AddStep("load screen", () => Stack.Push(new Screens.SelectV2.SongSelectV2()));
AddUntilStep("wait for load", () => Stack.CurrentScreen is Screens.SelectV2.SongSelectV2 songSelect && songSelect.IsLoaded);
AddStep("import test beatmap", () => beatmapManager.Import(TestResources.GetTestBeatmapForImport()));
}
[Test]