1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 16:47:24 +08:00
osu-lazer/osu.Game.Tests/Visual/TestCasePause.cs

48 lines
1.7 KiB
C#
Raw Normal View History

2019-03-17 23:46:15 +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;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
{
public class TestCasePause : TestCasePlayer
{
public TestCasePause()
: base(new OsuRuleset())
{
}
protected override Player CreatePlayer(Ruleset ruleset) => new PausePlayer();
protected override void AddCheckSteps(Func<Player> player)
{
PausePlayer pausable() => (PausePlayer)player();
base.AddCheckSteps(player);
//AddUntilStep(() => pausable().ScoreProcessor.TotalScore.Value > 0, "score above zero");
AddStep("pause", () => pausable().PausableGameplayContainer.Pause());
AddAssert("clock stopped", () => !pausable().GameplayClockContainer.GameplayClock.IsRunning);
AddStep("resume", () => pausable().PausableGameplayContainer.Resume());
AddUntilStep(() => pausable().GameplayClockContainer.GameplayClock.IsRunning, "clock started");
AddStep("pause too soon", () => pausable().PausableGameplayContainer.Pause());
AddAssert("clock not stopped", () => pausable().GameplayClockContainer.GameplayClock.IsRunning);
}
private class PausePlayer : Player
{
public new PausableGameplayContainer PausableGameplayContainer => base.PausableGameplayContainer;
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
}
}
}