1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 15:23:14 +08:00

Test drawable lifetime change on entry lifetime change

This commit is contained in:
ekrctb 2021-05-31 14:37:51 +09:00
parent e25cca6fbe
commit b7afea37c4

View File

@ -92,6 +92,35 @@ namespace osu.Game.Tests.Gameplay
AddAssert("Lifetime is correct", () => dho.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY && entry.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY);
}
[Test]
public void TestDrawableLifetimeUpdateOnEntryLifetimeChange()
{
TestDrawableHitObject dho = null;
TestLifetimeEntry entry = null;
AddStep("Create DHO", () =>
{
dho = new TestDrawableHitObject(null);
dho.Apply(entry = new TestLifetimeEntry(new HitObject()));
Child = dho;
});
AddStep("Set entry lifetime", () =>
{
entry.LifetimeStart = 777;
entry.LifetimeEnd = 888;
});
AddAssert("Drawable lifetime is updated", () => dho.LifetimeStart == 777 && dho.LifetimeEnd == 888);
AddStep("KeepAlive = true", () => entry.KeepAlive = true);
AddAssert("Drawable lifetime is updated", () => dho.LifetimeStart == double.MinValue && dho.LifetimeEnd == double.MaxValue);
AddStep("Modify start time", () => entry.HitObject.StartTime = 100);
AddAssert("Drawable lifetime is correct", () => dho.LifetimeStart == double.MinValue);
AddStep("KeepAlive = false", () => entry.KeepAlive = false);
AddAssert("Drawable lifetime is restored", () => dho.LifetimeStart == 100 - TestLifetimeEntry.INITIAL_LIFETIME_OFFSET);
}
private class TestDrawableHitObject : DrawableHitObject
{
public const double INITIAL_LIFETIME_OFFSET = 100;