1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:47:51 +08:00

Fix test scene to handle restarts properly

This commit is contained in:
Bartłomiej Dach 2022-07-23 21:56:10 +02:00
parent 9dea8e3d12
commit 9d3cdae4bb
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -22,8 +22,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{ {
protected override bool UseFreshStoragePerRun => true; protected override bool UseFreshStoragePerRun => true;
[Resolved] private RulesetStore rulesets = null!;
private RulesetStore rulesets { get; set; } = null!;
[Cached] [Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
@ -31,18 +30,25 @@ namespace osu.Game.Tests.Visual.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
Dependencies.Cache(Realm); Dependencies.Cache(Realm);
} }
[SetUpSteps] [SetUpSteps]
public void SetUpSteps() public void SetUpSteps()
{ {
AddStep("clear contents", Clear);
AddStep("reset storage", () => AddStep("reset storage", () =>
{ {
Realm.Write(realm => Realm.Write(realm =>
{ {
realm.RemoveAll<ModPreset>(); realm.RemoveAll<ModPreset>();
realm.Add(createTestPresets());
var testPresets = createTestPresets();
foreach (var preset in testPresets)
preset.Ruleset = realm.Find<RulesetInfo>(preset.Ruleset.ShortName);
realm.Add(testPresets);
}); });
}); });
} }
@ -75,7 +81,7 @@ namespace osu.Game.Tests.Visual.UserInterface
new ManiaModNightcore(), new ManiaModNightcore(),
new ManiaModHardRock() new ManiaModHardRock()
}, },
Ruleset = rulesets.GetRuleset(3).AsNonNull() Ruleset = r.Find<RulesetInfo>("mania")
}))); })));
AddUntilStep("2 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 2); AddUntilStep("2 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 2);
@ -87,7 +93,7 @@ namespace osu.Game.Tests.Visual.UserInterface
new OsuModHidden(), new OsuModHidden(),
new OsuModHardRock() new OsuModHardRock()
}, },
Ruleset = rulesets.GetRuleset(0).AsNonNull() Ruleset = r.Find<RulesetInfo>("osu")
}))); })));
AddUntilStep("2 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 2); AddUntilStep("2 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 2);
@ -140,7 +146,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddUntilStep("3 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 3); AddUntilStep("3 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 3);
} }
private IEnumerable<ModPreset> createTestPresets() => new[] private ICollection<ModPreset> createTestPresets() => new[]
{ {
new ModPreset new ModPreset
{ {