2020-10-04 12:50:25 +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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-10-04 12:50:25 +00:00
|
|
|
using System.Collections.Generic;
|
2022-08-15 09:53:10 +00:00
|
|
|
using System.Linq;
|
2020-10-04 12:50:25 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.NonVisual
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class GameplayClockTest
|
|
|
|
{
|
|
|
|
[TestCase(0)]
|
|
|
|
[TestCase(1)]
|
|
|
|
public void TestTrueGameplayRateWithZeroAdjustment(double underlyingClockRate)
|
|
|
|
{
|
|
|
|
var framedClock = new FramedClock(new ManualClock { Rate = underlyingClockRate });
|
|
|
|
var gameplayClock = new TestGameplayClock(framedClock);
|
|
|
|
|
|
|
|
gameplayClock.MutableNonGameplayAdjustments.Add(new BindableDouble());
|
|
|
|
|
|
|
|
Assert.That(gameplayClock.TrueGameplayRate, Is.EqualTo(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
private class TestGameplayClock : GameplayClock
|
|
|
|
{
|
|
|
|
public List<Bindable<double>> MutableNonGameplayAdjustments { get; } = new List<Bindable<double>>();
|
|
|
|
|
2022-08-15 09:53:10 +00:00
|
|
|
public override IEnumerable<double> NonGameplayAdjustments => MutableNonGameplayAdjustments.Select(b => b.Value);
|
2020-10-04 12:50:25 +00:00
|
|
|
|
|
|
|
public TestGameplayClock(IFrameBasedClock underlyingClock)
|
|
|
|
: base(underlyingClock)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|