1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 18:53:21 +08:00

Add failing test to check non-pooled lifetime

This commit is contained in:
ekrctb 2020-11-26 12:35:49 +09:00
parent b8a5cd94f7
commit 0817dae86c

View File

@ -46,10 +46,11 @@ namespace osu.Game.Tests.Visual.Gameplay
[SetUp] [SetUp]
public void Setup() => Schedule(() => testClock.CurrentTime = 0); public void Setup() => Schedule(() => testClock.CurrentTime = 0);
[Test] [TestCase("pooled")]
public void TestHitObjectPooling() [TestCase("non-pooled")]
public void TestHitObjectLifetime(string pooled)
{ {
var beatmap = createBeatmap(_ => new TestPooledHitObject()); var beatmap = createBeatmap(_ => pooled == "pooled" ? new TestPooledHitObject() : new TestHitObject());
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range }); beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
createTest(beatmap); createTest(beatmap);
@ -208,13 +209,13 @@ namespace osu.Game.Tests.Visual.Gameplay
/// <summary> /// <summary>
/// Get a <see cref="DrawableTestHitObject" /> corresponding to the <paramref name="index"/>'th <see cref="TestHitObject"/>. /// Get a <see cref="DrawableTestHitObject" /> corresponding to the <paramref name="index"/>'th <see cref="TestHitObject"/>.
/// When a pooling is used and the hit object is not alive, `null` is returned. /// When the hit object is not alive, `null` is returned.
/// </summary> /// </summary>
[CanBeNull] [CanBeNull]
private DrawableTestHitObject getDrawableHitObject(int index) private DrawableTestHitObject getDrawableHitObject(int index)
{ {
var hitObject = drawableRuleset.Beatmap.HitObjects.ElementAt(index); var hitObject = drawableRuleset.Beatmap.HitObjects.ElementAt(index);
return (DrawableTestHitObject)drawableRuleset.Playfield.HitObjectContainer.Objects.FirstOrDefault(obj => obj.HitObject == hitObject); return (DrawableTestHitObject)drawableRuleset.Playfield.HitObjectContainer.AliveObjects.FirstOrDefault(obj => obj.HitObject == hitObject);
} }
private float yScale => drawableRuleset.Playfield.HitObjectContainer.DrawHeight; private float yScale => drawableRuleset.Playfield.HitObjectContainer.DrawHeight;
@ -426,6 +427,7 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
}); });
} }
protected override void Update() => LifetimeEnd = HitObject.EndTime;
} }
private class DrawableTestPooledHitObject : DrawableTestHitObject private class DrawableTestPooledHitObject : DrawableTestHitObject
@ -436,8 +438,6 @@ namespace osu.Game.Tests.Visual.Gameplay
InternalChildren[0].Colour = Color4.LightSkyBlue; InternalChildren[0].Colour = Color4.LightSkyBlue;
InternalChildren[1].Colour = Color4.Blue; InternalChildren[1].Colour = Color4.Blue;
} }
protected override void Update() => LifetimeEnd = HitObject.EndTime;
} }
private class DrawableTestParentHitObject : DrawableTestHitObject private class DrawableTestParentHitObject : DrawableTestHitObject