1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 12:07:23 +08:00

Update TestSceneReplayReocorder to be safer about disposal

This commit is contained in:
Dean Herbert 2021-12-06 16:42:24 +09:00
parent 50a5f52f92
commit 0d3d22d3e1

View File

@ -43,8 +43,12 @@ namespace osu.Game.Tests.Visual.Gameplay
[Cached]
private GameplayState gameplayState = new GameplayState(new Beatmap(), new OsuRuleset(), Array.Empty<Mod>());
[SetUp]
public void SetUp() => Schedule(() =>
[SetUpSteps]
public void SetUpSteps()
{
AddStep("Reset recorder state", cleanUpState);
AddStep("Setup containers", () =>
{
replay = new Replay();
@ -120,6 +124,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}
});
});
}
[Test]
public void TestBasic()
@ -184,7 +189,14 @@ namespace osu.Game.Tests.Visual.Gameplay
[TearDownSteps]
public void TearDown()
{
AddStep("stop recorder", () => recorder.Expire());
AddStep("stop recorder", cleanUpState);
}
private void cleanUpState()
{
// Ensure previous recorder is disposed else it may affect the global playing state of `SpectatorClient`.
recorder?.RemoveAndDisposeImmediately();
recorder = null;
}
public class TestFramedReplayInputHandler : FramedReplayInputHandler<TestReplayFrame>