Add failing test case

This commit is contained in:
Bartłomiej Dach 2022-10-25 19:53:05 +02:00
parent 521fbd2ea3
commit 93e9b4a2c5
No known key found for this signature in database
2 changed files with 40 additions and 4 deletions

View File

@ -1,8 +1,12 @@
// 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.Framework.Testing;
using osu.Game.Rulesets.Taiko.Mods;
using osu.Game.Rulesets.Taiko.UI;
using osuTK;
namespace osu.Game.Rulesets.Taiko.Tests.Mods
{
@ -16,5 +20,37 @@ public class TestSceneTaikoModFlashlight : TaikoModTestScene
[Test]
public void TestComboBasedSize([Values] bool comboBasedSize) => CreateModTest(new ModTestData { Mod = new TaikoModFlashlight { ComboBasedSize = { Value = comboBasedSize } }, PassCondition = () => true });
[Test]
public void TestFlashlightAlwaysHasNonZeroSize()
{
bool failed = false;
CreateModTest(new ModTestData
{
Mod = new TestTaikoModFlashlight { ComboBasedSize = { Value = true } },
Autoplay = false,
PassCondition = () =>
{
failed |= this.ChildrenOfType<TestTaikoModFlashlight.TestTaikoFlashlight>().SingleOrDefault()?.FlashlightSize.Y == 0;
return !failed;
}
});
}
private class TestTaikoModFlashlight : TaikoModFlashlight
{
protected override Flashlight CreateFlashlight() => new TestTaikoFlashlight(this, Playfield);
public class TestTaikoFlashlight : TaikoFlashlight
{
public TestTaikoFlashlight(TaikoModFlashlight modFlashlight, TaikoPlayfield taikoPlayfield)
: base(modFlashlight, taikoPlayfield)
{
}
public new Vector2 FlashlightSize => base.FlashlightSize;
}
}
}
}

View File

@ -27,17 +27,17 @@ public class TaikoModFlashlight : ModFlashlight<TaikoHitObject>
public override float DefaultFlashlightSize => 200;
protected override Flashlight CreateFlashlight() => new TaikoFlashlight(this, playfield);
protected override Flashlight CreateFlashlight() => new TaikoFlashlight(this, Playfield);
private TaikoPlayfield playfield = null!;
protected TaikoPlayfield Playfield { get; private set; } = null!;
public override void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
{
playfield = (TaikoPlayfield)drawableRuleset.Playfield;
Playfield = (TaikoPlayfield)drawableRuleset.Playfield;
base.ApplyToDrawableRuleset(drawableRuleset);
}
private class TaikoFlashlight : Flashlight
public class TaikoFlashlight : Flashlight
{
private readonly LayoutValue flashlightProperties = new LayoutValue(Invalidation.RequiredParentSizeToFit | Invalidation.DrawInfo);
private readonly TaikoPlayfield taikoPlayfield;