2019-08-01 08:31:08 +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 System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Beatmaps
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class SliderEventGenerationTest
|
|
|
|
|
{
|
|
|
|
|
private const double start_time = 0;
|
|
|
|
|
private const double span_duration = 1000;
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestSingleSpan()
|
|
|
|
|
{
|
2023-09-29 05:19:26 +00:00
|
|
|
|
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 1).ToArray();
|
2019-08-01 08:31:08 +00:00
|
|
|
|
|
|
|
|
|
Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head));
|
|
|
|
|
Assert.That(events[0].Time, Is.EqualTo(start_time));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[1].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[1].Time, Is.EqualTo(span_duration / 2));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[3].Type, Is.EqualTo(SliderEventType.Tail));
|
|
|
|
|
Assert.That(events[3].Time, Is.EqualTo(span_duration));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestRepeat()
|
|
|
|
|
{
|
2023-09-29 05:19:26 +00:00
|
|
|
|
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 2).ToArray();
|
2019-08-01 08:31:08 +00:00
|
|
|
|
|
|
|
|
|
Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head));
|
|
|
|
|
Assert.That(events[0].Time, Is.EqualTo(start_time));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[1].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[1].Time, Is.EqualTo(span_duration / 2));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[2].Type, Is.EqualTo(SliderEventType.Repeat));
|
|
|
|
|
Assert.That(events[2].Time, Is.EqualTo(span_duration));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[3].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[3].Time, Is.EqualTo(span_duration + span_duration / 2));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[5].Type, Is.EqualTo(SliderEventType.Tail));
|
|
|
|
|
Assert.That(events[5].Time, Is.EqualTo(2 * span_duration));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestNonEvenTicks()
|
|
|
|
|
{
|
2023-09-29 05:19:26 +00:00
|
|
|
|
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, 300, span_duration, 2).ToArray();
|
2019-08-01 08:31:08 +00:00
|
|
|
|
|
|
|
|
|
Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head));
|
|
|
|
|
Assert.That(events[0].Time, Is.EqualTo(start_time));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[1].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[1].Time, Is.EqualTo(300));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[2].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[2].Time, Is.EqualTo(600));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[3].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[3].Time, Is.EqualTo(900));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[4].Type, Is.EqualTo(SliderEventType.Repeat));
|
|
|
|
|
Assert.That(events[4].Time, Is.EqualTo(span_duration));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[5].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[5].Time, Is.EqualTo(1100));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[6].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[6].Time, Is.EqualTo(1400));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[7].Type, Is.EqualTo(SliderEventType.Tick));
|
|
|
|
|
Assert.That(events[7].Time, Is.EqualTo(1700));
|
|
|
|
|
|
|
|
|
|
Assert.That(events[9].Type, Is.EqualTo(SliderEventType.Tail));
|
|
|
|
|
Assert.That(events[9].Time, Is.EqualTo(2 * span_duration));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2023-09-29 05:19:26 +00:00
|
|
|
|
public void TestLastTickOffset()
|
2019-08-01 08:31:08 +00:00
|
|
|
|
{
|
2023-09-29 05:19:26 +00:00
|
|
|
|
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 1).ToArray();
|
2019-08-01 08:31:08 +00:00
|
|
|
|
|
2023-09-29 07:44:04 +00:00
|
|
|
|
Assert.That(events[2].Type, Is.EqualTo(SliderEventType.LegacyLastTick));
|
|
|
|
|
Assert.That(events[2].Time, Is.EqualTo(span_duration + SliderEventGenerator.TAIL_LENIENCY));
|
2019-08-01 08:31:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestMinimumTickDistance()
|
|
|
|
|
{
|
|
|
|
|
const double velocity = 5;
|
|
|
|
|
const double min_distance = velocity * 10;
|
|
|
|
|
|
2023-09-29 05:19:26 +00:00
|
|
|
|
var events = SliderEventGenerator.Generate(start_time, span_duration, velocity, velocity, span_duration, 2).ToArray();
|
2019-08-01 08:31:08 +00:00
|
|
|
|
|
|
|
|
|
Assert.Multiple(() =>
|
|
|
|
|
{
|
|
|
|
|
int tickIndex = -1;
|
|
|
|
|
|
|
|
|
|
while (++tickIndex < events.Length)
|
|
|
|
|
{
|
|
|
|
|
if (events[tickIndex].Type != SliderEventType.Tick)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
Assert.That(events[tickIndex].Time, Is.LessThan(span_duration - min_distance).Or.GreaterThan(span_duration + min_distance));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|