1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00
osu-lazer/osu.Game/Tests/Visual/PlayerTestCase.cs

52 lines
1.5 KiB
C#
Raw Normal View History

2019-03-18 18:44:14 +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.
using System.Linq;
2019-03-18 18:44:14 +08:00
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Visual
{
public abstract class PlayerTestCase : RateAdjustedBeatmapTestCase
{
private readonly Ruleset ruleset;
protected Player Player;
protected PlayerTestCase(Ruleset ruleset)
{
this.ruleset = ruleset;
}
2019-03-18 18:44:14 +08:00
[SetUpSteps]
public void SetUpSteps()
{
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
2019-04-23 10:52:42 +08:00
AddUntilStep(() => Player.IsLoaded && Player.Alpha == 1, "player loaded");
}
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
protected virtual bool AllowFail => false;
private void loadPlayer()
{
var beatmap = CreateBeatmap(ruleset);
Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock);
if (!AllowFail)
2019-04-10 11:03:57 +08:00
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
Player = CreatePlayer(ruleset);
LoadScreen(Player);
}
protected virtual Player CreatePlayer(Ruleset ruleset) => new Player(false, false);
}
}