diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index cb4af67839..ca7b7b27b0 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -43,13 +43,6 @@ namespace osu.Game.Tests.Visual protected new OsuScreenDependencies Dependencies { get; private set; } - private DrawableRulesetDependencies rulesetDependencies; - - private Lazy localStorage; - protected Storage LocalStorage => localStorage.Value; - - private Lazy contextFactory; - protected IResourceStore Resources; protected IAPIProvider API @@ -65,23 +58,32 @@ namespace osu.Game.Tests.Visual private DummyAPIAccess dummyAPI; - protected DatabaseContextFactory ContextFactory => contextFactory.Value; - /// /// Whether this test scene requires real-world API access. /// If true, this will bypass the local and use the provided one. /// protected virtual bool UseOnlineAPI => false; + protected DatabaseContextFactory ContextFactory => contextFactory.Value; + + private Lazy contextFactory; + + protected virtual bool UseFreshStoragePerRun => false; + /// - /// When running headless, there is an opportunity to use the host storage rather than creating a second isolated one. - /// This is because the host is recycled per TestScene execution in headless at an nunit level. + /// A storage to be used by test runs. Can be isolated by setting to true. /// - private Storage isolatedHostStorage; + protected Storage LocalStorage => localStorage.Value; + + private Lazy localStorage; + + private Storage headlessHostStorage; + + private DrawableRulesetDependencies rulesetDependencies; protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { - isolatedHostStorage = (parent.Get() as HeadlessGameHost)?.Storage; + headlessHostStorage = (parent.Get() as HeadlessGameHost)?.Storage; Resources = parent.Get().Resources; @@ -132,8 +134,6 @@ namespace osu.Game.Tests.Visual base.Content.Add(content = new DrawSizePreservingFillContainer()); } - protected virtual bool UseFreshStoragePerRun => false; - public virtual void RecycleLocalStorage(bool isDisposing) { if (localStorage?.IsValueCreated == true) @@ -153,8 +153,8 @@ namespace osu.Game.Tests.Visual // When running headless, there is an opportunity to use the host storage rather than creating a second isolated one. // This is because the host is recycled per TestScene execution in headless at an nunit level. // Importantly, we can't use this optimisation when `UseFreshStoragePerRun` is true, as it doesn't reset per test method. - if (!UseFreshStoragePerRun && isolatedHostStorage != null) - return isolatedHostStorage; + if (!UseFreshStoragePerRun && headlessHostStorage != null) + return headlessHostStorage; return new TemporaryNativeStorage($"{GetType().Name}-{Guid.NewGuid()}"); });