1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 02:12:56 +08:00
osu-lazer/osu.Game.Tests/Visual/TestCasePause.cs

64 lines
2.3 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;
2019-03-18 10:48:11 +08:00
using osu.Framework.Graphics.Containers;
2019-03-17 23:46:15 +08:00
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())
{
}
2019-03-18 10:48:11 +08:00
protected override bool AllowFail => true;
2019-03-17 23:46:15 +08:00
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");
2019-03-18 10:48:11 +08:00
AddStep("pause", () => pausable().Pause());
2019-03-17 23:46:15 +08:00
AddAssert("clock stopped", () => !pausable().GameplayClockContainer.GameplayClock.IsRunning);
2019-03-18 10:48:11 +08:00
AddAssert("pause overlay shown", () => pausable().PauseOverlayVisible);
2019-03-17 23:46:15 +08:00
2019-03-18 10:48:11 +08:00
AddStep("resume", () => pausable().Resume());
AddAssert("pause overlay hidden", () => !pausable().PauseOverlayVisible);
2019-03-17 23:46:15 +08:00
2019-03-18 10:48:11 +08:00
AddStep("pause too soon", () => pausable().Pause());
2019-03-17 23:46:15 +08:00
AddAssert("clock not stopped", () => pausable().GameplayClockContainer.GameplayClock.IsRunning);
2019-03-18 10:48:11 +08:00
AddAssert("pause overlay hidden", () => !pausable().PauseOverlayVisible);
AddUntilStep(() => pausable().HasFailed, "wait for fail");
AddAssert("fail overlay shown", () => pausable().FailOverlayVisible);
AddStep("try to pause", () => pausable().Pause());
AddAssert("pause overlay hidden", () => !pausable().PauseOverlayVisible);
AddAssert("fail overlay still shown", () => pausable().FailOverlayVisible);
2019-03-17 23:46:15 +08:00
}
private class PausePlayer : Player
{
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
2019-03-18 10:48:11 +08:00
public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible;
public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible;
2019-03-17 23:46:15 +08:00
}
}
}