1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 01:07:25 +08:00
osu-lazer/osu.Game.Tests/Visual/Editing/TestSceneEditorClock.cs
Bartłomiej Dach 3b55eeb416 Fix test failure by setting beatmap
Post-merge, it was failing because somewhere along the way
`EditorClockTestScene` started expecting inheritors to set the beatmap
themselves explicitly in BDL.
2021-03-17 18:39:48 +01:00

60 lines
2.0 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.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit.Components;
using osuTK;
namespace osu.Game.Tests.Visual.Editing
{
[TestFixture]
public class TestSceneEditorClock : EditorClockTestScene
{
public TestSceneEditorClock()
{
Add(new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new TimeInfoContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200, 100)
},
new PlaybackControl
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200, 100)
}
}
});
}
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
}
[Test]
public void TestStopAtTrackEnd()
{
AddStep("Reset clock", () => Clock.Seek(0));
AddStep("Start clock", Clock.Start);
AddAssert("Clock running", () => Clock.IsRunning);
AddStep("Seek near end", () => Clock.Seek(Clock.TrackLength - 250));
AddUntilStep("Clock stops", () => !Clock.IsRunning);
AddAssert("Clock stopped at end", () => Clock.CurrentTime == Clock.TrackLength);
AddStep("Start clock again", Clock.Start);
AddAssert("Clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
}
}
}