1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Add extra test coverage to TestSceneOsuModAutoplay to cover fail case

Basically the slider needs to be slightly longer for this test to
correctly fail in headless tests, in conjunction with the new slider
tail leniency.

This is due to headless tests running at a fixed frame interval, and
these timings being *tight*.
This commit is contained in:
Dean Herbert 2023-10-03 18:35:01 +09:00
parent 9a3c21c320
commit 941f26d462
2 changed files with 16 additions and 8 deletions

View File

@ -51,8 +51,9 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
FinalRate = { Value = 1.3 } FinalRate = { Value = 1.3 }
}); });
[Test] [TestCase(6.25f)]
public void TestPerfectScoreOnShortSliderWithRepeat() [TestCase(20)]
public void TestPerfectScoreOnShortSliderWithRepeat(float pathLength)
{ {
AddStep("set score to standardised", () => LocalConfig.SetValue(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised)); AddStep("set score to standardised", () => LocalConfig.SetValue(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised));
@ -70,7 +71,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Path = new SliderPath(new[] Path = new SliderPath(new[]
{ {
new PathControlPoint(), new PathControlPoint(),
new PathControlPoint(new Vector2(0, 6.25f)) new PathControlPoint(new Vector2(0, pathLength))
}), }),
RepeatCount = 1, RepeatCount = 1,
SliderVelocityMultiplier = 10 SliderVelocityMultiplier = 10

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@ -42,9 +41,17 @@ namespace osu.Game.Rulesets.Osu.Tests
// Making these too short causes breakage from frames not being processed fast enough. // Making these too short causes breakage from frames not being processed fast enough.
// To keep things simple, these tests are crafted to always be >16ms length. // To keep things simple, these tests are crafted to always be >16ms length.
// If sliders shorter than this are ever used in gameplay it will probably break things and we can revisit. // If sliders shorter than this are ever used in gameplay it will probably break things and we can revisit.
[TestCase(80, 0)] [TestCase(30, 0)]
[TestCase(30, 1)]
[TestCase(40, 0)]
[TestCase(40, 1)]
[TestCase(50, 1)]
[TestCase(60, 1)]
[TestCase(70, 1)]
[TestCase(80, 1)] [TestCase(80, 1)]
[TestCase(80, 0)]
[TestCase(80, 10)] [TestCase(80, 10)]
[TestCase(90, 1)]
public void TestVeryShortSlider(float sliderLength, int repeatCount) public void TestVeryShortSlider(float sliderLength, int repeatCount)
{ {
Slider slider; Slider slider;
@ -66,15 +73,15 @@ namespace osu.Game.Rulesets.Osu.Tests
}), }),
}, 240, 1); }, 240, 1);
AddAssert("Slider is longer than one frame", () => slider.Duration / (slider.RepeatCount + 1), () => Is.GreaterThan(1000 / 60f));
AddAssert("Slider is shorter than lenience", () => slider.Duration / (slider.RepeatCount + 1), () => Is.LessThan(Math.Abs(SliderEventGenerator.TAIL_LENIENCY)));
assertAllMaxJudgements(); assertAllMaxJudgements();
// Even if the last tick is hit early, the slider should always execute its final judgement at its endtime. // Even if the last tick is hit early, the slider should always execute its final judgement at its endtime.
// If not, hitsounds will not play on time. // If not, hitsounds will not play on time.
AddAssert("Judgement offset is zero", () => judgementResults.Last().TimeOffset == 0); AddAssert("Judgement offset is zero", () => judgementResults.Last().TimeOffset == 0);
AddAssert("Slider judged at end time", () => judgementResults.Last().TimeAbsolute, () => Is.EqualTo(slider.EndTime)); AddAssert("Slider judged at end time", () => judgementResults.Last().TimeAbsolute, () => Is.EqualTo(slider.EndTime));
AddAssert("Slider is last judgement", () => judgementResults[^1].HitObject, Is.TypeOf<Slider>);
AddAssert("Tail is second last judgement", () => judgementResults[^2].HitObject, Is.TypeOf<SliderTailCircle>);
} }
[TestCase(300, false)] [TestCase(300, false)]