Завершить инженерную проверку этапа 2
This commit is contained in:
@@ -126,6 +126,63 @@ public final class LateLevelPlaythroughTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sawDeliveredBodyKeepsLevelTenLiftPoweredAfterSettling() {
|
||||
try (ActivityScenario<MainActivity> activity = ActivityScenario.launch(MainActivity.class)) {
|
||||
GameDriver driver = GameDriver.from(activity);
|
||||
driver.startLevel(10);
|
||||
await(driver, 4_000L, false, true, false,
|
||||
snapshot -> snapshot.deaths() == 1 && snapshot.corpseCount() == 1);
|
||||
GameView.AutomationSnapshot engaged = await(driver, 5_000L, false, false, false,
|
||||
GameView.AutomationSnapshot::firstMovingPlatformPowered);
|
||||
driver.setInput(false, false, false);
|
||||
driver.waitForNextDecision(750L);
|
||||
|
||||
GameView.AutomationSnapshot settled = driver.snapshot();
|
||||
assertEquals("The body must settle when it engages the lift plate instead of sliding",
|
||||
engaged.firstCorpseX(), settled.firstCorpseX(), 2f);
|
||||
|
||||
driver.waitForNextDecision(6_000L);
|
||||
|
||||
settled = driver.snapshot();
|
||||
assertTrue("The saw-delivered body slid off the lift plate after settling; "
|
||||
+ "platformY=" + settled.firstMovingPlatformY()
|
||||
+ ", deaths=" + settled.deaths()
|
||||
+ ", corpses=" + settled.corpseCount(),
|
||||
settled.firstMovingPlatformPowered());
|
||||
assertEquals("The stability wait must not consume another volunteer",
|
||||
1, settled.deaths());
|
||||
assertEquals("The delivered body must remain in the level",
|
||||
1, settled.corpseCount());
|
||||
}
|
||||
}
|
||||
|
||||
private static GameView.AutomationSnapshot await(
|
||||
GameDriver driver,
|
||||
long timeoutMillis,
|
||||
boolean moveLeft,
|
||||
boolean moveRight,
|
||||
boolean jump,
|
||||
LevelPlaytestBot.SnapshotCondition condition
|
||||
) {
|
||||
long deadline = System.currentTimeMillis() + timeoutMillis;
|
||||
GameView.AutomationSnapshot snapshot = driver.snapshot();
|
||||
while (System.currentTimeMillis() < deadline) {
|
||||
snapshot = driver.snapshot();
|
||||
if (condition.reached(snapshot)) {
|
||||
driver.setInput(false, false, false);
|
||||
return snapshot;
|
||||
}
|
||||
driver.setInput(moveLeft, moveRight, jump);
|
||||
driver.waitForNextDecision(32L);
|
||||
}
|
||||
throw new AssertionError("Timed out waiting for level 10 lift body; x="
|
||||
+ snapshot.playerX() + ", y=" + snapshot.playerY()
|
||||
+ ", deaths=" + snapshot.deaths()
|
||||
+ ", corpses=" + snapshot.corpseCount()
|
||||
+ ", platformY=" + snapshot.firstMovingPlatformY());
|
||||
}
|
||||
|
||||
private static final class GameDriver implements LevelPlaytestBot.Driver {
|
||||
private final Instrumentation instrumentation;
|
||||
private final GameView gameView;
|
||||
|
||||
Reference in New Issue
Block a user