mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Centralise test storage logic
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
@ -20,6 +22,9 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected DependencyContainer Dependencies { get; private set; }
|
||||
|
||||
private readonly Lazy<Storage> localStorage;
|
||||
protected Storage LocalStorage => localStorage.Value;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
@ -33,6 +38,11 @@ namespace osu.Game.Tests.Visual
|
||||
return Dependencies;
|
||||
}
|
||||
|
||||
protected OsuTestCase()
|
||||
{
|
||||
localStorage = new Lazy<Storage>(() => new DesktopStorage($"{GetType().Name}-{Guid.NewGuid()}", null));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audioManager, RulesetStore rulesets)
|
||||
{
|
||||
@ -50,6 +60,9 @@ namespace osu.Game.Tests.Visual
|
||||
beatmap.Disabled = true;
|
||||
beatmap.Value.Track.Stop();
|
||||
}
|
||||
|
||||
if (localStorage.IsValueCreated)
|
||||
localStorage.Value.DeleteDirectory(".");
|
||||
}
|
||||
|
||||
protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner();
|
||||
|
Reference in New Issue
Block a user