mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 17:53:15 +08:00
Rename and reorder fields in OsuTestScene
This commit is contained in:
parent
5631e75f16
commit
55f7d120e6
@ -43,13 +43,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected new OsuScreenDependencies Dependencies { get; private set; }
|
protected new OsuScreenDependencies Dependencies { get; private set; }
|
||||||
|
|
||||||
private DrawableRulesetDependencies rulesetDependencies;
|
|
||||||
|
|
||||||
private Lazy<Storage> localStorage;
|
|
||||||
protected Storage LocalStorage => localStorage.Value;
|
|
||||||
|
|
||||||
private Lazy<DatabaseContextFactory> contextFactory;
|
|
||||||
|
|
||||||
protected IResourceStore<byte[]> Resources;
|
protected IResourceStore<byte[]> Resources;
|
||||||
|
|
||||||
protected IAPIProvider API
|
protected IAPIProvider API
|
||||||
@ -65,23 +58,32 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private DummyAPIAccess dummyAPI;
|
private DummyAPIAccess dummyAPI;
|
||||||
|
|
||||||
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this test scene requires real-world API access.
|
/// Whether this test scene requires real-world API access.
|
||||||
/// If true, this will bypass the local <see cref="DummyAPIAccess"/> and use the <see cref="OsuGameBase"/> provided one.
|
/// If true, this will bypass the local <see cref="DummyAPIAccess"/> and use the <see cref="OsuGameBase"/> provided one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool UseOnlineAPI => false;
|
protected virtual bool UseOnlineAPI => false;
|
||||||
|
|
||||||
|
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
|
||||||
|
|
||||||
|
private Lazy<DatabaseContextFactory> contextFactory;
|
||||||
|
|
||||||
|
protected virtual bool UseFreshStoragePerRun => false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When running headless, there is an opportunity to use the host storage rather than creating a second isolated one.
|
/// A storage to be used by test runs. Can be isolated by setting <see cref="UseFreshStoragePerRun"/> to <c>true</c>.
|
||||||
/// This is because the host is recycled per TestScene execution in headless at an nunit level.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Storage isolatedHostStorage;
|
protected Storage LocalStorage => localStorage.Value;
|
||||||
|
|
||||||
|
private Lazy<Storage> localStorage;
|
||||||
|
|
||||||
|
private Storage headlessHostStorage;
|
||||||
|
|
||||||
|
private DrawableRulesetDependencies rulesetDependencies;
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
isolatedHostStorage = (parent.Get<GameHost>() as HeadlessGameHost)?.Storage;
|
headlessHostStorage = (parent.Get<GameHost>() as HeadlessGameHost)?.Storage;
|
||||||
|
|
||||||
Resources = parent.Get<OsuGameBase>().Resources;
|
Resources = parent.Get<OsuGameBase>().Resources;
|
||||||
|
|
||||||
@ -132,8 +134,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
base.Content.Add(content = new DrawSizePreservingFillContainer());
|
base.Content.Add(content = new DrawSizePreservingFillContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool UseFreshStoragePerRun => false;
|
|
||||||
|
|
||||||
public virtual void RecycleLocalStorage(bool isDisposing)
|
public virtual void RecycleLocalStorage(bool isDisposing)
|
||||||
{
|
{
|
||||||
if (localStorage?.IsValueCreated == true)
|
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.
|
// 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.
|
// 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.
|
// Importantly, we can't use this optimisation when `UseFreshStoragePerRun` is true, as it doesn't reset per test method.
|
||||||
if (!UseFreshStoragePerRun && isolatedHostStorage != null)
|
if (!UseFreshStoragePerRun && headlessHostStorage != null)
|
||||||
return isolatedHostStorage;
|
return headlessHostStorage;
|
||||||
|
|
||||||
return new TemporaryNativeStorage($"{GetType().Name}-{Guid.NewGuid()}");
|
return new TemporaryNativeStorage($"{GetType().Name}-{Guid.NewGuid()}");
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user