mirror of https://github.com/ppy/osu
Improve test quality
This commit is contained in:
parent
c7d0b88854
commit
dbfec215e7
|
@ -1,61 +1,55 @@
|
||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestSceneLeadIn : RateAdjustedBeatmapTestScene
|
public class TestSceneLeadIn : RateAdjustedBeatmapTestScene
|
||||||
{
|
{
|
||||||
private Ruleset ruleset;
|
|
||||||
|
|
||||||
private LeadInPlayer player;
|
private LeadInPlayer player;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(RulesetStore rulesets)
|
|
||||||
{
|
|
||||||
Add(new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.Black,
|
|
||||||
Depth = int.MaxValue
|
|
||||||
});
|
|
||||||
|
|
||||||
ruleset = rulesets.AvailableRulesets.First().CreateInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestShortLeadIn()
|
public void TestShortLeadIn()
|
||||||
{
|
{
|
||||||
AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 1000 } }));
|
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
||||||
AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == 0);
|
{
|
||||||
|
BeatmapInfo = { AudioLeadIn = 1000 }
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
|
||||||
|
|
||||||
|
AddAssert("correct lead-in", () => player.FirstFrameClockTime == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLongLeadIn()
|
public void TestLongLeadIn()
|
||||||
{
|
{
|
||||||
AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 10000 } }));
|
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
||||||
AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000);
|
{
|
||||||
|
BeatmapInfo = { AudioLeadIn = 10000 }
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadPlayerWithBeatmap(IBeatmap beatmap)
|
private void loadPlayerWithBeatmap(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
Beatmap.Value = new TestWorkingBeatmap(beatmap);
|
AddStep("create player", () =>
|
||||||
|
{
|
||||||
|
Beatmap.Value = CreateWorkingBeatmap(beatmap);
|
||||||
|
LoadScreen(player = new LeadInPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
LoadScreen(player = new LeadInPlayer());
|
AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LeadInPlayer : Player
|
private class LeadInPlayer : TestPlayer
|
||||||
{
|
{
|
||||||
public LeadInPlayer()
|
public LeadInPlayer()
|
||||||
: base(false, false)
|
: base(false, false)
|
||||||
|
|
Loading…
Reference in New Issue