mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 06:12:58 +08:00
Allow TestCasePlayer to instantiate only one ruleset type
This commit is contained in:
parent
cecfd7b0f3
commit
66afba6219
@ -10,6 +10,10 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseCatchPlayer : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseCatchPlayer : Game.Tests.Visual.TestCasePlayer
|
||||||
{
|
{
|
||||||
|
public TestCaseCatchPlayer() : base(typeof(CatchRuleset))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
protected override Beatmap CreateBeatmap()
|
protected override Beatmap CreateBeatmap()
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap();
|
var beatmap = new Beatmap();
|
||||||
|
@ -38,7 +38,6 @@ namespace osu.Game.Rulesets
|
|||||||
|
|
||||||
protected override void Prepare(bool reset = false)
|
protected override void Prepare(bool reset = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
Connection.CreateTable<RulesetInfo>();
|
Connection.CreateTable<RulesetInfo>();
|
||||||
|
|
||||||
if (reset)
|
if (reset)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 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.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -18,31 +19,39 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
public class TestCasePlayer : OsuTestCase
|
public class TestCasePlayer : OsuTestCase
|
||||||
{
|
{
|
||||||
|
private readonly Type ruleset;
|
||||||
|
|
||||||
protected Player Player;
|
protected Player Player;
|
||||||
private RulesetStore rulesets;
|
|
||||||
|
|
||||||
public override string Description => @"Showing everything to play the game.";
|
public override string Description => @"Showing everything to play the game.";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a TestCase which runs through the Player screen.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ruleset">An optional ruleset type which we want to target. If not provided we'll allow all rulesets to be tested.</param>
|
||||||
|
protected TestCasePlayer(Type ruleset)
|
||||||
|
{
|
||||||
|
this.ruleset = ruleset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestCasePlayer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(RulesetStore rulesets)
|
private void load(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
this.rulesets = rulesets;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
Add(new Box
|
Add(new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var r in rulesets.Query<RulesetInfo>())
|
string instantiation = ruleset?.AssemblyQualifiedName;
|
||||||
AddStep(r.Name, () => loadPlayerFor(r));
|
|
||||||
|
|
||||||
loadPlayerFor(rulesets.Query<RulesetInfo>().First());
|
foreach (var r in rulesets.Query<RulesetInfo>(rs => rs.Available && (instantiation == null || rs.InstantiationInfo == instantiation)))
|
||||||
|
AddStep(r.Name, () => loadPlayerFor(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Beatmap CreateBeatmap()
|
protected virtual Beatmap CreateBeatmap()
|
||||||
|
Loading…
Reference in New Issue
Block a user