2019-03-18 18:44:14 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-03-18 15:39:34 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
2019-03-26 12:16:46 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-18 18:44:14 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2019-03-18 15:39:34 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2019-04-12 13:53:23 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2019-03-18 15:39:34 +08:00
|
|
|
|
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-26 12:16:46 +08:00
|
|
|
|
}
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
2019-03-26 12:16:46 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2019-04-12 13:53:23 +08:00
|
|
|
|
OsuConfigManager manager;
|
|
|
|
|
Dependencies.Cache(manager = new OsuConfigManager(LocalStorage));
|
|
|
|
|
manager.GetBindable<double>(OsuSetting.DimLevel).Value = 1.0;
|
2019-03-18 18:44:14 +08:00
|
|
|
|
}
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
2019-03-18 18:44:14 +08:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
|
|
|
|
{
|
2019-03-18 15:39:34 +08:00
|
|
|
|
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
|
|
|
|
|
AddUntilStep(() => Player.IsLoaded, "player loaded");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
|
|
|
|
|
|
2019-03-18 18:43:55 +08:00
|
|
|
|
protected virtual bool AllowFail => false;
|
|
|
|
|
|
2019-03-18 15:39:34 +08:00
|
|
|
|
private void loadPlayer()
|
|
|
|
|
{
|
|
|
|
|
var beatmap = CreateBeatmap(ruleset);
|
|
|
|
|
|
|
|
|
|
Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock);
|
2019-03-18 18:43:55 +08:00
|
|
|
|
|
|
|
|
|
if (!AllowFail)
|
|
|
|
|
Beatmap.Value.Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
2019-03-22 13:10:38 +08:00
|
|
|
|
Player = CreatePlayer(ruleset);
|
|
|
|
|
LoadScreen(Player);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 15:53:44 +08:00
|
|
|
|
protected virtual Player CreatePlayer(Ruleset ruleset) => new Player(false, false);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|