2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-18 21:32:49 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-09-19 19:04:37 +08:00
|
|
|
|
using System;
|
2018-02-07 13:11:54 +08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
|
|
|
|
public abstract class OsuTestCase : TestCase
|
|
|
|
|
{
|
|
|
|
|
public override void RunTest()
|
|
|
|
|
{
|
2018-02-08 16:07:18 +08:00
|
|
|
|
using (var host = new CleanRunHeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false))
|
2017-09-18 21:32:49 +08:00
|
|
|
|
host.Run(new OsuTestCaseTestRunner(this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class OsuTestCaseTestRunner : OsuGameBase
|
|
|
|
|
{
|
|
|
|
|
private readonly OsuTestCase testCase;
|
|
|
|
|
|
2018-02-07 13:11:54 +08:00
|
|
|
|
protected override string MainResourceFile => File.Exists(base.MainResourceFile) ? base.MainResourceFile : Assembly.GetExecutingAssembly().Location;
|
|
|
|
|
|
2017-09-18 21:32:49 +08:00
|
|
|
|
public OsuTestCaseTestRunner(OsuTestCase testCase)
|
|
|
|
|
{
|
|
|
|
|
this.testCase = testCase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
Add(new TestCaseTestRunner.TestRunner(testCase));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|