1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 12:53:11 +08:00

Fix PushAndConfirm potentially failing if new screen quickly pushes a child screen

This commit is contained in:
Dean Herbert 2021-10-06 12:40:25 +09:00
parent 8ffaa491e7
commit 90fdaf18c0

View File

@ -83,8 +83,17 @@ namespace osu.Game.Tests.Visual
protected void PushAndConfirm(Func<Screen> newScreen)
{
Screen screen = null;
AddStep("Push new screen", () => Game.ScreenStack.Push(screen = newScreen()));
AddUntilStep("Wait for new screen", () => Game.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
IScreen previousScreen = null;
AddStep("Push new screen", () =>
{
previousScreen = Game.ScreenStack.CurrentScreen;
Game.ScreenStack.Push(screen = newScreen());
});
AddUntilStep("Wait for new screen", () => screen.IsLoaded
&& Game.ScreenStack.CurrentScreen != previousScreen
&& previousScreen.GetChildScreen() == screen);
}
protected void ConfirmAtMainMenu() => AddUntilStep("Wait for main menu", () => Game.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);