Add targeted PPI payload automation
This commit is contained in:
@@ -486,6 +486,8 @@ void creates_minimal_project_with_dirty_face_payload(pp::tests::Harness& h)
|
||||
const auto png_payload = transparent_png_1x1();
|
||||
const pp::assets::PpiDirtyFacePayloadConfig dirty_faces[] {
|
||||
{
|
||||
.layer_index = 0,
|
||||
.frame_index = 0,
|
||||
.face_index = 2,
|
||||
.x = 4,
|
||||
.y = 5,
|
||||
@@ -520,11 +522,64 @@ void creates_minimal_project_with_dirty_face_payload(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, decoded.value().faces[0].image.pixels.size() == 4U);
|
||||
}
|
||||
|
||||
void creates_minimal_project_with_targeted_dirty_face_payloads(pp::tests::Harness& h)
|
||||
{
|
||||
const auto png_payload = transparent_png_1x1();
|
||||
const pp::assets::PpiDirtyFacePayloadConfig dirty_faces[] {
|
||||
{
|
||||
.layer_index = 0,
|
||||
.frame_index = 1,
|
||||
.face_index = 2,
|
||||
.x = 4,
|
||||
.y = 5,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.png_rgba8 = std::span<const std::byte>(png_payload.data(), png_payload.size()),
|
||||
},
|
||||
{
|
||||
.layer_index = 1,
|
||||
.frame_index = 0,
|
||||
.face_index = 2,
|
||||
.x = 6,
|
||||
.y = 7,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.png_rgba8 = std::span<const std::byte>(png_payload.data(), png_payload.size()),
|
||||
},
|
||||
};
|
||||
const auto project = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Payload",
|
||||
.layer_metadata = {},
|
||||
.layer_count = 2,
|
||||
.frame_count = 2,
|
||||
.frame_duration_ms = 333,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(dirty_faces, 2),
|
||||
});
|
||||
|
||||
PP_EXPECT(h, project.ok());
|
||||
const auto decoded = decode_ppi_project_images(project.value());
|
||||
PP_EXPECT(h, decoded.ok());
|
||||
PP_EXPECT(h, decoded.value().project.body.summary.dirty_face_count == 2U);
|
||||
PP_EXPECT(h, decoded.value().faces.size() == 2U);
|
||||
PP_EXPECT(h, decoded.value().faces[0].layer_index == 0U);
|
||||
PP_EXPECT(h, decoded.value().faces[0].frame_index == 1U);
|
||||
PP_EXPECT(h, decoded.value().faces[0].face_index == 2U);
|
||||
PP_EXPECT(h, decoded.value().faces[0].descriptor.x0 == 4U);
|
||||
PP_EXPECT(h, decoded.value().faces[1].layer_index == 1U);
|
||||
PP_EXPECT(h, decoded.value().faces[1].frame_index == 0U);
|
||||
PP_EXPECT(h, decoded.value().faces[1].face_index == 2U);
|
||||
PP_EXPECT(h, decoded.value().faces[1].descriptor.x0 == 6U);
|
||||
}
|
||||
|
||||
void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
{
|
||||
const auto png_payload = transparent_png_1x1();
|
||||
const pp::assets::PpiDirtyFacePayloadConfig duplicate_faces[] {
|
||||
{
|
||||
.layer_index = 0,
|
||||
.frame_index = 0,
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
@@ -533,6 +588,8 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.png_rgba8 = std::span<const std::byte>(png_payload.data(), png_payload.size()),
|
||||
},
|
||||
{
|
||||
.layer_index = 0,
|
||||
.frame_index = 0,
|
||||
.face_index = 0,
|
||||
.x = 1,
|
||||
.y = 1,
|
||||
@@ -541,6 +598,30 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.png_rgba8 = std::span<const std::byte>(png_payload.data(), png_payload.size()),
|
||||
},
|
||||
};
|
||||
const pp::assets::PpiDirtyFacePayloadConfig bad_layer_faces[] {
|
||||
{
|
||||
.layer_index = 1,
|
||||
.frame_index = 0,
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.png_rgba8 = std::span<const std::byte>(png_payload.data(), png_payload.size()),
|
||||
},
|
||||
};
|
||||
const pp::assets::PpiDirtyFacePayloadConfig bad_frame_faces[] {
|
||||
{
|
||||
.layer_index = 0,
|
||||
.frame_index = 1,
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.png_rgba8 = std::span<const std::byte>(png_payload.data(), png_payload.size()),
|
||||
},
|
||||
};
|
||||
const auto no_size = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 0,
|
||||
.height = 128,
|
||||
@@ -625,6 +706,26 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(duplicate_faces, 2),
|
||||
});
|
||||
const auto bad_layer_dirty_face = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.layer_metadata = {},
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(bad_layer_faces, 1),
|
||||
});
|
||||
const auto bad_frame_dirty_face = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.layer_metadata = {},
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(bad_frame_faces, 1),
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !no_size.ok());
|
||||
PP_EXPECT(h, no_size.status().code == StatusCode::invalid_argument);
|
||||
@@ -642,6 +743,10 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, bad_blend_mode.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !duplicate_dirty_face.ok());
|
||||
PP_EXPECT(h, duplicate_dirty_face.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !bad_layer_dirty_face.ok());
|
||||
PP_EXPECT(h, bad_layer_dirty_face.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_frame_dirty_face.ok());
|
||||
PP_EXPECT(h, bad_frame_dirty_face.status().code == StatusCode::out_of_range);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -665,6 +770,7 @@ int main()
|
||||
harness.run("creates_minimal_project_with_multiple_layers", creates_minimal_project_with_multiple_layers);
|
||||
harness.run("creates_minimal_project_with_multiple_frames", creates_minimal_project_with_multiple_frames);
|
||||
harness.run("creates_minimal_project_with_dirty_face_payload", creates_minimal_project_with_dirty_face_payload);
|
||||
harness.run("creates_minimal_project_with_targeted_dirty_face_payloads", creates_minimal_project_with_targeted_dirty_face_payloads);
|
||||
harness.run("rejects_invalid_minimal_project_writer_inputs", rejects_invalid_minimal_project_writer_inputs);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ execute_process(
|
||||
--frames 2
|
||||
--frame-duration-ms 321
|
||||
--include-test-face-payload
|
||||
--payload-layer 1
|
||||
--payload-frame 1
|
||||
RESULT_VARIABLE save_result
|
||||
OUTPUT_VARIABLE save_output
|
||||
ERROR_VARIABLE save_error)
|
||||
@@ -32,7 +34,14 @@ string(FIND "${save_output}" "\"command\":\"save-project\"" save_command_index)
|
||||
string(FIND "${save_output}" "\"layers\":2" save_layers_index)
|
||||
string(FIND "${save_output}" "\"frames\":2" save_frames_index)
|
||||
string(FIND "${save_output}" "\"facePayloads\":1" save_payload_index)
|
||||
if(save_command_index LESS 0 OR save_layers_index LESS 0 OR save_frames_index LESS 0 OR save_payload_index LESS 0)
|
||||
string(FIND "${save_output}" "\"payloadLayer\":1" save_payload_layer_index)
|
||||
string(FIND "${save_output}" "\"payloadFrame\":1" save_payload_frame_index)
|
||||
if(save_command_index LESS 0
|
||||
OR save_layers_index LESS 0
|
||||
OR save_frames_index LESS 0
|
||||
OR save_payload_index LESS 0
|
||||
OR save_payload_layer_index LESS 0
|
||||
OR save_payload_frame_index LESS 0)
|
||||
message(FATAL_ERROR "save-project payload output did not contain expected summary: ${save_output}")
|
||||
endif()
|
||||
|
||||
@@ -40,6 +49,21 @@ if(NOT EXISTS "${OUTPUT_PATH}")
|
||||
message(FATAL_ERROR "save-project did not create ${OUTPUT_PATH}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PANO_CLI}" inspect-project --path "${OUTPUT_PATH}"
|
||||
RESULT_VARIABLE inspect_result
|
||||
OUTPUT_VARIABLE inspect_output
|
||||
ERROR_VARIABLE inspect_error)
|
||||
|
||||
if(NOT inspect_result EQUAL 0)
|
||||
message(FATAL_ERROR "inspect-project failed after payload save-project: ${inspect_output}${inspect_error}")
|
||||
endif()
|
||||
|
||||
string(REGEX MATCH "\"index\":1,\"storedOrder\":1,\"name\":\"Payload 2\".*\"index\":1,\"durationMs\":321,\"dirtyFaces\":\\[\\{\"face\":0" inspect_targeted_payload "${inspect_output}")
|
||||
if(NOT inspect_targeted_payload)
|
||||
message(FATAL_ERROR "inspect-project output did not show the payload on layer 1 frame 1: ${inspect_output}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PANO_CLI}" load-project --path "${OUTPUT_PATH}"
|
||||
RESULT_VARIABLE load_result
|
||||
|
||||
Reference in New Issue
Block a user