packer (WIP)
This commit is contained in:
+4
-2
@@ -505,8 +505,10 @@ final class FileSystemPackerWorkspaceServiceTest {
|
||||
|
||||
final var manifest = MAPPER.readTree(projectRoot.resolve("assets/ui/atlas/asset.json").toFile());
|
||||
assertEquals(2, manifest.path("output").path("pipeline").path("palettes").size());
|
||||
assertEquals(0xFFFF0000, manifest.path("output").path("pipeline").path("palettes").get(0).path("originalArgb8888").get(0).asInt());
|
||||
assertEquals(0x001F, manifest.path("output").path("pipeline").path("palettes").get(1).path("convertedRgb565").get(0).asInt());
|
||||
assertEquals(0, manifest.path("output").path("pipeline").path("palettes").get(0).path("index").asInt());
|
||||
assertEquals(0xFFFF0000, manifest.path("output").path("pipeline").path("palettes").get(0).path("palette").path("originalArgb8888").get(0).asInt());
|
||||
assertEquals(1, manifest.path("output").path("pipeline").path("palettes").get(1).path("index").asInt());
|
||||
assertEquals(0x001F, manifest.path("output").path("pipeline").path("palettes").get(1).path("palette").path("convertedRgb565").get(0).asInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+77
@@ -91,6 +91,83 @@ final class PackerAssetDeclarationParserTest {
|
||||
assertTrue(result.diagnostics().stream().anyMatch(diagnostic -> diagnostic.message().contains("output.pipeline")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsesPaletteDeclarationsUsingExplicitIndexContract() throws Exception {
|
||||
final Path manifest = tempDir.resolve("asset.json");
|
||||
Files.writeString(manifest, """
|
||||
{
|
||||
"schema_version": 1,
|
||||
"asset_uuid": "uuid-palette-contract",
|
||||
"name": "palette_asset",
|
||||
"type": "tile_bank",
|
||||
"output": {
|
||||
"format": "TILES/indexed_v1",
|
||||
"codec": "NONE",
|
||||
"pipeline": {
|
||||
"palettes": [
|
||||
{
|
||||
"index": 1,
|
||||
"palette": {
|
||||
"originalArgb8888": [4294901760],
|
||||
"convertedRgb565": [63488]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"preload": { "enabled": true }
|
||||
}
|
||||
""");
|
||||
|
||||
final var result = parser.parse(manifest);
|
||||
|
||||
assertTrue(result.valid());
|
||||
assertTrue(result.declaration().outputPipelineMetadata().get("palettes").isArray());
|
||||
assertEquals(1, result.declaration().outputPipelineMetadata().get("palettes").get(0).path("index").asInt());
|
||||
assertEquals(63488, result.declaration().outputPipelineMetadata().get("palettes").get(0).path("palette").path("convertedRgb565").get(0).asInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsPaletteDeclarationsWithDuplicateIndices() throws Exception {
|
||||
final Path manifest = tempDir.resolve("asset.json");
|
||||
Files.writeString(manifest, """
|
||||
{
|
||||
"schema_version": 1,
|
||||
"asset_uuid": "uuid-palette-duplicate",
|
||||
"name": "palette_asset",
|
||||
"type": "tile_bank",
|
||||
"output": {
|
||||
"format": "TILES/indexed_v1",
|
||||
"codec": "NONE",
|
||||
"pipeline": {
|
||||
"palettes": [
|
||||
{
|
||||
"index": 0,
|
||||
"palette": {
|
||||
"originalArgb8888": [4294901760],
|
||||
"convertedRgb565": [63488]
|
||||
}
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"palette": {
|
||||
"originalArgb8888": [4278255360],
|
||||
"convertedRgb565": [2016]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"preload": { "enabled": true }
|
||||
}
|
||||
""");
|
||||
|
||||
final var result = parser.parse(manifest);
|
||||
|
||||
assertFalse(result.valid());
|
||||
assertTrue(result.diagnostics().stream().anyMatch(diagnostic -> diagnostic.message().contains("duplicate palette index 0")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMalformedJsonWithStructuralDiagnostic() {
|
||||
final var result = parser.parse(PackerFixtureLocator.fixtureRoot("workspaces/invalid-malformed/assets/bad/asset.json"));
|
||||
|
||||
+5
-2
@@ -63,9 +63,11 @@ final class PackerAssetDetailsServiceTest {
|
||||
final ObjectNode manifest = (ObjectNode) mapper.readTree(manifestPath.toFile());
|
||||
final ObjectNode pipeline = ((ObjectNode) manifest.path("output")).putObject("pipeline");
|
||||
final var palettes = pipeline.putArray("palettes");
|
||||
palettes.addObject()
|
||||
final ObjectNode declaration = palettes.addObject();
|
||||
declaration.put("index", 3);
|
||||
declaration.putObject("palette")
|
||||
.putArray("originalArgb8888").add(0xFFFF0000).add(0xFF00FF00);
|
||||
((ObjectNode) palettes.get(0))
|
||||
((ObjectNode) declaration.path("palette"))
|
||||
.putArray("convertedRgb565").add(0xF800).add(0x07E0);
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValue(manifestPath.toFile(), manifest);
|
||||
|
||||
@@ -73,6 +75,7 @@ final class PackerAssetDetailsServiceTest {
|
||||
final var result = service.getAssetDetails(new GetAssetDetailsRequest(project(projectRoot), AssetReference.forAssetId(1)));
|
||||
|
||||
assertEquals(1, result.details().pipelinePalettes().size());
|
||||
assertEquals(3, result.details().pipelinePalettes().getFirst().get("index"));
|
||||
assertEquals(
|
||||
List.of(0xFFFF0000, 0xFF00FF00),
|
||||
result.details().pipelinePalettes().getFirst().get("originalArgb8888"));
|
||||
|
||||
Reference in New Issue
Block a user