Стабилизировать ранние сценарии после этапа 3

This commit is contained in:
2026-08-18 17:33:05 +03:00
parent f07d1cf830
commit f06467fcfa
2 changed files with 29 additions and 5 deletions
@@ -49,13 +49,31 @@ public final class GameLifecycleTest {
GameView.AutomationSnapshot resumed = snapshot(instrumentation, view[0]);
assertFalse("Back from the visible pause screen must resume the puzzle", resumed.visiblyPaused());
runOnGame(instrumentation, view[0], false, false, true, false);
sleep(250L);
GameView.AutomationSnapshot moving = waitForMovement(
instrumentation, view[0], resumed.playerX(), 10_000L);
runOnGame(instrumentation, view[0], false, false, false, false);
GameView.AutomationSnapshot moving = snapshot(instrumentation, view[0]);
assertTrue("The resumed simulation must accept movement", moving.playerX() > resumed.playerX() + 20f);
}
}
private static GameView.AutomationSnapshot waitForMovement(
Instrumentation instrumentation, GameView gameView, float startX, long timeoutMillis) {
long deadline = System.currentTimeMillis() + timeoutMillis;
GameView.AutomationSnapshot current = snapshot(instrumentation, gameView);
while (System.currentTimeMillis() < deadline) {
if (current.playerX() > startX + 20f) return current;
sleep(24L);
current = snapshot(instrumentation, gameView);
}
throw new AssertionError(
"The resumed simulation did not move within " + timeoutMillis
+ "ms; startX=" + startX
+ ", finalX=" + current.playerX()
+ ", alive=" + current.playerAlive()
+ ", paused=" + current.visiblyPaused()
+ ", inputActive=" + current.inputActive());
}
private static void createRetainedCorpse(Instrumentation instrumentation, GameView gameView) {
runOnGame(instrumentation, gameView, true, false, true, false);
long deadline = System.currentTimeMillis() + 8_000L;
@@ -67,9 +67,15 @@ public final class EarlyLevelScenarios {
.step("Wait for the next volunteer", 2_000L, LevelPlaytestBot.Input.none(),
EarlyLevelScenarios::respawnedAtStart)
.step("Approach the saw", 3_000L, LevelPlaytestBot.Input.right(),
snapshot -> snapshot.playerX() >= 300f)
.step("Jump over the saw and plate body", 3_000L, LevelPlaytestBot.Input.rightJump(),
snapshot -> snapshot.playerX() >= 700f)
snapshot -> snapshot.playerAlive()
&& snapshot.playerOnGround()
&& snapshot.playerX() >= 280f)
.step("Take off before the saw", 1_000L, LevelPlaytestBot.Input.rightJump(),
snapshot -> snapshot.playerAlive()
&& !snapshot.playerOnGround()
&& snapshot.playerY() <= 680f)
.step("Clear the saw and plate body", 3_000L, LevelPlaytestBot.Input.right(),
snapshot -> snapshot.playerAlive() && snapshot.playerX() >= 700f)
.step("Reach the relic through the open door", 5_000L, LevelPlaytestBot.Input.right(),
GameView.AutomationSnapshot::completed)
.build();