Merge pull request #2415 from smoogipoo/better-test-case

Update OsuTestCase with framework testing changes
This commit is contained in:
Dean Herbert 2018-04-18 15:56:09 +09:00 committed by GitHub
commit 0a292a6ab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

@ -1 +1 @@
Subproject commit f858902d167c42d000662cb3a1cd202d723ea182 Subproject commit 16e6a453db9a8f4454238a2911eb5f1444b7ec2a

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using osu.Framework.Testing; using osu.Framework.Testing;
@ -10,28 +9,27 @@ namespace osu.Game.Tests.Visual
{ {
public abstract class OsuTestCase : TestCase public abstract class OsuTestCase : TestCase
{ {
public override void RunTest() protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner();
{
using (var host = new CleanRunHeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false))
host.Run(new OsuTestCaseTestRunner(this));
}
public class OsuTestCaseTestRunner : OsuGameBase public class OsuTestCaseTestRunner : OsuGameBase, ITestCaseTestRunner
{ {
private readonly OsuTestCase testCase;
protected override string MainResourceFile => File.Exists(base.MainResourceFile) ? base.MainResourceFile : Assembly.GetExecutingAssembly().Location; protected override string MainResourceFile => File.Exists(base.MainResourceFile) ? base.MainResourceFile : Assembly.GetExecutingAssembly().Location;
public OsuTestCaseTestRunner(OsuTestCase testCase) private readonly TestCaseTestRunner.TestRunner runner;
public OsuTestCaseTestRunner()
{ {
this.testCase = testCase; runner = new TestCaseTestRunner.TestRunner();
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
Add(new TestCaseTestRunner.TestRunner(testCase));
Add(runner);
} }
public void RunTestBlocking(TestCase test) => runner.RunTestBlocking(test);
} }
} }
} }