Skip to content

Commit

Permalink
Merge pull request #2415 from smoogipoo/better-test-case
Browse files Browse the repository at this point in the history
Update OsuTestCase with framework testing changes
  • Loading branch information
peppy committed Apr 18, 2018
2 parents bc31507 + 560fcfc commit 0a292a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions osu.Game/Tests/Visual/OsuTestCase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.IO;
using System.Reflection;
using osu.Framework.Testing;
Expand All @@ -10,28 +9,27 @@ namespace osu.Game.Tests.Visual
{
public abstract class OsuTestCase : TestCase
{
public override void RunTest()
{
using (var host = new CleanRunHeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false))
host.Run(new OsuTestCaseTestRunner(this));
}
protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner();

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;

public OsuTestCaseTestRunner(OsuTestCase testCase)
private readonly TestCaseTestRunner.TestRunner runner;

public OsuTestCaseTestRunner()
{
this.testCase = testCase;
runner = new TestCaseTestRunner.TestRunner();
}

protected override void LoadComplete()
{
base.LoadComplete();
Add(new TestCaseTestRunner.TestRunner(testCase));

Add(runner);
}

public void RunTestBlocking(TestCase test) => runner.RunTestBlocking(test);
}
}
}

0 comments on commit 0a292a6

Please sign in to comment.