mirror of https://github.com/ppy/osu
Update scenarios to use new `TestRunHeadlessGameHost` where feasible
This commit is contained in:
parent
aaf828714c
commit
dc44cc0eb3
|
@ -7,6 +7,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Collections.IO
|
||||
|
@ -127,7 +128,7 @@ public async Task TestImportMalformedDatabase()
|
|||
[Test]
|
||||
public async Task TestSaveAndReload()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
||||
using (HeadlessGameHost host = new TestRunHeadlessGameHost("TestSaveAndReload", bypassCleanup: true))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -148,7 +149,7 @@ public async Task TestSaveAndReload()
|
|||
}
|
||||
}
|
||||
|
||||
using (HeadlessGameHost host = new HeadlessGameHost("TestSaveAndReload"))
|
||||
using (HeadlessGameHost host = new TestRunHeadlessGameHost("TestSaveAndReload"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.IO;
|
||||
|
||||
|
@ -278,7 +278,7 @@ public void TestMigrationToSeeminglyNestedTarget()
|
|||
|
||||
private static string getDefaultLocationFor(string testTypeName)
|
||||
{
|
||||
string path = Path.Combine(RuntimeInfo.StartupDirectory, "headless", testTypeName);
|
||||
string path = Path.Combine(TestRunHeadlessGameHost.TemporaryTestDirectory, testTypeName);
|
||||
|
||||
if (Directory.Exists(path))
|
||||
Directory.Delete(path, true);
|
||||
|
@ -288,7 +288,7 @@ private static string getDefaultLocationFor(string testTypeName)
|
|||
|
||||
private string prepareCustomPath(string suffix = "")
|
||||
{
|
||||
string path = Path.Combine(RuntimeInfo.StartupDirectory, $"custom-path{suffix}");
|
||||
string path = Path.Combine(TestRunHeadlessGameHost.TemporaryTestDirectory, $"custom-path{suffix}");
|
||||
|
||||
if (Directory.Exists(path))
|
||||
Directory.Delete(path, true);
|
||||
|
@ -308,6 +308,15 @@ public CustomTestHeadlessGameHost([CallerMemberName] string callingMethodName =
|
|||
InitialStorage = new DesktopStorage(defaultStorageLocation, this);
|
||||
InitialStorage.DeleteDirectory(string.Empty);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
// the storage may have changed from the initial location.
|
||||
// this handles cleanup of the initial location.
|
||||
InitialStorage.DeleteDirectory(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
|
||||
namespace osu.Game.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// A headless host which cleans up before running (removing any remnants from a previous execution).
|
||||
/// </summary>
|
||||
public class CleanRunHeadlessGameHost : HeadlessGameHost
|
||||
public class CleanRunHeadlessGameHost : TestRunHeadlessGameHost
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new instance.
|
||||
|
|
|
@ -155,7 +155,7 @@ public virtual void RecycleLocalStorage()
|
|||
}
|
||||
|
||||
localStorage =
|
||||
new Lazy<Storage>(() => isolatedHostStorage ?? new NativeStorage(Path.Combine(RuntimeInfo.StartupDirectory, $"{GetType().Name}-{Guid.NewGuid()}")));
|
||||
new Lazy<Storage>(() => isolatedHostStorage ?? new TemporaryNativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
|
|
Loading…
Reference in New Issue