mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Update scenarios to use new TestRunHeadlessGameHost
where feasible
This commit is contained in:
parent
aaf828714c
commit
dc44cc0eb3
@ -7,6 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Collections.IO
|
namespace osu.Game.Tests.Collections.IO
|
||||||
@ -127,7 +128,7 @@ namespace osu.Game.Tests.Collections.IO
|
|||||||
[Test]
|
[Test]
|
||||||
public async Task TestSaveAndReload()
|
public async Task TestSaveAndReload()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
using (HeadlessGameHost host = new TestRunHeadlessGameHost("TestSaveAndReload", bypassCleanup: true))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -148,7 +149,7 @@ namespace osu.Game.Tests.Collections.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (HeadlessGameHost host = new HeadlessGameHost("TestSaveAndReload"))
|
using (HeadlessGameHost host = new TestRunHeadlessGameHost("TestSaveAndReload"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,10 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
|
|
||||||
private static string getDefaultLocationFor(string testTypeName)
|
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))
|
if (Directory.Exists(path))
|
||||||
Directory.Delete(path, true);
|
Directory.Delete(path, true);
|
||||||
@ -288,7 +288,7 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
|
|
||||||
private string prepareCustomPath(string suffix = "")
|
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))
|
if (Directory.Exists(path))
|
||||||
Directory.Delete(path, true);
|
Directory.Delete(path, true);
|
||||||
@ -308,6 +308,15 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
InitialStorage = new DesktopStorage(defaultStorageLocation, this);
|
InitialStorage = new DesktopStorage(defaultStorageLocation, this);
|
||||||
InitialStorage.DeleteDirectory(string.Empty);
|
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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Testing;
|
||||||
|
|
||||||
namespace osu.Game.Tests
|
namespace osu.Game.Tests
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A headless host which cleans up before running (removing any remnants from a previous execution).
|
/// A headless host which cleans up before running (removing any remnants from a previous execution).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CleanRunHeadlessGameHost : HeadlessGameHost
|
public class CleanRunHeadlessGameHost : TestRunHeadlessGameHost
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new instance.
|
/// Create a new instance.
|
||||||
|
@ -155,7 +155,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
localStorage =
|
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]
|
[Resolved]
|
||||||
|
Loading…
Reference in New Issue
Block a user