Fix intermittent failure in tests with restarting player instances

This commit is contained in:
Salman Ahmed
2023-01-15 15:51:18 +03:00
parent 8f70424999
commit 13c1b8f5a4
5 changed files with 28 additions and 5 deletions

View File

@ -195,11 +195,17 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("wait for player", () =>
{
DismissAnyNotifications();
return (player = Game.ScreenStack.CurrentScreen as Player) != null;
player = Game.ScreenStack.CurrentScreen as Player;
return player?.IsLoaded == true;
});
AddAssert("retry count is 0", () => player.RestartCount == 0);
// todo: see https://github.com/ppy/osu/issues/22220
// tests are supposed to be immune to this edge case by the logic in TestPlayer,
// but we're running a full game instance here, so we have to work around it manually.
AddStep("end spectator before retry", () => Game.SpectatorClient.EndPlaying(player.GameplayState));
AddStep("attempt to retry", () => player.ChildrenOfType<HotkeyRetryOverlay>().First().Action());
AddUntilStep("wait for old player gone", () => Game.ScreenStack.CurrentScreen != player);