1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Merge branch 'fix-key-binding-destruction' into better-skin-hashing

This commit is contained in:
Dean Herbert 2020-09-17 11:59:36 +09:00
commit 0d9f531e19

View File

@ -69,12 +69,26 @@ namespace osu.Game.Tests.Visual
/// </summary> /// </summary>
protected virtual bool UseOnlineAPI => false; protected virtual bool UseOnlineAPI => false;
/// <summary>
/// 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.
/// </summary>
private Storage isolatedHostStorage;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
if (!UseFreshStoragePerRun)
isolatedHostStorage = (parent.Get<GameHost>() as HeadlessGameHost)?.Storage;
contextFactory = new Lazy<DatabaseContextFactory>(() => contextFactory = new Lazy<DatabaseContextFactory>(() =>
{ {
var factory = new DatabaseContextFactory(LocalStorage); var factory = new DatabaseContextFactory(LocalStorage);
// only reset the database if not using the host storage.
// if we reset the host storage, it will delete global key bindings.
if (isolatedHostStorage == null)
factory.ResetDatabase(); factory.ResetDatabase();
using (var usage = factory.Get()) using (var usage = factory.Get())
usage.Migrate(); usage.Migrate();
return factory; return factory;
@ -135,12 +149,9 @@ namespace osu.Game.Tests.Visual
} }
localStorage = localStorage =
new Lazy<Storage>(() => !UseFreshStoragePerRun && host is HeadlessGameHost ? host.Storage : new NativeStorage(Path.Combine(RuntimeInfo.StartupDirectory, $"{GetType().Name}-{Guid.NewGuid()}"))); new Lazy<Storage>(() => isolatedHostStorage ?? new NativeStorage(Path.Combine(RuntimeInfo.StartupDirectory, $"{GetType().Name}-{Guid.NewGuid()}")));
} }
[Resolved]
private GameHost host { get; set; }
[Resolved] [Resolved]
protected AudioManager Audio { get; private set; } protected AudioManager Audio { get; private set; }