2019-03-26 15:13:58 +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 NUnit.Framework;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-11-15 13:47:28 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2019-03-26 15:13:58 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
2019-11-15 13:15:09 +08:00
|
|
|
public class TestSceneLeadIn : RateAdjustedBeatmapTestScene
|
2019-03-26 15:13:58 +08:00
|
|
|
{
|
|
|
|
private LeadInPlayer player;
|
|
|
|
|
2019-11-15 13:47:28 +08:00
|
|
|
[Test]
|
|
|
|
public void TestShortLeadIn()
|
2019-03-26 15:13:58 +08:00
|
|
|
{
|
2019-11-15 13:47:28 +08:00
|
|
|
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
2019-03-26 15:13:58 +08:00
|
|
|
{
|
2019-11-15 13:47:28 +08:00
|
|
|
BeatmapInfo = { AudioLeadIn = 1000 }
|
2019-03-26 15:13:58 +08:00
|
|
|
});
|
|
|
|
|
2019-11-15 13:47:28 +08:00
|
|
|
AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
|
2019-03-26 15:13:58 +08:00
|
|
|
|
2019-11-15 13:47:28 +08:00
|
|
|
AddAssert("correct lead-in", () => player.FirstFrameClockTime == 0);
|
2019-03-26 15:13:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestLongLeadIn()
|
|
|
|
{
|
2019-11-15 13:47:28 +08:00
|
|
|
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
|
|
|
{
|
|
|
|
BeatmapInfo = { AudioLeadIn = 10000 }
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000);
|
2019-03-26 15:13:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void loadPlayerWithBeatmap(IBeatmap beatmap)
|
|
|
|
{
|
2019-11-15 13:47:28 +08:00
|
|
|
AddStep("create player", () =>
|
|
|
|
{
|
|
|
|
Beatmap.Value = CreateWorkingBeatmap(beatmap);
|
|
|
|
LoadScreen(player = new LeadInPlayer());
|
|
|
|
});
|
2019-03-26 15:13:58 +08:00
|
|
|
|
2019-11-15 13:47:28 +08:00
|
|
|
AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
|
2019-03-26 15:13:58 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 13:47:28 +08:00
|
|
|
private class LeadInPlayer : TestPlayer
|
2019-03-26 15:13:58 +08:00
|
|
|
{
|
2019-05-31 14:58:46 +08:00
|
|
|
public LeadInPlayer()
|
|
|
|
: base(false, false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-03-26 15:13:58 +08:00
|
|
|
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();
|
2019-05-31 14:58:46 +08:00
|
|
|
|
2019-03-26 15:13:58 +08:00
|
|
|
if (!FirstFrameClockTime.HasValue)
|
|
|
|
{
|
|
|
|
FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
|
|
|
AddInternal(new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
|
|
|
|
+ $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} "
|
|
|
|
+ $"FirstFrameClockTime: {FirstFrameClockTime}"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|