1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 15:32:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Gameplay/TestSceneOverlayActivation.cs

71 lines
3.4 KiB
C#
Raw Normal View History

2020-08-03 22:00:10 +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;
2020-08-03 22:00:10 +08:00
using NUnit.Framework;
using osu.Game.Overlays;
using osu.Game.Rulesets;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneOverlayActivation : OsuPlayerTestScene
{
protected new OverlayTestPlayer Player => base.Player as OverlayTestPlayer;
2020-08-03 22:00:10 +08:00
public override void SetUpSteps()
{
base.SetUpSteps();
AddUntilStep("gameplay has started",
() => Player.GameplayClockContainer.GameplayClock.CurrentTime > Player.DrawableRuleset.GameplayStartTime);
}
2020-08-03 22:00:10 +08:00
[Test]
2020-08-07 16:17:11 +08:00
public void TestGameplayOverlayActivation()
2020-08-03 22:00:10 +08:00
{
2020-10-07 15:22:39 +08:00
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
2020-08-03 22:00:10 +08:00
}
[Test]
public void TestGameplayOverlayActivationPaused()
{
2020-10-07 15:22:39 +08:00
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
AddStep("pause gameplay", () => Player.Pause());
2020-10-07 15:22:39 +08:00
AddAssert("local user not playing", () => !Player.LocalUserPlaying.Value);
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
2020-08-03 22:00:10 +08:00
}
[Test]
public void TestGameplayOverlayActivationReplayLoaded()
{
2020-10-07 15:22:39 +08:00
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
AddStep("load a replay", () => Player.DrawableRuleset.HasReplayLoaded.Value = true);
2020-10-07 15:22:39 +08:00
AddAssert("local user not playing", () => !Player.LocalUserPlaying.Value);
AddAssert("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
2020-08-03 22:00:10 +08:00
}
[Test]
public void TestGameplayOverlayActivationBreaks()
{
2020-10-07 15:22:39 +08:00
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
AddStep("seek to break", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().StartTime));
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
AddAssert("local user not playing", () => !Player.LocalUserPlaying.Value);
AddStep("seek to break end", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().EndTime));
AddUntilStep("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
}
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new OverlayTestPlayer();
2020-08-03 22:00:10 +08:00
protected class OverlayTestPlayer : TestPlayer
2020-08-03 22:00:10 +08:00
{
public new OverlayActivation OverlayActivationMode => base.OverlayActivationMode.Value;
}
}
}