1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 21:23:04 +08:00

Merge pull request #7654 from peppy/reset-test-storage

Add a method to recycle test storage between runs
This commit is contained in:
Dan Balasescu 2020-01-29 16:37:37 +09:00 committed by GitHub
commit 37036b855b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 13 deletions

View File

@ -66,6 +66,8 @@ namespace osu.Game.Tests.Visual.Menus
game.Dispose();
}
RecycleLocalStorage();
// see MouseSettings
var frameworkConfig = host.Dependencies.Get<FrameworkConfigManager>();
frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity).Disabled = false;

View File

@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual
protected new OsuScreenDependencies Dependencies { get; private set; }
private readonly Lazy<Storage> localStorage;
private Lazy<Storage> localStorage;
protected Storage LocalStorage => localStorage.Value;
private readonly Lazy<DatabaseContextFactory> contextFactory;
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual
protected OsuTestScene()
{
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
RecycleLocalStorage();
contextFactory = new Lazy<DatabaseContextFactory>(() =>
{
var factory = new DatabaseContextFactory(LocalStorage);
@ -104,6 +104,23 @@ namespace osu.Game.Tests.Visual
base.Content.Add(content = new DrawSizePreservingFillContainer());
}
public void RecycleLocalStorage()
{
if (localStorage?.IsValueCreated == true)
{
try
{
localStorage.Value.DeleteDirectory(".");
}
catch
{
// we don't really care if this fails; it will just leave folders lying around from test runs.
}
}
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
}
[Resolved]
protected AudioManager Audio { get; private set; }
@ -131,17 +148,7 @@ namespace osu.Game.Tests.Visual
if (contextFactory.IsValueCreated)
contextFactory.Value.ResetDatabase();
if (localStorage.IsValueCreated)
{
try
{
localStorage.Value.DeleteDirectory(".");
}
catch
{
// we don't really care if this fails; it will just leave folders lying around from test runs.
}
}
RecycleLocalStorage();
}
protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner();