Merge pull request #8778 from frenzibyte/test-scene-create-ruleset

Add method of creating a ruleset for testing with in OsuTestScene
This commit is contained in:
Dan Balasescu 2020-06-15 17:22:54 +09:00 committed by GitHub
commit c09868780e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 127 additions and 184 deletions

View File

@ -13,8 +13,10 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
{ {
public class TestSceneCatchModPerfect : ModPerfectTestScene public class TestSceneCatchModPerfect : ModPerfectTestScene
{ {
protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
public TestSceneCatchModPerfect() public TestSceneCatchModPerfect()
: base(new CatchRuleset(), new CatchModPerfect()) : base(new CatchModPerfect())
{ {
} }

View File

@ -12,13 +12,8 @@ using osuTK;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
public class TestSceneAutoJuiceStream : PlayerTestScene public class TestSceneAutoJuiceStream : TestSceneCatchPlayer
{ {
public TestSceneAutoJuiceStream()
: base(new CatchRuleset())
{
}
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{ {
var beatmap = new Beatmap var beatmap = new Beatmap

View File

@ -4,18 +4,12 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
[TestFixture] [TestFixture]
public class TestSceneBananaShower : PlayerTestScene public class TestSceneBananaShower : TestSceneCatchPlayer
{ {
public TestSceneBananaShower()
: base(new CatchRuleset())
{
}
[Test] [Test]
public void TestBananaShower() public void TestBananaShower()
{ {

View File

@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestFixture] [TestFixture]
public class TestSceneCatchPlayer : PlayerTestScene public class TestSceneCatchPlayer : PlayerTestScene
{ {
public TestSceneCatchPlayer() protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
: base(new CatchRuleset())
{
}
} }
} }

View File

@ -4,18 +4,12 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
[TestFixture] [TestFixture]
public class TestSceneCatchStacker : PlayerTestScene public class TestSceneCatchStacker : TestSceneCatchPlayer
{ {
public TestSceneCatchStacker()
: base(new CatchRuleset())
{
}
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{ {
var beatmap = new Beatmap var beatmap = new Beatmap

View File

@ -9,19 +9,13 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Visual;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
[TestFixture] [TestFixture]
public class TestSceneHyperDash : PlayerTestScene public class TestSceneHyperDash : TestSceneCatchPlayer
{ {
public TestSceneHyperDash()
: base(new CatchRuleset())
{
}
protected override bool Autoplay => true; protected override bool Autoplay => true;
[Test] [Test]

View File

@ -7,18 +7,12 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Tests.Visual;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
public class TestSceneJuiceStream : PlayerTestScene public class TestSceneJuiceStream : TestSceneCatchPlayer
{ {
public TestSceneJuiceStream()
: base(new CatchRuleset())
{
}
[Test] [Test]
public void TestJuiceStreamEndingCombo() public void TestJuiceStreamEndingCombo()
{ {

View File

@ -10,8 +10,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
{ {
public class TestSceneManiaModPerfect : ModPerfectTestScene public class TestSceneManiaModPerfect : ModPerfectTestScene
{ {
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
public TestSceneManiaModPerfect() public TestSceneManiaModPerfect()
: base(new ManiaRuleset(), new ManiaModPerfect()) : base(new ManiaModPerfect())
{ {
} }

View File

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

View File

@ -5,11 +5,8 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Mania.Tests namespace osu.Game.Rulesets.Mania.Tests
{ {
public class TestScenePlayer : PlayerTestScene public class TestSceneManiaPlayer : PlayerTestScene
{
public TestScenePlayer()
: base(new ManiaRuleset())
{ {
} protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
} }
} }

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Mods
{
public class OsuModTestScene : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
}
}

View File

@ -9,17 +9,11 @@ using osu.Framework.Utils;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Mods namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
public class TestSceneOsuModDifficultyAdjust : ModTestScene public class TestSceneOsuModDifficultyAdjust : OsuModTestScene
{ {
public TestSceneOsuModDifficultyAdjust()
: base(new OsuRuleset())
{
}
[Test] [Test]
public void TestNoAdjustment() => CreateModTest(new ModTestData public void TestNoAdjustment() => CreateModTest(new ModTestData
{ {

View File

@ -4,17 +4,11 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Mods namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
public class TestSceneOsuModDoubleTime : ModTestScene public class TestSceneOsuModDoubleTime : OsuModTestScene
{ {
public TestSceneOsuModDoubleTime()
: base(new OsuRuleset())
{
}
[TestCase(0.5)] [TestCase(0.5)]
[TestCase(1.01)] [TestCase(1.01)]
[TestCase(1.5)] [TestCase(1.5)]

View File

@ -8,18 +8,12 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Visual;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Osu.Tests.Mods namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
public class TestSceneOsuModHidden : ModTestScene public class TestSceneOsuModHidden : OsuModTestScene
{ {
public TestSceneOsuModHidden()
: base(new OsuRuleset())
{
}
[Test] [Test]
public void TestDefaultBeatmapTest() => CreateModTest(new ModTestData public void TestDefaultBeatmapTest() => CreateModTest(new ModTestData
{ {

View File

@ -13,8 +13,10 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
public class TestSceneOsuModPerfect : ModPerfectTestScene public class TestSceneOsuModPerfect : ModPerfectTestScene
{ {
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
public TestSceneOsuModPerfect() public TestSceneOsuModPerfect()
: base(new OsuRuleset(), new OsuModPerfect()) : base(new OsuModPerfect())
{ {
} }

View File

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

View File

@ -4,19 +4,13 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Visual;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
[TestFixture] [TestFixture]
public class TestSceneHitCircleLongCombo : PlayerTestScene public class TestSceneHitCircleLongCombo : TestSceneOsuPlayer
{ {
public TestSceneHitCircleLongCombo()
: base(new OsuRuleset())
{
}
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{ {
var beatmap = new Beatmap var beatmap = new Beatmap

View File

@ -19,10 +19,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
public class TestSceneMissHitWindowJudgements : ModTestScene public class TestSceneMissHitWindowJudgements : ModTestScene
{ {
public TestSceneMissHitWindowJudgements() protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
: base(new OsuRuleset())
{
}
[Test] [Test]
public void TestMissViaEarlyHit() public void TestMissViaEarlyHit()

View File

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

View File

@ -25,13 +25,12 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
[TestFixture] [TestFixture]
public class TestSceneSkinFallbacks : PlayerTestScene public class TestSceneSkinFallbacks : TestSceneOsuPlayer
{ {
private readonly TestSource testUserSkin; private readonly TestSource testUserSkin;
private readonly TestSource testBeatmapSkin; private readonly TestSource testBeatmapSkin;
public TestSceneSkinFallbacks() public TestSceneSkinFallbacks()
: base(new OsuRuleset())
{ {
testUserSkin = new TestSource("user"); testUserSkin = new TestSource("user");
testBeatmapSkin = new TestSource("beatmap"); testBeatmapSkin = new TestSource("beatmap");

View File

@ -12,8 +12,10 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{ {
public class TestSceneTaikoModPerfect : ModPerfectTestScene public class TestSceneTaikoModPerfect : ModPerfectTestScene
{ {
protected override Ruleset CreatePlayerRuleset() => new TestTaikoRuleset();
public TestSceneTaikoModPerfect() public TestSceneTaikoModPerfect()
: base(new TestTaikoRuleset(), new TaikoModPerfect()) : base(new TaikoModPerfect())
{ {
} }

View File

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

View File

@ -6,7 +6,6 @@ using osu.Framework.Testing;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests namespace osu.Game.Rulesets.Taiko.Tests
{ {
@ -14,13 +13,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
/// Taiko has some interesting rules for legacy mappings. /// Taiko has some interesting rules for legacy mappings.
/// </summary> /// </summary>
[HeadlessTest] [HeadlessTest]
public class TestSceneSampleOutput : PlayerTestScene public class TestSceneSampleOutput : TestSceneTaikoPlayer
{ {
public TestSceneSampleOutput()
: base(new TaikoRuleset())
{
}
public override void SetUpSteps() public override void SetUpSteps()
{ {
base.SetUpSteps(); base.SetUpSteps();

View File

@ -5,17 +5,11 @@ using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests namespace osu.Game.Rulesets.Taiko.Tests
{ {
public class TestSceneSwellJudgements : PlayerTestScene public class TestSceneSwellJudgements : TestSceneTaikoPlayer
{ {
public TestSceneSwellJudgements()
: base(new TaikoRuleset())
{
}
[Test] [Test]
public void TestZeroTickTimeOffsets() public void TestZeroTickTimeOffsets()
{ {

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneTaikoPlayer : PlayerTestScene
{
protected override Ruleset CreatePlayerRuleset() => new TaikoRuleset();
}
}

View File

@ -11,13 +11,8 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests namespace osu.Game.Rulesets.Taiko.Tests
{ {
public class TestSceneTaikoSuddenDeath : PlayerTestScene public class TestSceneTaikoSuddenDeath : TestSceneTaikoPlayer
{ {
public TestSceneTaikoSuddenDeath()
: base(new TaikoRuleset())
{
}
protected override bool AllowFail => true; protected override bool AllowFail => true;
protected override TestPlayer CreatePlayer(Ruleset ruleset) protected override TestPlayer CreatePlayer(Ruleset ruleset)

View File

@ -16,17 +16,16 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Storyboards; using osu.Game.Storyboards;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual.Gameplay;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Tests.Gameplay namespace osu.Game.Tests.Gameplay
{ {
[HeadlessTest] [HeadlessTest]
public class TestSceneHitObjectSamples : PlayerTestScene public class TestSceneHitObjectSamples : OsuPlayerTestScene
{ {
private readonly SkinInfo userSkinInfo = new SkinInfo(); private readonly SkinInfo userSkinInfo = new SkinInfo();
@ -44,11 +43,6 @@ namespace osu.Game.Tests.Gameplay
protected override bool HasCustomSteps => true; protected override bool HasCustomSteps => true;
public TestSceneHitObjectSamples()
: base(new OsuRuleset())
{
}
private SkinSourceDependencyContainer dependencies; private SkinSourceDependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)

View File

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

View File

@ -0,0 +1,16 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.Gameplay
{
/// <summary>
/// A <see cref="PlayerTestScene"/> with an arbitrary ruleset value to test with.
/// </summary>
public abstract class OsuPlayerTestScene : PlayerTestScene
{
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
}
}

View File

@ -10,14 +10,13 @@ using osu.Framework.Testing;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Storyboards; using osu.Game.Storyboards;
using osuTK; using osuTK;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
public class TestSceneCompletionCancellation : PlayerTestScene public class TestSceneCompletionCancellation : OsuPlayerTestScene
{ {
private Track track; private Track track;
@ -29,11 +28,6 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override bool AllowFail => false; protected override bool AllowFail => false;
public TestSceneCompletionCancellation()
: base(new OsuRuleset())
{
}
[SetUpSteps] [SetUpSteps]
public override void SetUpSteps() public override void SetUpSteps()
{ {

View File

@ -10,23 +10,17 @@ using osu.Framework.Utils;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Storyboards; using osu.Game.Storyboards;
using osuTK; using osuTK;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
public class TestSceneGameplayRewinding : PlayerTestScene public class TestSceneGameplayRewinding : OsuPlayerTestScene
{ {
[Resolved] [Resolved]
private AudioManager audioManager { get; set; } private AudioManager audioManager { get; set; }
public TestSceneGameplayRewinding()
: base(new OsuRuleset())
{
}
private Track track; private Track track;
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)

View File

@ -10,14 +10,13 @@ using osu.Framework.Testing;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osuTK; using osuTK;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
public class TestScenePause : PlayerTestScene public class TestScenePause : OsuPlayerTestScene
{ {
protected new PausePlayer Player => (PausePlayer)base.Player; protected new PausePlayer Player => (PausePlayer)base.Player;
@ -26,7 +25,6 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
public TestScenePause() public TestScenePause()
: base(new OsuRuleset())
{ {
base.Content.Add(content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }); base.Content.Add(content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both });
} }

View File

@ -8,12 +8,11 @@ using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
[HeadlessTest] // we alter unsafe properties on the game host to test inactive window state. [HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
public class TestScenePauseWhenInactive : PlayerTestScene public class TestScenePauseWhenInactive : OsuPlayerTestScene
{ {
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{ {
@ -27,11 +26,6 @@ namespace osu.Game.Tests.Visual.Gameplay
[Resolved] [Resolved]
private GameHost host { get; set; } private GameHost host { get; set; }
public TestScenePauseWhenInactive()
: base(new OsuRuleset())
{
}
[Test] [Test]
public void TestDoesntPauseDuringIntro() public void TestDoesntPauseDuringIntro()
{ {

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@ -15,17 +16,10 @@ namespace osu.Game.Tests.Visual
{ {
protected Editor Editor { get; private set; } protected Editor Editor { get; private set; }
private readonly Ruleset ruleset;
protected EditorTestScene(Ruleset ruleset)
{
this.ruleset = ruleset;
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Beatmap.Value = CreateWorkingBeatmap(ruleset.RulesetInfo); Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
} }
public override void SetUpSteps() public override void SetUpSteps()
@ -37,6 +31,14 @@ namespace osu.Game.Tests.Visual
&& Editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true); && 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(); protected virtual Editor CreateEditor() => new Editor();
} }
} }

View File

@ -10,13 +10,10 @@ namespace osu.Game.Tests.Visual
{ {
public abstract class ModPerfectTestScene : ModTestScene public abstract class ModPerfectTestScene : ModTestScene
{ {
private readonly Ruleset ruleset;
private readonly ModPerfect mod; private readonly ModPerfect mod;
protected ModPerfectTestScene(Ruleset ruleset, ModPerfect mod) protected ModPerfectTestScene(ModPerfect mod)
: base(ruleset)
{ {
this.ruleset = ruleset;
this.mod = mod; this.mod = mod;
} }
@ -25,7 +22,7 @@ namespace osu.Game.Tests.Visual
Mod = mod, Mod = mod,
Beatmap = new Beatmap Beatmap = new Beatmap
{ {
BeatmapInfo = { Ruleset = ruleset.RulesetInfo }, BeatmapInfo = { Ruleset = CreatePlayerRuleset().RulesetInfo },
HitObjects = { testData.HitObject } HitObjects = { testData.HitObject }
}, },
Autoplay = !shouldMiss, Autoplay = !shouldMiss,

View File

@ -14,11 +14,6 @@ namespace osu.Game.Tests.Visual
{ {
protected sealed override bool HasCustomSteps => true; protected sealed override bool HasCustomSteps => true;
protected ModTestScene(Ruleset ruleset)
: base(ruleset)
{
}
private ModTestData currentTestData; private ModTestData currentTestData;
protected void CreateModTest(ModTestData testData) => CreateTest(() => protected void CreateModTest(ModTestData testData) => CreateTest(() =>

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -125,6 +126,15 @@ namespace osu.Game.Tests.Visual
[Resolved] [Resolved]
protected AudioManager Audio { get; private set; } protected AudioManager Audio { get; private set; }
/// <summary>
/// Creates the ruleset to be used for this test scene.
/// </summary>
/// <remarks>
/// When testing against ruleset-specific components, this method must be overriden to their corresponding ruleset.
/// </remarks>
[CanBeNull]
protected virtual Ruleset CreateRuleset() => null;
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) => protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) =>
@ -136,7 +146,7 @@ namespace osu.Game.Tests.Visual
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(RulesetStore rulesets) private void load(RulesetStore rulesets)
{ {
Ruleset.Value = rulesets.AvailableRulesets.First(); Ruleset.Value = CreateRuleset()?.RulesetInfo ?? rulesets.AvailableRulesets.First();
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Testing; using osu.Framework.Testing;
@ -19,15 +20,8 @@ namespace osu.Game.Tests.Visual
/// </summary> /// </summary>
protected virtual bool HasCustomSteps { get; } = false; protected virtual bool HasCustomSteps { get; } = false;
private readonly Ruleset ruleset;
protected TestPlayer Player; protected TestPlayer Player;
protected PlayerTestScene(Ruleset ruleset)
{
this.ruleset = ruleset;
}
protected OsuConfigManager LocalConfig; protected OsuConfigManager LocalConfig;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -53,7 +47,7 @@ namespace osu.Game.Tests.Visual
action?.Invoke(); action?.Invoke();
AddStep(ruleset.RulesetInfo.Name, LoadPlayer); AddStep(CreatePlayerRuleset().Description, LoadPlayer);
AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1); AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1);
} }
@ -63,11 +57,10 @@ namespace osu.Game.Tests.Visual
protected void LoadPlayer() protected void LoadPlayer()
{ {
var ruleset = Ruleset.Value.CreateInstance();
var beatmap = CreateBeatmap(ruleset.RulesetInfo); var beatmap = CreateBeatmap(ruleset.RulesetInfo);
Beatmap.Value = CreateWorkingBeatmap(beatmap); Beatmap.Value = CreateWorkingBeatmap(beatmap);
Ruleset.Value = ruleset.RulesetInfo;
SelectedMods.Value = Array.Empty<Mod>(); SelectedMods.Value = Array.Empty<Mod>();
if (!AllowFail) if (!AllowFail)
@ -88,6 +81,14 @@ namespace osu.Game.Tests.Visual
LoadScreen(Player); LoadScreen(Player);
} }
/// <summary>
/// Creates the ruleset for setting up the <see cref="Player"/> component.
/// </summary>
[NotNull]
protected abstract Ruleset CreatePlayerRuleset();
protected sealed override Ruleset CreateRuleset() => CreatePlayerRuleset();
protected virtual TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false); protected virtual TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false);
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -32,9 +33,6 @@ namespace osu.Game.Tests.Visual
{ {
} }
// Required to be part of the per-ruleset implementation to construct the newer version of the Ruleset.
protected abstract Ruleset CreateRulesetForSkinProvider();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, SkinManager skinManager) private void load(AudioManager audio, SkinManager skinManager)
{ {
@ -107,7 +105,7 @@ namespace osu.Game.Tests.Visual
{ {
new OutlineBox { Alpha = autoSize ? 1 : 0 }, new OutlineBox { Alpha = autoSize ? 1 : 0 },
mainProvider.WithChild( mainProvider.WithChild(
new SkinProvidingContainer(CreateRulesetForSkinProvider().CreateLegacySkinProvider(mainProvider, beatmap)) new SkinProvidingContainer(Ruleset.Value.CreateInstance().CreateLegacySkinProvider(mainProvider, beatmap))
{ {
Child = created, Child = created,
RelativeSizeAxes = !autoSize ? Axes.Both : Axes.None, RelativeSizeAxes = !autoSize ? Axes.Both : Axes.None,
@ -120,6 +118,14 @@ namespace osu.Game.Tests.Visual
}; };
} }
/// <summary>
/// Creates the ruleset for adding the corresponding skin transforming component.
/// </summary>
[NotNull]
protected abstract Ruleset CreateRulesetForSkinProvider();
protected sealed override Ruleset CreateRuleset() => CreateRulesetForSkinProvider();
protected virtual IBeatmap CreateBeatmapForSkinProvider() => CreateWorkingBeatmap(Ruleset.Value).GetPlayableBeatmap(Ruleset.Value); protected virtual IBeatmap CreateBeatmapForSkinProvider() => CreateWorkingBeatmap(Ruleset.Value).GetPlayableBeatmap(Ruleset.Value);
private class OutlineBox : CompositeDrawable private class OutlineBox : CompositeDrawable