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] [Cached]
private GameplayState gameplayState = new GameplayState(new Beatmap(), new OsuRuleset(), Array.Empty<Mod>()); private GameplayState gameplayState = new GameplayState(new Beatmap(), new OsuRuleset(), Array.Empty<Mod>());
[SetUp] [SetUpSteps]
public void SetUp() => Schedule(() => public void SetUpSteps()
{
AddStep("Reset recorder state", cleanUpState);
AddStep("Setup containers", () =>
{ {
replay = new Replay(); replay = new Replay();
@ -120,6 +124,7 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
}); });
}); });
}
[Test] [Test]
public void TestBasic() public void TestBasic()
@ -184,7 +189,14 @@ namespace osu.Game.Tests.Visual.Gameplay
[TearDownSteps] [TearDownSteps]
public void TearDown() 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> public class TestFramedReplayInputHandler : FramedReplayInputHandler<TestReplayFrame>