2019-03-18 15:39:34 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-01-31 12:54:26 +08:00
|
|
|
using NUnit.Framework;
|
2019-03-18 15:39:34 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-04-12 13:53:23 +08:00
|
|
|
using osu.Game.Configuration;
|
2019-03-18 15:39:34 +08:00
|
|
|
using osu.Game.Rulesets;
|
2020-01-31 12:54:26 +08:00
|
|
|
using osu.Game.Rulesets.Catch;
|
|
|
|
using osu.Game.Rulesets.Mania;
|
2019-03-18 15:39:34 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-01-31 12:54:26 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Taiko;
|
2019-03-18 15:39:34 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
2020-01-31 12:54:26 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A base class which runs <see cref="Player"/> test for all available rulesets.
|
|
|
|
/// Steps to be run for each ruleset should be added via <see cref="AddCheckSteps"/>.
|
|
|
|
/// </summary>
|
2022-11-24 13:32:20 +08:00
|
|
|
public abstract partial class TestSceneAllRulesetPlayers : RateAdjustedBeatmapTestScene
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
2021-10-18 13:20:38 +08:00
|
|
|
protected Player Player { get; private set; }
|
|
|
|
|
|
|
|
protected OsuConfigManager Config { get; private set; }
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 08:06:39 +08:00
|
|
|
private void load()
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
2021-10-18 13:20:38 +08:00
|
|
|
Dependencies.Cache(Config = new OsuConfigManager(LocalStorage));
|
|
|
|
Config.GetBindable<double>(OsuSetting.DimLevel).Value = 1.0;
|
2020-01-31 12:54:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestOsu() => runForRuleset(new OsuRuleset().RulesetInfo);
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestTaiko() => runForRuleset(new TaikoRuleset().RulesetInfo);
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCatch() => runForRuleset(new CatchRuleset().RulesetInfo);
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestMania() => runForRuleset(new ManiaRuleset().RulesetInfo);
|
|
|
|
|
|
|
|
private void runForRuleset(RulesetInfo ruleset)
|
|
|
|
{
|
|
|
|
Player p = null;
|
|
|
|
AddStep($"load {ruleset.Name} player", () => p = loadPlayerFor(ruleset));
|
|
|
|
AddUntilStep("player loaded", () =>
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
2020-01-31 12:54:26 +08:00
|
|
|
if (p?.IsLoaded == true)
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
2020-01-31 12:54:26 +08:00
|
|
|
p = null;
|
|
|
|
return true;
|
|
|
|
}
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2020-01-31 12:54:26 +08:00
|
|
|
return false;
|
|
|
|
});
|
2019-04-12 13:53:23 +08:00
|
|
|
|
2020-01-31 12:54:26 +08:00
|
|
|
AddCheckSteps();
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract void AddCheckSteps();
|
|
|
|
|
2019-05-31 13:40:53 +08:00
|
|
|
private Player loadPlayerFor(RulesetInfo rulesetInfo)
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
2019-05-31 13:40:53 +08:00
|
|
|
Ruleset.Value = rulesetInfo;
|
|
|
|
var ruleset = rulesetInfo.CreateInstance();
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-05-31 13:40:53 +08:00
|
|
|
var working = CreateWorkingBeatmap(rulesetInfo);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
|
|
Beatmap.Value = working;
|
2021-09-10 11:00:41 +08:00
|
|
|
SelectedMods.Value = new[] { ruleset.CreateMod<ModNoFail>() };
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-05-31 13:40:53 +08:00
|
|
|
Player = CreatePlayer(ruleset);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-03-22 13:10:38 +08:00
|
|
|
LoadScreen(Player);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-03-22 13:10:38 +08:00
|
|
|
return Player;
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
|
2019-05-10 14:39:25 +08:00
|
|
|
protected virtual Player CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false);
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
}
|