From 7e0379441c692c5eed9f16ef8b6e36bed6bf6549 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Oct 2021 16:18:47 +0900 Subject: [PATCH] Change `TestSceneOsuGame` to use `OsuGameTestScene` to avoid async disposal deadlock The original implementation was done so in a way that the nested `OsuGame` would be disposed via the async queue, causing a deadlock for 10-20s during test runs. `OsuGameTestScene` was already fixed to avoid this, so consuming it here seems like the easy fix. --- .../Visual/Navigation/TestSceneOsuGame.cs | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs b/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs index 7327d4053a..353ead131e 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs @@ -34,7 +34,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.Navigation { [TestFixture] - public class TestSceneOsuGame : OsuTestScene + public class TestSceneOsuGame : OsuGameTestScene { private IReadOnlyList requiredGameDependencies => new[] { @@ -84,34 +84,12 @@ namespace osu.Game.Tests.Visual.Navigation typeof(PreviewTrackManager), }; - private OsuGame game; - [Resolved] private OsuGameBase gameBase { get; set; } [Resolved] private GameHost host { get; set; } - [SetUpSteps] - public void SetUpSteps() - { - AddStep("create game", () => - { - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - }; - - AddGame(game = new OsuGame()); - }); - - AddUntilStep("wait for load", () => game.IsLoaded); - } - [Test] public void TestNullRulesetHandled() { @@ -127,8 +105,8 @@ namespace osu.Game.Tests.Visual.Navigation [Test] public void TestSwitchThreadExecutionMode() { - AddStep("Change thread mode to multi threaded", () => { game.Dependencies.Get().SetValue(FrameworkSetting.ExecutionMode, ExecutionMode.MultiThreaded); }); - AddStep("Change thread mode to single thread", () => { game.Dependencies.Get().SetValue(FrameworkSetting.ExecutionMode, ExecutionMode.SingleThread); }); + AddStep("Change thread mode to multi threaded", () => { Game.Dependencies.Get().SetValue(FrameworkSetting.ExecutionMode, ExecutionMode.MultiThreaded); }); + AddStep("Change thread mode to single thread", () => { Game.Dependencies.Get().SetValue(FrameworkSetting.ExecutionMode, ExecutionMode.SingleThread); }); } [Test] @@ -154,7 +132,7 @@ namespace osu.Game.Tests.Visual.Navigation { foreach (var type in requiredGameDependencies) { - if (game.Dependencies.Get(type) == null) + if (Game.Dependencies.Get(type) == null) throw new InvalidOperationException($"{type} has not been cached"); }