1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 15:27:24 +08:00

Use CreateRuleset() for editor test scenes as well

This commit is contained in:
Salman Ahmed 2020-06-04 00:47:10 +03:00
parent c72592c52c
commit 741fa20149
No known key found for this signature in database
GPG Key ID: ED81FD33FD9B58BC
5 changed files with 18 additions and 22 deletions

View File

@ -15,8 +15,9 @@ namespace osu.Game.Rulesets.Mania.Tests
{
private readonly Bindable<ManiaScrollingDirection> direction = new Bindable<ManiaScrollingDirection>();
protected override Ruleset CreateEditorRuleset() => new ManiaRuleset();
public TestSceneEditor()
: base(new ManiaRuleset())
{
AddStep("upwards scroll", () => direction.Value = ManiaScrollingDirection.Up);
AddStep("downwards scroll", () => direction.Value = ManiaScrollingDirection.Down);

View File

@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestFixture]
public class TestSceneEditor : EditorTestScene
{
public TestSceneEditor()
: base(new OsuRuleset())
{
}
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
}
}

View File

@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Taiko.Tests
[TestFixture]
public class TestSceneEditor : EditorTestScene
{
public TestSceneEditor()
: base(new TaikoRuleset())
{
}
protected override Ruleset CreateEditorRuleset() => new TaikoRuleset();
}
}

View File

@ -4,6 +4,7 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
@ -13,13 +14,10 @@ namespace osu.Game.Tests.Visual.Editing
{
public class TestSceneEditorChangeStates : EditorTestScene
{
public TestSceneEditorChangeStates()
: base(new OsuRuleset())
{
}
private EditorBeatmap editorBeatmap;
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
public override void SetUpSteps()
{
base.SetUpSteps();

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Rulesets;
@ -15,17 +16,11 @@ namespace osu.Game.Tests.Visual
{
protected Editor Editor { get; private set; }
private readonly Ruleset ruleset;
protected EditorTestScene(Ruleset ruleset)
{
this.ruleset = ruleset;
}
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = CreateWorkingBeatmap(ruleset.RulesetInfo);
Ruleset.Value = CreateEditorRuleset().RulesetInfo;
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
}
public override void SetUpSteps()
@ -37,6 +32,14 @@ namespace osu.Game.Tests.Visual
&& Editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true);
}
/// <summary>
/// Creates the ruleset for providing a corresponding beatmap to load the editor on.
/// </summary>
[NotNull]
protected abstract Ruleset CreateEditorRuleset();
protected sealed override Ruleset CreateRuleset() => CreateEditorRuleset();
protected virtual Editor CreateEditor() => new Editor();
}
}