From 741fa201492c41b916744315f28593f1e3c57cd9 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 4 Jun 2020 00:47:10 +0300 Subject: [PATCH] Use CreateRuleset() for editor test scenes as well --- .../TestSceneEditor.cs | 3 ++- .../TestSceneEditor.cs | 5 +---- .../TestSceneEditor.cs | 5 +---- .../Editing/TestSceneEditorChangeStates.cs | 8 +++----- osu.Game/Tests/Visual/EditorTestScene.cs | 19 +++++++++++-------- 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneEditor.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneEditor.cs index 7ed886be49..3b9c03b86a 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneEditor.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneEditor.cs @@ -15,8 +15,9 @@ namespace osu.Game.Rulesets.Mania.Tests { private readonly Bindable direction = new Bindable(); + 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); diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneEditor.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneEditor.cs index 4aca34bf64..9239034a53 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneEditor.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneEditor.cs @@ -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(); } } diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneEditor.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneEditor.cs index 089a7ad00b..411fe08bcf 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TestSceneEditor.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneEditor.cs @@ -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(); } } diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorChangeStates.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorChangeStates.cs index 20862e9cac..293a6e6869 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorChangeStates.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorChangeStates.cs @@ -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(); diff --git a/osu.Game/Tests/Visual/EditorTestScene.cs b/osu.Game/Tests/Visual/EditorTestScene.cs index 2f6e6fb599..4f9a5b53b8 100644 --- a/osu.Game/Tests/Visual/EditorTestScene.cs +++ b/osu.Game/Tests/Visual/EditorTestScene.cs @@ -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().FirstOrDefault()?.IsLoaded == true); } + /// + /// Creates the ruleset for providing a corresponding beatmap to load the editor on. + /// + [NotNull] + protected abstract Ruleset CreateEditorRuleset(); + + protected sealed override Ruleset CreateRuleset() => CreateEditorRuleset(); + protected virtual Editor CreateEditor() => new Editor(); } }