mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 08:52:58 +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:
commit
37036b855b
@ -66,6 +66,8 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
game.Dispose();
|
game.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecycleLocalStorage();
|
||||||
|
|
||||||
// see MouseSettings
|
// see MouseSettings
|
||||||
var frameworkConfig = host.Dependencies.Get<FrameworkConfigManager>();
|
var frameworkConfig = host.Dependencies.Get<FrameworkConfigManager>();
|
||||||
frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity).Disabled = false;
|
frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity).Disabled = false;
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected new OsuScreenDependencies Dependencies { get; private set; }
|
protected new OsuScreenDependencies Dependencies { get; private set; }
|
||||||
|
|
||||||
private readonly Lazy<Storage> localStorage;
|
private Lazy<Storage> localStorage;
|
||||||
protected Storage LocalStorage => localStorage.Value;
|
protected Storage LocalStorage => localStorage.Value;
|
||||||
|
|
||||||
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
||||||
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected OsuTestScene()
|
protected OsuTestScene()
|
||||||
{
|
{
|
||||||
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
|
RecycleLocalStorage();
|
||||||
contextFactory = new Lazy<DatabaseContextFactory>(() =>
|
contextFactory = new Lazy<DatabaseContextFactory>(() =>
|
||||||
{
|
{
|
||||||
var factory = new DatabaseContextFactory(LocalStorage);
|
var factory = new DatabaseContextFactory(LocalStorage);
|
||||||
@ -104,6 +104,23 @@ namespace osu.Game.Tests.Visual
|
|||||||
base.Content.Add(content = new DrawSizePreservingFillContainer());
|
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]
|
[Resolved]
|
||||||
protected AudioManager Audio { get; private set; }
|
protected AudioManager Audio { get; private set; }
|
||||||
|
|
||||||
@ -131,17 +148,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
if (contextFactory.IsValueCreated)
|
if (contextFactory.IsValueCreated)
|
||||||
contextFactory.Value.ResetDatabase();
|
contextFactory.Value.ResetDatabase();
|
||||||
|
|
||||||
if (localStorage.IsValueCreated)
|
RecycleLocalStorage();
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
localStorage.Value.DeleteDirectory(".");
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// we don't really care if this fails; it will just leave folders lying around from test runs.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner();
|
protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner();
|
||||||
|
Loading…
Reference in New Issue
Block a user