feat(studio): integrate memcard persistence and headless controls
Persist cartridge identity and slot configuration, add MemcardBoot and the MemcardBuffer SDK, and consume the runtime's negotiated memcard host controls with protected teardown. Qualify save/reopen and version upgrades through distinct configured runtime processes. Include specs, examples, regression evidence and the consolidated discussion lesson.
This commit is contained in:
@@ -128,6 +128,49 @@ class DevDesktopTest {
|
||||
assertEquals("external agent edit", form.draft);
|
||||
});
|
||||
}
|
||||
@Test void protectedReturnShowsExplicitDiscardAndCancelDoesNotGrantConsent() throws Exception {
|
||||
try (var pool = Executors.newSingleThreadExecutor()) {
|
||||
var authority = new DefaultAutomationSession(root, new ExecutorOperationExecutor(pool));
|
||||
var discarded = new java.util.concurrent.atomic.AtomicBoolean();
|
||||
authority.grant(false).toCompletableFuture().get(5, TimeUnit.SECONDS);
|
||||
var task = authority.acquire().task();
|
||||
authority.attachRuntime(task, new ManagedHeadlessSession() {
|
||||
public String sessionId() { return "dirty"; }
|
||||
public void cancel() { }
|
||||
public CompletionStage<Void> shutdown() { return shutdown(false); }
|
||||
public CompletionStage<Void> shutdown(boolean consent) {
|
||||
if (!consent) return CompletableFuture.failedFuture(new AutomationException(new AutomationFailure(
|
||||
AutomationFailure.Code.MEMCARD_ERROR, "Unsaved changes", java.util.Map.of("reason", "unsaved_changes"))));
|
||||
discarded.set(true); return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
});
|
||||
var view = new DevWorkspace[1]; var stage = new Stage[1];
|
||||
try {
|
||||
fx(() -> {
|
||||
view[0] = new DevWorkspace(new ProjectReference("Dirty", "1", "pbs", 1, ProjectTarget.Game, root),
|
||||
authority, new I18nService(), new StudioEventBus());
|
||||
stage[0] = new Stage(); stage[0].setScene(new Scene(new VBox(view[0].rootNode()), 1050, 800)); stage[0].show(); view[0].load();
|
||||
assertFalse(view[0].rootNode().lookup("#dev-discard-game-data").isVisible());
|
||||
});
|
||||
assertEquals(ControlResult.Status.CLEANUP_FAILED, authority.reclaim().toCompletableFuture().get(5, TimeUnit.SECONDS).status());
|
||||
fx(() -> {
|
||||
var discard = (Button) view[0].rootNode().lookup("#dev-discard-game-data"); assertTrue(discard.isVisible());
|
||||
Platform.runLater(() -> javafx.stage.Window.getWindows().stream().filter(w -> w instanceof Stage && w != stage[0]).findFirst()
|
||||
.ifPresent(w -> ((Button) ((DialogPane) w.getScene().getRoot()).lookupButton(ButtonType.CANCEL)).fire()));
|
||||
discard.fire(); assertFalse(discarded.get());
|
||||
Platform.runLater(() -> javafx.stage.Window.getWindows().stream().filter(w -> w instanceof Stage && w != stage[0]).findFirst()
|
||||
.ifPresent(w -> ((Button) ((DialogPane) w.getScene().getRoot()).lookupButton(ButtonType.OK)).fire()));
|
||||
discard.fire();
|
||||
assertTrue(discarded.get()); assertTrue(authority.snapshot().manualAllowed());
|
||||
assertFalse(discard.isVisible());
|
||||
});
|
||||
} finally {
|
||||
fx(() -> { if (view[0] != null) view[0].unLoad(); if (stage[0] != null) stage[0].close(); });
|
||||
authority.reclaimDiscardingUnsavedGameData().toCompletableFuture().get(5, TimeUnit.SECONDS);
|
||||
authority.closeAsync().toCompletableFuture().get(5, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test void preparesConnectionWithoutGrantAndRemainsAvailableWhenTransportStops() throws Exception {
|
||||
var mapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
|
||||
Reference in New Issue
Block a user