mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 03:57:25 +08:00
85 lines
2.7 KiB
C#
85 lines
2.7 KiB
C#
// 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 NUnit.Framework;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Graphics.Sprites;
|
|
using osu.Game.Rulesets.Osu;
|
|
using osu.Game.Screens.Play;
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
{
|
|
public class TestSceneLeadIn : RateAdjustedBeatmapTestScene
|
|
{
|
|
private LeadInPlayer player;
|
|
|
|
[Test]
|
|
public void TestShortLeadIn()
|
|
{
|
|
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
|
{
|
|
BeatmapInfo = { AudioLeadIn = 1000 }
|
|
});
|
|
|
|
AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
|
|
|
|
AddAssert("correct lead-in", () => player.FirstFrameClockTime == 0);
|
|
}
|
|
|
|
[Test]
|
|
public void TestLongLeadIn()
|
|
{
|
|
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
|
{
|
|
BeatmapInfo = { AudioLeadIn = 10000 }
|
|
});
|
|
|
|
AddAssert("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000);
|
|
}
|
|
|
|
private void loadPlayerWithBeatmap(IBeatmap beatmap)
|
|
{
|
|
AddStep("create player", () =>
|
|
{
|
|
Beatmap.Value = CreateWorkingBeatmap(beatmap);
|
|
LoadScreen(player = new LeadInPlayer());
|
|
});
|
|
|
|
AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
|
|
}
|
|
|
|
private class LeadInPlayer : TestPlayer
|
|
{
|
|
public LeadInPlayer()
|
|
: base(false, false)
|
|
{
|
|
}
|
|
|
|
public double? FirstFrameClockTime;
|
|
|
|
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
|
|
|
public double GameplayStartTime => DrawableRuleset.GameplayStartTime;
|
|
|
|
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
|
|
|
protected override void UpdateAfterChildren()
|
|
{
|
|
base.UpdateAfterChildren();
|
|
|
|
if (!FirstFrameClockTime.HasValue)
|
|
{
|
|
FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
|
AddInternal(new OsuSpriteText
|
|
{
|
|
Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
|
|
+ $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} "
|
|
+ $"FirstFrameClockTime: {FirstFrameClockTime}"
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|