1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 04:13:03 +08:00

Update broken test scenes to match new OsuTestScene logic

This commit is contained in:
Dean Herbert 2022-01-18 13:22:55 +09:00
parent b9aae5569f
commit da9a60a695
6 changed files with 31 additions and 20 deletions

View File

@ -29,9 +29,10 @@ namespace osu.Game.Tests.Visual.Editing
[Cached] [Cached]
private EditorClipboard clipboard = new EditorClipboard(); private EditorClipboard clipboard = new EditorClipboard();
[BackgroundDependencyLoader] protected override void LoadComplete()
private void load()
{ {
base.LoadComplete();
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
Child = new ComposeScreen Child = new ComposeScreen

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
@ -37,9 +36,10 @@ namespace osu.Game.Tests.Visual.Editing
}); });
} }
[BackgroundDependencyLoader] protected override void LoadComplete()
private void load()
{ {
base.LoadComplete();
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
// ensure that music controller does not change this beatmap due to it // ensure that music controller does not change this beatmap due to it
// completing naturally as part of the test. // completing naturally as part of the test.

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -23,9 +22,10 @@ namespace osu.Game.Tests.Visual.Editing
BeatDivisor.Value = 4; BeatDivisor.Value = 4;
} }
[BackgroundDependencyLoader] protected override void LoadComplete()
private void load()
{ {
base.LoadComplete();
var testBeatmap = new Beatmap var testBeatmap = new Beatmap
{ {
ControlPointInfo = new ControlPointInfo(), ControlPointInfo = new ControlPointInfo(),

View File

@ -29,9 +29,10 @@ namespace osu.Game.Tests.Visual.Editing
editorBeatmap = new EditorBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)); editorBeatmap = new EditorBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
} }
[BackgroundDependencyLoader] protected override void LoadComplete()
private void load()
{ {
base.LoadComplete();
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
Beatmap.Disabled = true; Beatmap.Disabled = true;

View File

@ -35,9 +35,9 @@ namespace osu.Game.Tests.Visual
return dependencies; return dependencies;
} }
[BackgroundDependencyLoader] protected override void LoadComplete()
private void load()
{ {
base.LoadComplete();
Beatmap.BindValueChanged(beatmapChanged, true); Beatmap.BindValueChanged(beatmapChanged, true);
} }

View File

@ -42,17 +42,27 @@ namespace osu.Game.Tests.Visual
Alpha = 0 Alpha = 0
}; };
private TestBeatmapManager testBeatmapManager;
private WorkingBeatmap working;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio, RulesetStore rulesets) private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
{ {
Add(logo); Add(logo);
var working = CreateWorkingBeatmap(Ruleset.Value); working = CreateWorkingBeatmap(Ruleset.Value);
Beatmap.Value = working;
if (IsolateSavingFromDatabase) if (IsolateSavingFromDatabase)
Dependencies.CacheAs<BeatmapManager>(new TestBeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default, working)); Dependencies.CacheAs<BeatmapManager>(testBeatmapManager = new TestBeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
}
protected override void LoadComplete()
{
base.LoadComplete();
Beatmap.Value = working;
if (testBeatmapManager != null)
testBeatmapManager.TestBeatmap = working;
} }
protected virtual bool EditorComponentsReady => Editor.ChildrenOfType<HitObjectComposer>().FirstOrDefault()?.IsLoaded == true protected virtual bool EditorComponentsReady => Editor.ChildrenOfType<HitObjectComposer>().FirstOrDefault()?.IsLoaded == true
@ -114,12 +124,11 @@ namespace osu.Game.Tests.Visual
private class TestBeatmapManager : BeatmapManager private class TestBeatmapManager : BeatmapManager
{ {
private readonly WorkingBeatmap testBeatmap; public WorkingBeatmap TestBeatmap;
public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host, WorkingBeatmap defaultBeatmap, WorkingBeatmap testBeatmap) public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host, WorkingBeatmap defaultBeatmap)
: base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap) : base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap)
{ {
this.testBeatmap = testBeatmap;
} }
protected override BeatmapModelManager CreateBeatmapModelManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, GameHost host) protected override BeatmapModelManager CreateBeatmapModelManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, GameHost host)
@ -143,7 +152,7 @@ namespace osu.Game.Tests.Visual
} }
public override WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo) public override WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo)
=> testBeatmapManager.testBeatmap; => testBeatmapManager.TestBeatmap;
} }
internal class TestBeatmapModelManager : BeatmapModelManager internal class TestBeatmapModelManager : BeatmapModelManager