osu/osu.Game.Tests/Gameplay/TestSceneMasterGameplayClockContainer.cs

59 lines
1.8 KiB
C#
Raw Normal View History

2020-06-14 02:34:07 +00: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;
2020-06-19 13:43:25 +00:00
using osu.Framework.Testing;
2020-06-14 02:34:07 +00:00
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Gameplay
{
2020-06-19 13:43:25 +00:00
[HeadlessTest]
2021-04-16 11:51:42 +00:00
public class TestSceneMasterGameplayClockContainer : OsuTestScene
2020-06-14 02:34:07 +00:00
{
[Test]
public void TestStartThenElapsedTime()
{
GameplayClockContainer gcc = null;
2020-08-06 09:31:08 +00:00
AddStep("create container", () =>
{
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
2020-08-17 06:38:16 +00:00
working.LoadTrack();
2021-04-14 08:47:11 +00:00
Add(gcc = new MasterGameplayClockContainer(working, 0));
2020-08-06 09:31:08 +00:00
});
2021-04-20 04:56:13 +00:00
AddStep("start clock", () => gcc.Start());
2020-06-14 02:34:07 +00:00
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
}
2021-04-20 04:56:13 +00:00
[Test]
public void TestElapseThenReset()
{
GameplayClockContainer gcc = null;
AddStep("create container", () =>
{
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
working.LoadTrack();
Add(gcc = new MasterGameplayClockContainer(working, 0));
});
AddStep("start clock", () => gcc.Start());
AddUntilStep("current time greater 2000", () => gcc.GameplayClock.CurrentTime > 2000);
double timeAtReset = 0;
AddStep("reset clock", () =>
{
timeAtReset = gcc.GameplayClock.CurrentTime;
gcc.Reset();
});
AddAssert("current time < time at reset", () => gcc.GameplayClock.CurrentTime < timeAtReset);
}
2020-06-14 02:34:07 +00:00
}
}