Стабилизировать ранние сценарии после этапа 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]); GameView.AutomationSnapshot resumed = snapshot(instrumentation, view[0]);
assertFalse("Back from the visible pause screen must resume the puzzle", resumed.visiblyPaused()); assertFalse("Back from the visible pause screen must resume the puzzle", resumed.visiblyPaused());
runOnGame(instrumentation, view[0], false, false, true, false); 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); 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); 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) { private static void createRetainedCorpse(Instrumentation instrumentation, GameView gameView) {
runOnGame(instrumentation, gameView, true, false, true, false); runOnGame(instrumentation, gameView, true, false, true, false);
long deadline = System.currentTimeMillis() + 8_000L; 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(), .step("Wait for the next volunteer", 2_000L, LevelPlaytestBot.Input.none(),
EarlyLevelScenarios::respawnedAtStart) EarlyLevelScenarios::respawnedAtStart)
.step("Approach the saw", 3_000L, LevelPlaytestBot.Input.right(), .step("Approach the saw", 3_000L, LevelPlaytestBot.Input.right(),
snapshot -> snapshot.playerX() >= 300f) snapshot -> snapshot.playerAlive()
.step("Jump over the saw and plate body", 3_000L, LevelPlaytestBot.Input.rightJump(), && snapshot.playerOnGround()
snapshot -> snapshot.playerX() >= 700f) && 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(), .step("Reach the relic through the open door", 5_000L, LevelPlaytestBot.Input.right(),
GameView.AutomationSnapshot::completed) GameView.AutomationSnapshot::completed)
.build(); .build();