rename test scene and create a new game each test

This commit is contained in:
David Zhao 2019-07-30 18:16:17 +09:00
parent 82fcb88f5c
commit 98bb6da975

View File

@ -20,49 +20,37 @@ using osuTK.Input;
namespace osu.Game.Tests.Visual.Menus namespace osu.Game.Tests.Visual.Menus
{ {
public class TestSceneExitingScreens : ManualInputManagerTestScene public class TestSceneScreenNavigation : ManualInputManagerTestScene
{ {
private readonly TestOsuGame osuGame = new TestOsuGame(); private GameHost gameHost;
private TestOsuGame osuGame;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost gameHost) private void load(GameHost gameHost)
{ {
osuGame.SetHost(gameHost); this.gameHost = gameHost;
Children = new Drawable[] Child = new Box
{ {
new Box RelativeSizeAxes = Axes.Both,
{ Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
osuGame
}; };
} }
[SetUpSteps] [SetUpSteps]
public void SetUpSteps() public void SetUpSteps()
{ {
AddUntilStep("wait for load", () => osuGame.IsLoaded); AddStep("Create new game instance", () =>
AddUntilStep("exit to main menu", () =>
{ {
var current = osuGame.ScreenStack.CurrentScreen; if (osuGame != null)
Remove(osuGame);
switch (current) osuGame = new TestOsuGame();
{ osuGame.SetHost(gameHost);
case null:
case IntroScreen _:
case Disclaimer _:
return false;
case MainMenu _: Add(osuGame);
return true;
default:
current.Exit();
return false;
}
}); });
AddUntilStep("wait for load and menu is current", () => osuGame.IsLoaded && osuGame.ScreenStack.CurrentScreen is MainMenu);
} }
[Test] [Test]