mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 00:53:10 +08:00
Test stopping behavior
This commit is contained in:
parent
7e4f58c2d3
commit
a38c912c6d
51
osu.Game.Tests/Visual/Editor/TestSceneEditorClock.cs
Normal file
51
osu.Game.Tests/Visual/Editor/TestSceneEditorClock.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Screens.Edit.Components;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
|
{
|
||||||
|
[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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[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", () => Clock.IsRunning && Clock.CurrentTime < Clock.TrackLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -113,7 +113,6 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
private class StartStopButton : OsuButton
|
private class StartStopButton : OsuButton
|
||||||
{
|
{
|
||||||
private IAdjustableClock adjustableClock;
|
private IAdjustableClock adjustableClock;
|
||||||
private bool started;
|
|
||||||
|
|
||||||
public StartStopButton()
|
public StartStopButton()
|
||||||
{
|
{
|
||||||
@ -132,18 +131,17 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
|
|
||||||
private void onClick()
|
private void onClick()
|
||||||
{
|
{
|
||||||
if (started)
|
if (adjustableClock.IsRunning)
|
||||||
{
|
|
||||||
adjustableClock.Stop();
|
adjustableClock.Stop();
|
||||||
Text = "Start";
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
adjustableClock.Start();
|
adjustableClock.Start();
|
||||||
Text = "Stop";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
started = !started;
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Text = adjustableClock.IsRunning ? "Stop" : "Start";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user