1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Test ModDifficultyAdjust is actually taking effect

This commit is contained in:
Dean Herbert 2020-03-05 11:53:04 +09:00
parent 26ce0d05d6
commit 9a12909f09

View File

@ -1,8 +1,14 @@
// 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.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Mods namespace osu.Game.Rulesets.Osu.Tests.Mods
@ -19,7 +25,15 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new OsuModDifficultyAdjust(), Mod = new OsuModDifficultyAdjust(),
Autoplay = true, Autoplay = true,
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2 PassCondition = checkSomeHit
});
[Test]
public void TestCircleSize1() => CreateModTest(new ModTestData
{
Mod = new OsuModDifficultyAdjust { CircleSize = { Value = 1 } },
Autoplay = true,
PassCondition = () => checkSomeHit() && checkObjectsScale(0.78f)
}); });
[Test] [Test]
@ -27,7 +41,15 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new OsuModDifficultyAdjust { CircleSize = { Value = 10 } }, Mod = new OsuModDifficultyAdjust { CircleSize = { Value = 10 } },
Autoplay = true, Autoplay = true,
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2 PassCondition = () => checkSomeHit() && checkObjectsScale(0.15f)
});
[Test]
public void TestApproachRate1() => CreateModTest(new ModTestData
{
Mod = new OsuModDifficultyAdjust { ApproachRate = { Value = 1 } },
Autoplay = true,
PassCondition = () => checkSomeHit() && checkObjectsPreempt(1680)
}); });
[Test] [Test]
@ -35,7 +57,30 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new OsuModDifficultyAdjust { ApproachRate = { Value = 10 } }, Mod = new OsuModDifficultyAdjust { ApproachRate = { Value = 10 } },
Autoplay = true, Autoplay = true,
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2 PassCondition = () => checkSomeHit() && checkObjectsPreempt(450)
}); });
private bool checkObjectsPreempt(double target)
{
var objects = Player.ChildrenOfType<DrawableHitCircle>();
if (!objects.Any())
return false;
return objects.All(o => o.HitObject.TimePreempt == target);
}
private bool checkObjectsScale(float target)
{
var objects = Player.ChildrenOfType<DrawableHitCircle>();
if (!objects.Any())
return false;
return objects.All(o => Precision.AlmostEquals(o.ChildrenOfType<ShakeContainer>().First().Children.OfType<Container>().Single().Scale.X, target));
}
private bool checkSomeHit()
{
return Player.ScoreProcessor.JudgedHits >= 2;
}
} }
} }