implements PLN-0091
JaCoCo Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 61.08% (17147/28073) * Branch Coverage: 51.93% (6599/12707) * Lines of Code: 28073 * Cyclomatic Complexity: 11234 #### Quality Gates Summary Output truncated.
Test / Build skipped: 15, passed: 583
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good

This commit is contained in:
2026-07-14 16:33:59 +01:00
parent ffa41db994
commit ae1ba0d2d3
4 changed files with 107 additions and 11 deletions
@@ -338,8 +338,10 @@ final class FileSystemPackerWorkspaceServiceTest {
assertEquals(16, assetTable.get(0).path("metadata").path("tile_size").asInt());
assertEquals(256, assetTable.get(0).path("metadata").path("width").asInt());
assertEquals(256, assetTable.get(0).path("metadata").path("height").asInt());
assertEquals(64, assetTable.get(0).path("metadata").path("palette_count").asInt());
assertEquals(1, assetTable.get(0).path("metadata").path("palette_count").asInt());
assertEquals(1, assetTable.get(0).path("metadata").path("palette_authored").asInt());
assertEquals(32768 + 64, assetTable.get(0).path("size").asInt());
assertEquals(65536 + 64, assetTable.get(0).path("decoded_size").asInt());
assertTrue(assetTable.get(0).path("metadata").path("pipeline").isMissingNode());
final var preload = MAPPER.readTree(projectRoot.resolve("build/preload.json").toFile());
@@ -354,6 +356,53 @@ final class FileSystemPackerWorkspaceServiceTest {
assertEquals(0, assetTableMetadata.get(0).path("metadata").path("pipeline").path("palettes").get(0).path("index").asInt());
}
@Test
void packWorkspaceEmitsIntermediateGlyphPaletteCountWithoutRemappingPaletteIdentity() throws Exception {
final Path projectRoot = copyFixture("workspaces/managed-basic", tempDir.resolve("pack-workspace-palette-count-7"));
final Path assetRoot = projectRoot.resolve("assets/ui/atlas");
final Path manifestPath = assetRoot.resolve("asset.json");
writeTilePng(assetRoot.resolve("confirm.png"), 16);
final ObjectNode manifest = (ObjectNode) MAPPER.readTree(manifestPath.toFile());
final ObjectNode output = (ObjectNode) manifest.path("output");
output.putObject("metadata").put("tile_size", "16x16");
final ObjectNode pipeline = output.putObject("pipeline");
final var palettes = pipeline.putArray("palettes");
final ObjectNode palette = palettes.addObject();
palette.put("index", 6);
palette.putObject("palette")
.putArray("rgba8888").add(0xFF0000FF);
final var artifacts = manifest.putArray("artifacts");
artifacts.addObject().put("file", "confirm.png").put("index", 0);
MAPPER.writerWithDefaultPrettyPrinter().writeValue(manifestPath.toFile(), manifest);
final FileSystemPackerWorkspaceService service = service();
final var result = service.packWorkspace(new PackWorkspaceRequest(project(projectRoot)));
assertEquals(PackerOperationStatus.SUCCESS, result.status());
final byte[] assetsPa = Files.readAllBytes(projectRoot.resolve("build/assets.pa"));
final var assetTable = MAPPER.readTree(projectRoot.resolve("build/asset_table.json").toFile());
assertEquals(7, assetTable.get(0).path("metadata").path("palette_count").asInt());
assertEquals(1, assetTable.get(0).path("metadata").path("palette_authored").asInt());
assertEquals(32768 + (7 * 16 * 4), assetTable.get(0).path("size").asInt());
assertEquals(65536 + (7 * 16 * 4), assetTable.get(0).path("decoded_size").asInt());
final int payloadOffset = (int) readLeLong(assetsPa, 12);
final int assetOffset = assetTable.get(0).path("offset").asInt();
final int packedPixelBytes = (assetTable.get(0).path("metadata").path("width").asInt()
* assetTable.get(0).path("metadata").path("height").asInt()) / 2;
final int paletteStart = payloadOffset + assetOffset + packedPixelBytes;
final int paletteSixStart = paletteStart + (6 * 16 * 4);
assertEquals(0x00, assetsPa[paletteStart] & 0xFF);
assertEquals(0x00, assetsPa[paletteStart + 1] & 0xFF);
assertEquals(0x00, assetsPa[paletteStart + 2] & 0xFF);
assertEquals(0x00, assetsPa[paletteStart + 3] & 0xFF);
assertEquals(0xFF, assetsPa[paletteSixStart] & 0xFF);
assertEquals(0x00, assetsPa[paletteSixStart + 1] & 0xFF);
assertEquals(0x00, assetsPa[paletteSixStart + 2] & 0xFF);
assertEquals(0xFF, assetsPa[paletteSixStart + 3] & 0xFF);
}
@Test
void packWorkspaceRemapsGlyphTileIndicesUsingGlyphMaterialSchema() throws Exception {
final Path projectRoot = copyFixture("workspaces/managed-basic", tempDir.resolve("pack-workspace-remap-material"));
@@ -215,6 +215,39 @@ final class PackerAssetDeclarationParserTest {
assertTrue(result.diagnostics().stream().anyMatch(diagnostic -> diagnostic.message().contains("duplicate palette index 0")));
}
@Test
void rejectsPaletteDeclarationIndexAboveV1Maximum() throws Exception {
final Path manifest = tempDir.resolve("asset.json");
Files.writeString(manifest, """
{
"schema_version": 1,
"asset_uuid": "uuid-palette-too-high",
"name": "palette_asset",
"type": "glyph_bank",
"output": {
"format": "GLYPH/indexed_v1",
"codec": "NONE",
"pipeline": {
"palettes": [
{
"index": 64,
"palette": {
"rgba8888": [-16776961]
}
}
]
}
},
"preload": { "enabled": true }
}
""");
final var result = parser.parse(manifest);
assertFalse(result.valid());
assertTrue(result.diagnostics().stream().anyMatch(diagnostic -> diagnostic.message().contains("maximum supported index is 63")));
}
@Test
void rejectsMalformedJsonWithStructuralDiagnostic() {
final var result = parser.parse(PackerFixtureLocator.fixtureRoot("workspaces/invalid-malformed/assets/bad/asset.json"));