1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Remove PlayerTestScene constructor and use CreateRuleset method instead

This commit is contained in:
Salman Ahmed 2020-04-17 10:32:12 +03:00
parent 5fa6bcb5a3
commit 92df4e3a9e
20 changed files with 89 additions and 116 deletions

View File

@ -12,13 +12,8 @@ using osuTK;
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)
{
var beatmap = new Beatmap

View File

@ -8,12 +8,11 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class TestSceneBananaShower : PlayerTestScene
public class TestSceneBananaShower : TestSceneCatchPlayer
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
@ -26,11 +25,6 @@ namespace osu.Game.Rulesets.Catch.Tests
typeof(DrawableCatchRuleset),
};
public TestSceneBananaShower()
: base(new CatchRuleset())
{
}
[Test]
public void TestBananaShower()
{

View File

@ -1,6 +1,8 @@
// 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 System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Game.Tests.Visual;
@ -9,9 +11,11 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestFixture]
public class TestSceneCatchPlayer : PlayerTestScene
{
public TestSceneCatchPlayer()
: base(new CatchRuleset())
public override IReadOnlyList<Type> RequiredTypes => new[]
{
}
typeof(CatchRuleset),
};
protected override Ruleset CreateRuleset() => new CatchRuleset();
}
}

View File

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

View File

@ -10,24 +10,18 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class TestSceneHyperDash : PlayerTestScene
public class TestSceneHyperDash : TestSceneCatchPlayer
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(CatcherArea),
};
public TestSceneHyperDash()
: base(new CatchRuleset())
{
}
protected override bool Autoplay => true;
[Test]

View File

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

View File

@ -0,0 +1,19 @@
// 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 System;
using System.Collections.Generic;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Mania.Tests
{
public class TestSceneManiaPlayer : PlayerTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ManiaRuleset),
};
protected override Ruleset CreateRuleset() => new ManiaRuleset();
}
}

View File

@ -1,15 +0,0 @@
// 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.Mania.Tests
{
public class TestScenePlayer : PlayerTestScene
{
public TestScenePlayer()
: base(new ManiaRuleset())
{
}
}
}

View File

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

View File

@ -1,6 +1,8 @@
// 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 System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Game.Tests.Visual;
@ -9,9 +11,11 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestFixture]
public class TestSceneOsuPlayer : PlayerTestScene
{
public TestSceneOsuPlayer()
: base(new OsuRuleset())
public override IReadOnlyList<Type> RequiredTypes => new[]
{
}
typeof(OsuRuleset),
};
protected override Ruleset CreateRuleset() => new OsuRuleset();
}
}

View File

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

View File

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

View File

@ -0,0 +1,19 @@
// 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 System;
using System.Collections.Generic;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneTaikoPlayer : PlayerTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(TaikoRuleset)
};
protected override Ruleset CreateRuleset() => new TaikoRuleset();
}
}

View File

@ -11,13 +11,8 @@ using osu.Game.Tests.Visual;
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 TestPlayer CreatePlayer(Ruleset ruleset)

View File

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

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 TestPlayerTestScene : PlayerTestScene
{
protected override Ruleset CreateRuleset() => new OsuRuleset();
}
}

View File

@ -10,23 +10,17 @@ using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Storyboards;
using osuTK;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneGameplayRewinding : PlayerTestScene
public class TestSceneGameplayRewinding : TestPlayerTestScene
{
[Resolved]
private AudioManager audioManager { get; set; }
public TestSceneGameplayRewinding()
: base(new OsuRuleset())
{
}
private Track track;
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.Cursor;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestScenePause : PlayerTestScene
public class TestScenePause : TestPlayerTestScene
{
protected new PausePlayer Player => (PausePlayer)base.Player;
@ -26,7 +25,6 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override Container<Drawable> Content => content;
public TestScenePause()
: base(new OsuRuleset())
{
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.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.Gameplay
{
[HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
public class TestScenePauseWhenInactive : PlayerTestScene
public class TestScenePauseWhenInactive : TestPlayerTestScene
{
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
@ -27,11 +26,6 @@ namespace osu.Game.Tests.Visual.Gameplay
[Resolved]
private GameHost host { get; set; }
public TestScenePauseWhenInactive()
: base(new OsuRuleset())
{
}
[Test]
public void TestDoesntPauseDuringIntro()
{

View File

@ -19,15 +19,8 @@ namespace osu.Game.Tests.Visual
/// </summary>
protected virtual bool HasCustomSteps { get; } = false;
private readonly Ruleset ruleset;
protected TestPlayer Player;
protected PlayerTestScene(Ruleset ruleset)
{
this.ruleset = ruleset;
}
protected OsuConfigManager LocalConfig;
[BackgroundDependencyLoader]
@ -53,7 +46,7 @@ namespace osu.Game.Tests.Visual
action?.Invoke();
AddStep(ruleset.RulesetInfo.Name, LoadPlayer);
AddStep(CreateRuleset().RulesetInfo.Name, LoadPlayer);
AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1);
}
@ -63,28 +56,28 @@ namespace osu.Game.Tests.Visual
protected void LoadPlayer()
{
var beatmap = CreateBeatmap(ruleset.RulesetInfo);
var beatmap = CreateBeatmap(Ruleset.Value);
Beatmap.Value = CreateWorkingBeatmap(beatmap);
Ruleset.Value = ruleset.RulesetInfo;
SelectedMods.Value = Array.Empty<Mod>();
var rulesetInstance = Ruleset.Value.CreateInstance();
if (!AllowFail)
{
var noFailMod = ruleset.GetAllMods().FirstOrDefault(m => m is ModNoFail);
var noFailMod = rulesetInstance.GetAllMods().FirstOrDefault(m => m is ModNoFail);
if (noFailMod != null)
SelectedMods.Value = new[] { noFailMod };
}
if (Autoplay)
{
var mod = ruleset.GetAutoplayMod();
var mod = rulesetInstance.GetAutoplayMod();
if (mod != null)
SelectedMods.Value = SelectedMods.Value.Concat(mod.Yield()).ToArray();
}
Player = CreatePlayer(ruleset);
Player = CreatePlayer(rulesetInstance);
LoadScreen(Player);
}