2023-07-10 22:29:59 +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.
|
|
|
|
|
2023-07-11 18:40:27 +08:00
|
|
|
using System.Collections.Generic;
|
2023-07-10 22:29:59 +08:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Game.Beatmaps;
|
2023-07-12 05:21:03 +08:00
|
|
|
using osu.Game.Beatmaps.Timing;
|
2023-07-10 22:29:59 +08:00
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Rulesets.Edit.Checks;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Editing.Checks
|
|
|
|
{
|
2023-07-26 04:18:31 +08:00
|
|
|
public class CheckDrainLengthTest
|
2023-07-10 22:29:59 +08:00
|
|
|
{
|
2023-07-25 15:58:41 +08:00
|
|
|
private CheckDrainLength check = null!;
|
2023-07-10 22:29:59 +08:00
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2023-07-25 15:58:41 +08:00
|
|
|
check = new CheckDrainLength();
|
2023-07-10 22:29:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestDrainTimeShort()
|
|
|
|
{
|
2023-07-12 05:18:49 +08:00
|
|
|
var beatmap = new Beatmap<HitObject>
|
2023-07-10 22:29:59 +08:00
|
|
|
{
|
|
|
|
HitObjects =
|
|
|
|
{
|
2023-07-12 05:22:37 +08:00
|
|
|
new HitCircle { StartTime = 0 },
|
|
|
|
new HitCircle { StartTime = 29_999 }
|
2023-07-10 22:29:59 +08:00
|
|
|
}
|
|
|
|
};
|
2023-07-12 05:18:49 +08:00
|
|
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
|
|
|
|
|
|
|
var issues = check.Run(context).ToList();
|
|
|
|
|
|
|
|
Assert.That(issues, Has.Count.EqualTo(1));
|
2023-07-25 15:58:41 +08:00
|
|
|
Assert.That(issues.Single().Template is CheckDrainLength.IssueTemplateTooShort);
|
2023-07-10 22:29:59 +08:00
|
|
|
}
|
2023-07-11 18:40:27 +08:00
|
|
|
|
2023-07-12 05:18:49 +08:00
|
|
|
[Test]
|
|
|
|
public void TestDrainTimeBreak()
|
2023-07-11 18:40:27 +08:00
|
|
|
{
|
2023-07-12 05:18:49 +08:00
|
|
|
var beatmap = new Beatmap<HitObject>
|
2023-07-11 18:40:27 +08:00
|
|
|
{
|
|
|
|
HitObjects =
|
|
|
|
{
|
|
|
|
new HitCircle { StartTime = 0 },
|
2023-07-12 05:21:03 +08:00
|
|
|
new HitCircle { StartTime = 40_000 }
|
|
|
|
},
|
2024-06-19 13:31:53 +08:00
|
|
|
Breaks =
|
2023-07-12 05:21:03 +08:00
|
|
|
{
|
|
|
|
new BreakPeriod(10_000, 21_000)
|
2023-07-11 18:40:27 +08:00
|
|
|
}
|
|
|
|
};
|
2023-07-12 05:18:49 +08:00
|
|
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
|
|
|
|
|
|
|
var issues = check.Run(context).ToList();
|
|
|
|
|
|
|
|
Assert.That(issues, Has.Count.EqualTo(1));
|
2023-07-25 15:58:41 +08:00
|
|
|
Assert.That(issues.Single().Template is CheckDrainLength.IssueTemplateTooShort);
|
2023-07-11 18:40:27 +08:00
|
|
|
}
|
|
|
|
|
2023-07-12 05:18:49 +08:00
|
|
|
[Test]
|
|
|
|
public void TestDrainTimeCorrect()
|
2023-07-11 18:40:27 +08:00
|
|
|
{
|
|
|
|
var hitObjects = new List<HitObject>();
|
|
|
|
|
|
|
|
for (int i = 0; i <= 30; ++i)
|
|
|
|
hitObjects.Add(new HitCircle { StartTime = 1000 * i });
|
|
|
|
|
2023-07-12 05:18:49 +08:00
|
|
|
var beatmap = new Beatmap<HitObject> { HitObjects = hitObjects };
|
|
|
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
2023-07-11 18:40:27 +08:00
|
|
|
|
2023-07-12 05:18:49 +08:00
|
|
|
var issues = check.Run(context).ToList();
|
2023-07-11 18:40:27 +08:00
|
|
|
|
|
|
|
Assert.That(issues, Is.Empty);
|
|
|
|
}
|
2023-07-10 22:29:59 +08:00
|
|
|
}
|
|
|
|
}
|