feat(studio): adopt the 640x360 native graphics contract
Update the new JavaFX UI's frame sizing and pointer cancellation while preserving zoom and scrolling. Adapt Pong, Fragments and the camera scene to the native viewport, and update exact visual references and IPC fixtures. Build and run all three examples against qualified installed runtimes. Observe an actual Pong paddle collision and verify native frame captures. Retain the qualification evidence generated for the tested native bundles. Validated by the complete verify and desktop integration gates, including the existing 30-second Play measurement and 20 Play/Stop cycles. Work: WRK-0016 / DEC-0001 / PLN-0001 Commit and push explicitly authorized by the user after completion.
This commit is contained in:
@@ -89,8 +89,8 @@ class StudioPlayDesktopTest {
|
||||
fx(()->{assertTrue(stage.getScene().lookup("#runtime-path").isDisabled());return null;});
|
||||
assertThrows(p.studio.api.automation.ControlDeniedException.class,()->access.enterManual(root));
|
||||
fx(()->{ComboBox<Integer> zoom=(ComboBox<Integer>)stage.getScene().lookup("#viewport-zoom");zoom.setValue(4);
|
||||
var image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(1920,image.getFitWidth());assertFalse(image.isSmooth());
|
||||
zoom.setValue(2);assertEquals(960,image.getFitWidth());zoom.setValue(1);assertEquals(480,image.getFitWidth());return null;});
|
||||
var image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(2560,image.getFitWidth());assertFalse(image.isSmooth());
|
||||
zoom.setValue(2);assertEquals(1280,image.getFitWidth());zoom.setValue(1);assertEquals(640,image.getFitWidth());return null;});
|
||||
// Deliver a real key edge through the viewport; Pong leaves its static menu.
|
||||
// Zoom popup/native activation can transfer desktop focus. Establish the
|
||||
// input precondition explicitly; the later focus-loss checks never resume.
|
||||
@@ -219,6 +219,7 @@ class StudioPlayDesktopTest {
|
||||
assertEquals(16,image.getFitWidth());
|
||||
pointer(image,MouseEvent.MOUSE_PRESSED,6,6);assertEquals(new ExecutionInput(4096,1,1),input.get());
|
||||
pointer(image,MouseEvent.MOUSE_DRAGGED,-1,6);assertEquals(0,input.get().buttons());assertEquals(-1,input.get().touchX());
|
||||
pointer(image,MouseEvent.MOUSE_DRAGGED,6,6);assertEquals(0,input.get().buttons(),"Reentry while held must not recapture");
|
||||
pointer(image,MouseEvent.MOUSE_PRESSED,14,6);assertEquals(new ExecutionInput(4096,3,1),input.get());
|
||||
pointer(image,MouseEvent.MOUSE_RELEASED,30,30);assertEquals(0,input.get().buttons());
|
||||
var surface=stage.getScene().lookup("#game-surface");
|
||||
|
||||
@@ -93,6 +93,70 @@ class HeadlessTaskIntegrationTest {
|
||||
}
|
||||
void authorityRetained() { assertEquals(ControlState.AGENT_WORKING, project.automation().snapshot().state()); }
|
||||
|
||||
@org.junit.jupiter.params.ParameterizedTest
|
||||
@org.junit.jupiter.params.provider.ValueSource(strings={"pong","fragments","main"})
|
||||
void maintainedGraphicsExamplesBuildAndPublishNativeFrames(String name) throws Exception {
|
||||
project.close();
|
||||
Path examples=Path.of("../test-projects").toAbsolutePath().normalize();
|
||||
if(!Files.isDirectory(examples))examples=Path.of("test-projects").toAbsolutePath().normalize();
|
||||
Path example=examples.resolve(name);
|
||||
for(String directory:List.of("src","assets")){
|
||||
Path from=example.resolve(directory);
|
||||
if(!Files.isDirectory(from))continue;
|
||||
try(var files=Files.walk(from)){
|
||||
for(Path file:files.toList()){
|
||||
Path target=root.resolve(directory).resolve(from.relativize(file));
|
||||
if(Files.isDirectory(file))Files.createDirectories(target);
|
||||
else Files.copy(file,target,StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
Files.copy(example.resolve("prometeu.json"),root.resolve("prometeu.json"),StandardCopyOption.REPLACE_EXISTING);
|
||||
var reference=app.getBean(ProjectCatalog.class).openProject(root);
|
||||
project=app.getBean(ProjectSessionFactory.class).open(reference);
|
||||
assertTrue(project.automation().grant(false).toCompletableFuture().get(5,TimeUnit.SECONDS).success());
|
||||
task=tasks.acquire(root).task().value();
|
||||
call(TaskTools.HeadlessAction.BOOT,successfulBuild("graphics-"+name));
|
||||
var result=advance("graphics-frames-"+name);
|
||||
assertEquals(AutomationOutcome.Kind.SUCCEEDED,result.kind(),String.valueOf(result));
|
||||
var png=result.capture().png();
|
||||
var pixels=new p.studio.app.evidence.PngEvidenceCodec().decode(png);
|
||||
assertEquals(640,pixels.width());assertEquals(360,pixels.height());
|
||||
assertNull(call(TaskTools.HeadlessAction.FAULT,null).values().get("fault"));
|
||||
Path output=Path.of("build/graphics-examples");Files.createDirectories(output);
|
||||
Files.write(output.resolve(name+".png"),png);
|
||||
if(name.equals("pong")) {
|
||||
tasks.headless(root,task,TaskTools.HeadlessAction.SET_INPUT,null,Map.of("start",true));
|
||||
advance("pong-native-start");
|
||||
tasks.headless(root,task,TaskTools.HeadlessAction.SET_INPUT,null,Map.of("start",false,"a",true));
|
||||
advance("pong-native-serve");
|
||||
tasks.headless(root,task,TaskTools.HeadlessAction.CLEAR_INPUT,null,Map.of());
|
||||
int previous=-1;boolean rightPaddleBounce=false;
|
||||
for(int i=0;i<80&&!rightPaddleBounce;i++) {
|
||||
String request="pong-native-contact-"+i;
|
||||
tasks.advance(root,task,request,1);
|
||||
var frame=finished(request);assertNull(frame.failure());
|
||||
assertEquals(AutomationOutcome.Kind.SUCCEEDED,frame.runtimeResult().kind());
|
||||
var image=new p.studio.app.evidence.PngEvidenceCodec().decode(frame.runtimeResult().capture().png());
|
||||
byte[] rgba=image.rgba();int left=640,right=-1;
|
||||
// Independent observation of the white ball/flash in the arena;
|
||||
// HUD is above it, and neither paddle has this color.
|
||||
for(int y=72;y<328;y++)for(int x=60;x<615;x++) {
|
||||
int offset=(y*640+x)*4;
|
||||
if(Byte.toUnsignedInt(rgba[offset])==236&&Byte.toUnsignedInt(rgba[offset+1])==244
|
||||
&&Byte.toUnsignedInt(rgba[offset+2])==250) {left=Math.min(left,x);right=Math.max(right,x);}
|
||||
}
|
||||
assertTrue(right>=left,"Playing ball must remain observable before right contact");
|
||||
int center=(left+right)/2;
|
||||
// A scored point would teleport to the center; require a local
|
||||
// reversal near the new right paddle at x=590 instead.
|
||||
rightPaddleBounce=previous>570&¢er<previous&¢er>500;
|
||||
previous=center;
|
||||
}
|
||||
assertTrue(rightPaddleBounce,"Actual guest ball must bounce off the paddle in the expanded arena");
|
||||
}
|
||||
}
|
||||
|
||||
@Test void originalCaptureEvidenceSurvivesLaterFramesRebuildReleaseAndReopen() throws Exception {
|
||||
call(TaskTools.HeadlessAction.BOOT,successfulBuild("evidence-build"));
|
||||
tasks.advance(root,task,"evidence-frame",1);var original=finished("evidence-frame");
|
||||
@@ -145,7 +209,7 @@ class HeadlessTaskIntegrationTest {
|
||||
var legacyPaths=new ArrayList<String>();
|
||||
String[] names={"menu-accent","serve-ball","moved-paddle"};
|
||||
// Fixed expectations from the fixture's draw/input contract, never from a native capture.
|
||||
Evidence.Rect[] regions={new Evidence.Rect(113,114,1,80),new Evidence.Rect(237,152,6,6),new Evidence.Rect(42,72,8,36)};
|
||||
Evidence.Rect[] regions={new Evidence.Rect(193,159,1,80),new Evidence.Rect(317,197,6,6),new Evidence.Rect(42,72,8,36)};
|
||||
int[][] colors={{77,237,205},{236,244,250},{77,237,205}};
|
||||
long totalPngBytes=0;
|
||||
for(int i=0;i<names.length;i++) {
|
||||
@@ -163,11 +227,11 @@ class HeadlessTaskIntegrationTest {
|
||||
assertFalse(persisted.path("isError").asBoolean(),persisted.toString());
|
||||
var actual=mapper.convertValue(persisted.path("structuredContent").path("value"),Evidence.Publication.class).artifacts().getFirst();
|
||||
Path reference=root.resolve("reference-"+names[i]+".png");
|
||||
byte[] rgba=new byte[480*270*4];
|
||||
byte[] rgba=new byte[640*360*4];
|
||||
for(int pixel=0;pixel<rgba.length;pixel+=4){
|
||||
rgba[pixel]=(byte)colors[i][0];rgba[pixel+1]=(byte)colors[i][1];rgba[pixel+2]=(byte)colors[i][2];rgba[pixel+3]=(byte)255;
|
||||
}
|
||||
Files.write(reference,new p.studio.app.evidence.PngEvidenceCodec().encode(new Evidence.Pixels(480,270,rgba)));
|
||||
Files.write(reference,new p.studio.app.evidence.PngEvidenceCodec().encode(new Evidence.Pixels(640,360,rgba)));
|
||||
legacyPaths.add(reference.toString());legacyPaths.add(legacyActual.toString());
|
||||
var imported=mcp.call("studio_evidence_import",args.deepCopy().put("clientRequestId","import-"+request).put("path",reference.toString())).wire();
|
||||
afterCalls++;afterWireBytes+=mapper.writeValueAsBytes(imported).length;
|
||||
|
||||
@@ -75,7 +75,7 @@ class StudioPlayProcessTest {
|
||||
try(var s=new Native()){
|
||||
s.connection.pause().get(3,TimeUnit.SECONDS);s.connection.startExecution().get(3,TimeUnit.SECONDS);
|
||||
Thread.sleep(80);assertNull(s.connection.acquireLatestFrame());
|
||||
s.connection.resume().get(3,TimeUnit.SECONDS);try(var image=s.image()){assertEquals(480,image.width());}
|
||||
s.connection.resume().get(3,TimeUnit.SECONDS);try(var image=s.image()){assertEquals(640,image.width());}
|
||||
s.connection.stopAsync().get(5,TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ class StudioWireTest {
|
||||
byte[] huge=fixture("pause.hex");java.util.Arrays.fill(huge,12,16,(byte)255);
|
||||
assertThrows(IOException.class,()->Header.decode(huge));
|
||||
assertThrows(IOException.class,()->frameBytes(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE));
|
||||
assertThrows(IOException.class,()->frameBytes(480,270,481));
|
||||
assertEquals(518400,frameBytes(480,270,480));
|
||||
assertThrows(IOException.class,()->frameBytes(640,360,641));
|
||||
assertEquals(921600,frameBytes(640,360,640));
|
||||
assertThrows(IOException.class,()->text(new byte[]{(byte)0xff},0));
|
||||
}
|
||||
@Test void rgbaPayloadMatchesSharedFixture() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user