2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-07-29 14:24:14 +08:00
|
|
|
|
public class TestSceneSpinner : OsuSkinnableTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private int depthIndex;
|
|
|
|
|
|
2020-08-05 17:44:34 +08:00
|
|
|
|
private TestDrawableSpinner drawableSpinner;
|
|
|
|
|
|
|
|
|
|
[TestCase(false)]
|
|
|
|
|
[TestCase(true)]
|
|
|
|
|
public void TestVariousSpinners(bool autoplay)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-08-06 11:33:40 +08:00
|
|
|
|
string term = autoplay ? "Hit" : "Miss";
|
|
|
|
|
AddStep($"{term} Big", () => SetContents(() => testSingle(2, autoplay)));
|
|
|
|
|
AddStep($"{term} Medium", () => SetContents(() => testSingle(5, autoplay)));
|
|
|
|
|
AddStep($"{term} Small", () => SetContents(() => testSingle(7, autoplay)));
|
2020-08-05 17:44:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase(false)]
|
|
|
|
|
[TestCase(true)]
|
|
|
|
|
public void TestLongSpinner(bool autoplay)
|
|
|
|
|
{
|
|
|
|
|
AddStep("Very short spinner", () => SetContents(() => testSingle(5, autoplay, 2000)));
|
|
|
|
|
AddUntilStep("Wait for completion", () => drawableSpinner.Result.HasResult);
|
|
|
|
|
AddUntilStep("Check correct progress", () => drawableSpinner.Progress == (autoplay ? 1 : 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase(false)]
|
|
|
|
|
[TestCase(true)]
|
|
|
|
|
public void TestSuperShortSpinner(bool autoplay)
|
|
|
|
|
{
|
|
|
|
|
AddStep("Very short spinner", () => SetContents(() => testSingle(5, autoplay, 200)));
|
|
|
|
|
AddUntilStep("Wait for completion", () => drawableSpinner.Result.HasResult);
|
|
|
|
|
AddUntilStep("Short spinner implicitly completes", () => drawableSpinner.Progress == 1);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 17:44:34 +08:00
|
|
|
|
private Drawable testSingle(float circleSize, bool auto = false, double length = 3000)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-08-06 11:34:42 +08:00
|
|
|
|
const double delay = 2000;
|
|
|
|
|
|
|
|
|
|
var spinner = new Spinner
|
|
|
|
|
{
|
|
|
|
|
StartTime = Time.Current + delay,
|
|
|
|
|
EndTime = Time.Current + delay + length
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
|
|
|
|
|
|
2020-08-05 17:44:34 +08:00
|
|
|
|
drawableSpinner = new TestDrawableSpinner(spinner, auto)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Depth = depthIndex++
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-13 20:45:38 +08:00
|
|
|
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
2020-08-05 17:44:34 +08:00
|
|
|
|
mod.ApplyToDrawableHitObjects(new[] { drawableSpinner });
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-08-05 17:44:34 +08:00
|
|
|
|
return drawableSpinner;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestDrawableSpinner : DrawableSpinner
|
|
|
|
|
{
|
2020-07-29 14:24:14 +08:00
|
|
|
|
private readonly bool auto;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-28 12:31:40 +08:00
|
|
|
|
public TestDrawableSpinner(Spinner s, bool auto)
|
|
|
|
|
: base(s)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
this.auto = auto;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-29 14:24:14 +08:00
|
|
|
|
protected override void Update()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-07-29 14:24:14 +08:00
|
|
|
|
base.Update();
|
|
|
|
|
if (auto)
|
2020-07-29 19:01:01 +08:00
|
|
|
|
RotationTracker.AddRotation((float)(Clock.ElapsedFrameTime * 3));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|