mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 00:43:22 +08:00
Make autoplay tests test via the ReplayPlayer
code path
This commit is contained in:
parent
911256603b
commit
45984f035b
@ -18,12 +18,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Description("Player instantiated with an autoplay mod.")]
|
||||
public class TestSceneAutoplay : TestSceneAllRulesetPlayers
|
||||
{
|
||||
protected new TestPlayer Player => (TestPlayer)base.Player;
|
||||
protected new TestReplayPlayer Player => (TestReplayPlayer)base.Player;
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
SelectedMods.Value = new[] { ruleset.GetAutoplayMod() };
|
||||
return new TestPlayer(false);
|
||||
return new TestReplayPlayer(false);
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
|
75
osu.Game/Tests/Visual/TestReplayPlayer.cs
Normal file
75
osu.Game/Tests/Visual/TestReplayPlayer.cs
Normal file
@ -0,0 +1,75 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
/// <summary>
|
||||
/// A player that exposes many components that would otherwise not be available, for testing purposes.
|
||||
/// </summary>
|
||||
public class TestReplayPlayer : ReplayPlayer
|
||||
{
|
||||
protected override bool PauseOnFocusLost { get; }
|
||||
|
||||
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
|
||||
|
||||
/// <summary>
|
||||
/// Mods from *player* (not OsuScreen).
|
||||
/// </summary>
|
||||
public new Bindable<IReadOnlyList<Mod>> Mods => base.Mods;
|
||||
|
||||
public new HUDOverlay HUDOverlay => base.HUDOverlay;
|
||||
|
||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
||||
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
|
||||
public new HealthProcessor HealthProcessor => base.HealthProcessor;
|
||||
|
||||
public new bool PauseCooldownActive => base.PauseCooldownActive;
|
||||
|
||||
public readonly List<JudgementResult> Results = new List<JudgementResult>();
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a replay player that renders an autoplay mod.
|
||||
/// </summary>
|
||||
public TestReplayPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
||||
: base((beatmap, mods) => mods.OfType<ModAutoplay>().First().CreateReplayScore(beatmap, mods), new PlayerConfiguration
|
||||
{
|
||||
AllowPause = allowPause,
|
||||
ShowResults = showResults
|
||||
})
|
||||
{
|
||||
PauseOnFocusLost = pauseOnFocusLost;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a replay player that renders the provided replay.
|
||||
/// </summary>
|
||||
public TestReplayPlayer(Score score, bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
||||
: base(score, new PlayerConfiguration
|
||||
{
|
||||
AllowPause = allowPause,
|
||||
ShowResults = showResults
|
||||
})
|
||||
{
|
||||
PauseOnFocusLost = pauseOnFocusLost;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ScoreProcessor.NewJudgement += r => Results.Add(r);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user