Launch the JavaFX 2 project shell on Java 25 with an interactive viewport, managed Play lifecycle and project mutation guards. Preserve headless/MCP and save compatibility, and qualify exact runtime executable bundles. Separate unit JaCoCo gates from opt-in integration suites and use the internal Pong fixture for the headless visual pilot. Move maintenance and native conformance tools into tooling; retain the VS Code extension and update current navigation links. Validation: tooling make verify passed, including 1064 Studio unit tests, JaCoCo thresholds and 22 headless integration tests.
56 lines
5.3 KiB
Java
56 lines
5.3 KiB
Java
package p.studio.app.animation;
|
|
|
|
import javafx.application.Platform;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.control.*;
|
|
import javafx.scene.image.ImageView;
|
|
import javafx.stage.Stage;
|
|
import org.junit.jupiter.api.*;
|
|
import org.junit.jupiter.api.io.TempDir;
|
|
import p.studio.ui.javafx.workspaces.assets.details.animation.AnimationEditorControl;
|
|
import p.animation.*;
|
|
import java.nio.file.*;
|
|
import java.util.concurrent.*;
|
|
import java.util.function.*;
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
/** Actual JavaFX editing, shared save/preview, drift repair and handoff lifecycle. */
|
|
@org.junit.jupiter.api.Tag("integration")
|
|
class AnimationDesktopTest {
|
|
@TempDir Path root;
|
|
@BeforeAll static void toolkit()throws Exception{
|
|
var ready=new CompletableFuture<Void>();
|
|
try{Platform.startup(()->{Platform.setImplicitExit(false);ready.complete(null);});}
|
|
catch(IllegalStateException running){ready.complete(null);}
|
|
ready.get(10,TimeUnit.SECONDS);
|
|
}
|
|
@AfterAll static void stopToolkit(){Platform.exit();}
|
|
static <T>T fx(Supplier<T> work)throws Exception{var result=new CompletableFuture<T>();Platform.runLater(()->{try{result.complete(work.get());}catch(Throwable f){result.completeExceptionally(f);}});return result.get(10,TimeUnit.SECONDS);}
|
|
static void await(BooleanSupplier test)throws Exception{long end=System.nanoTime()+TimeUnit.SECONDS.toNanos(10);while(!test.getAsBoolean()){if(System.nanoTime()>end)fail("Animation editor did not finish");Thread.sleep(10);}}
|
|
static Button button(AnimationEditorControl editor,String text){return editor.lookupAll(".button").stream().filter(n->n instanceof Button b&&b.getText().equals(text)).map(n->(Button)n).findFirst().orElseThrow();}
|
|
@Test void authorsPreviewsSavesRepairsAndCloses()throws Exception{
|
|
var fixture=new AnimationIntegrationTest();fixture.root=root;fixture.setup();
|
|
var pool=Executors.newCachedThreadPool();var stage=new Stage[1];var editor=new AnimationEditorControl[1];
|
|
try{
|
|
fx(()->{editor[0]=new AnimationEditorControl(fixture.project,fixture.manual,pool);var scroll=new ScrollPane(editor[0]);scroll.setFitToWidth(true);stage[0]=new Stage();stage[0].setTitle("Animation authoring acceptance");stage[0].setScene(new Scene(scroll,1040,940));stage[0].show();editor[0].bind(fixture.uuid);return null;});
|
|
await(()->{try{return fx(()->((Label)editor[0].lookup("#animation-status")).getText().equals("New definition"));}catch(Exception e){throw new RuntimeException(e);}});
|
|
fx(()->{((TextField)editor[0].lookup("#animation-id")).setText("hero");button(editor[0],"New animator").fire();((ComboBox<?>)editor[0].lookup("#animation-glyph")).getSelectionModel().selectFirst();((TextField)editor[0].lookup("#animation-duration")).setText("2");button(editor[0],"Add frame").fire();return null;});
|
|
assertTrue(editor[0].hasUnsavedChanges().toCompletableFuture().get());
|
|
editor[0].saveAll().toCompletableFuture().get(10,TimeUnit.SECONDS);
|
|
assertFalse(editor[0].hasUnsavedChanges().toCompletableFuture().get());
|
|
assertEquals(2,fixture.manual.execute(p.studio.api.assets.animation.AnimationService.Request.get(fixture.project,fixture.uuid)).view().document().animators().getFirst().clips().getFirst().frames().getFirst().durationTicks());
|
|
fx(()->{button(editor[0],"Preview").fire();return null;});
|
|
await(()->{try{return fx(()->((ImageView)editor[0].lookup("#animation-image")).getImage()!=null);}catch(Exception e){throw new RuntimeException(e);}});
|
|
fx(()->{var snapshot=stage[0].getScene().snapshot(null);var image=new java.awt.image.BufferedImage((int)snapshot.getWidth(),(int)snapshot.getHeight(),java.awt.image.BufferedImage.TYPE_INT_ARGB);for(int y=0;y<image.getHeight();y++)for(int x=0;x<image.getWidth();x++)image.setRGB(x,y,snapshot.getPixelReader().getArgb(x,y));try{javax.imageio.ImageIO.write(image,"png",Path.of("/tmp/dec84-animation-desktop.png").toFile());}catch(Exception e){throw new RuntimeException(e);}return null;});
|
|
var asset=(com.fasterxml.jackson.databind.node.ObjectNode)fixture.mapper.readTree(fixture.bankRoot.resolve("asset.json").toFile());((com.fasterxml.jackson.databind.node.ObjectNode)asset.path("artifacts").get(0)).put("index",1);((com.fasterxml.jackson.databind.node.ObjectNode)asset.path("artifacts").get(1)).put("index",0);fixture.mapper.writeValue(fixture.bankRoot.resolve("asset.json").toFile(),asset);
|
|
editor[0].refreshFromDisk().toCompletableFuture().get(10,TimeUnit.SECONDS);
|
|
fx(()->{button(editor[0],"Prepare rebind").fire();return null;});
|
|
await(()->{try{return fx(()->!button(editor[0],"Apply rebind").isDisabled());}catch(Exception e){throw new RuntimeException(e);}});
|
|
fx(()->{button(editor[0],"Apply rebind").fire();return null;});
|
|
await(()->fixture.manual.execute(p.studio.api.assets.animation.AnimationService.Request.get(fixture.project,fixture.uuid)).view().diagnostics().isEmpty());
|
|
fx(()->{editor[0].openOrigin("/animators/0/clips/0/frames/0");editor[0].close();stage[0].close();return null;});
|
|
assertFalse(pool.isShutdown());
|
|
}finally{fx(()->{if(editor[0]!=null)editor[0].close();if(stage[0]!=null)stage[0].close();return null;});pool.shutdownNow();fixture.close();}
|
|
}
|
|
}
|