Add multi-layer PPI save automation
This commit is contained in:
@@ -392,6 +392,7 @@ void creates_minimal_project_for_roundtrip_load(pp::tests::Harness& h)
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Roundtrip",
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 333,
|
||||
.dirty_faces = {},
|
||||
@@ -412,12 +413,42 @@ void creates_minimal_project_for_roundtrip_load(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[0].duration_ms == 333U);
|
||||
}
|
||||
|
||||
void creates_minimal_project_with_multiple_layers(pp::tests::Harness& h)
|
||||
{
|
||||
const auto project = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Layer",
|
||||
.layer_count = 2,
|
||||
.frame_count = 2,
|
||||
.frame_duration_ms = 111,
|
||||
.dirty_faces = {},
|
||||
});
|
||||
|
||||
PP_EXPECT(h, project.ok());
|
||||
const auto index = parse_ppi_project_index(project.value());
|
||||
PP_EXPECT(h, index.ok());
|
||||
PP_EXPECT(h, index.value().body.summary.layer_count == 2U);
|
||||
PP_EXPECT(h, index.value().body.summary.declared_frame_count == 4U);
|
||||
PP_EXPECT(h, index.value().body.summary.total_layer_frames == 4U);
|
||||
PP_EXPECT(h, index.value().body.layers.size() == 2U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].stored_order == 0U);
|
||||
PP_EXPECT(h, index.value().body.layers[1].stored_order == 1U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].name == "Layer 1");
|
||||
PP_EXPECT(h, index.value().body.layers[1].name == "Layer 2");
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames.size() == 2U);
|
||||
PP_EXPECT(h, index.value().body.layers[1].frames.size() == 2U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[1].duration_ms == 111U);
|
||||
PP_EXPECT(h, index.value().body.layers[1].frames[1].duration_ms == 111U);
|
||||
}
|
||||
|
||||
void creates_minimal_project_with_multiple_frames(pp::tests::Harness& h)
|
||||
{
|
||||
const auto project = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Frames",
|
||||
.layer_count = 1,
|
||||
.frame_count = 3,
|
||||
.frame_duration_ms = 111,
|
||||
.dirty_faces = {},
|
||||
@@ -451,6 +482,7 @@ void creates_minimal_project_with_dirty_face_payload(pp::tests::Harness& h)
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Payload",
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 333,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(dirty_faces, 1),
|
||||
@@ -496,6 +528,7 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.width = 0,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = {},
|
||||
@@ -504,6 +537,7 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "",
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = {},
|
||||
@@ -512,6 +546,7 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 0,
|
||||
.dirty_faces = {},
|
||||
@@ -520,14 +555,25 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.layer_count = 1,
|
||||
.frame_count = 0,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = {},
|
||||
});
|
||||
const auto no_layers = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.layer_count = 0,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = {},
|
||||
});
|
||||
const auto duplicate_dirty_face = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.layer_count = 1,
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(duplicate_faces, 2),
|
||||
@@ -541,6 +587,8 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, no_duration.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !no_frames.ok());
|
||||
PP_EXPECT(h, no_frames.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !no_layers.ok());
|
||||
PP_EXPECT(h, no_layers.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !duplicate_dirty_face.ok());
|
||||
PP_EXPECT(h, duplicate_dirty_face.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
@@ -563,6 +611,7 @@ int main()
|
||||
harness.run("rejects_invalid_dirty_face_png_payloads", rejects_invalid_dirty_face_png_payloads);
|
||||
harness.run("rejects_invalid_project_body_summaries", rejects_invalid_project_body_summaries);
|
||||
harness.run("creates_minimal_project_for_roundtrip_load", creates_minimal_project_for_roundtrip_load);
|
||||
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("rejects_invalid_minimal_project_writer_inputs", rejects_invalid_minimal_project_writer_inputs);
|
||||
|
||||
@@ -16,6 +16,7 @@ execute_process(
|
||||
--width 96
|
||||
--height 48
|
||||
--layer-name Payload
|
||||
--layers 2
|
||||
--frames 2
|
||||
--frame-duration-ms 321
|
||||
--include-test-face-payload
|
||||
@@ -28,8 +29,10 @@ if(NOT save_result EQUAL 0)
|
||||
endif()
|
||||
|
||||
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_payload_index LESS 0)
|
||||
if(save_command_index LESS 0 OR save_layers_index LESS 0 OR save_frames_index LESS 0 OR save_payload_index LESS 0)
|
||||
message(FATAL_ERROR "save-project payload output did not contain expected summary: ${save_output}")
|
||||
endif()
|
||||
|
||||
@@ -52,15 +55,17 @@ string(FIND "${load_output}" "\"pixelDataLoaded\":true" load_pixels_index)
|
||||
string(FIND "${load_output}" "\"facePayloads\":1" load_payload_index)
|
||||
string(FIND "${load_output}" "\"width\":96" load_width_index)
|
||||
string(FIND "${load_output}" "\"height\":48" load_height_index)
|
||||
string(FIND "${load_output}" "\"layers\":2" load_layers_index)
|
||||
string(FIND "${load_output}" "\"frames\":2" load_frames_index)
|
||||
string(FIND "${load_output}" "\"animationDurationMs\":642" load_duration_index)
|
||||
string(FIND "${load_output}" "\"layerNames\":[\"Payload\"]" load_layer_index)
|
||||
string(FIND "${load_output}" "\"layerFrameCounts\":[2]" load_layer_frames_index)
|
||||
string(FIND "${load_output}" "\"layerNames\":[\"Payload 1\",\"Payload 2\"]" load_layer_index)
|
||||
string(FIND "${load_output}" "\"layerFrameCounts\":[2,2]" load_layer_frames_index)
|
||||
if(load_command_index LESS 0
|
||||
OR load_pixels_index LESS 0
|
||||
OR load_payload_index LESS 0
|
||||
OR load_width_index LESS 0
|
||||
OR load_height_index LESS 0
|
||||
OR load_layers_index LESS 0
|
||||
OR load_frames_index LESS 0
|
||||
OR load_duration_index LESS 0
|
||||
OR load_layer_index LESS 0
|
||||
|
||||
@@ -16,6 +16,7 @@ execute_process(
|
||||
--width 96
|
||||
--height 48
|
||||
--layer-name Roundtrip
|
||||
--layers 2
|
||||
--frames 3
|
||||
--frame-duration-ms 321
|
||||
RESULT_VARIABLE save_result
|
||||
@@ -27,9 +28,10 @@ if(NOT save_result EQUAL 0)
|
||||
endif()
|
||||
|
||||
string(FIND "${save_output}" "\"command\":\"save-project\"" save_command_index)
|
||||
string(FIND "${save_output}" "\"bytes\":65711" save_bytes_index)
|
||||
string(FIND "${save_output}" "\"bytes\":65830" save_bytes_index)
|
||||
string(FIND "${save_output}" "\"layers\":2" save_layers_index)
|
||||
string(FIND "${save_output}" "\"frames\":3" save_frames_index)
|
||||
if(save_command_index LESS 0 OR save_bytes_index LESS 0 OR save_frames_index LESS 0)
|
||||
if(save_command_index LESS 0 OR save_bytes_index LESS 0 OR save_layers_index LESS 0 OR save_frames_index LESS 0)
|
||||
message(FATAL_ERROR "save-project output did not contain expected summary: ${save_output}")
|
||||
endif()
|
||||
|
||||
@@ -50,14 +52,16 @@ endif()
|
||||
string(FIND "${load_output}" "\"command\":\"load-project\"" load_command_index)
|
||||
string(FIND "${load_output}" "\"width\":96" load_width_index)
|
||||
string(FIND "${load_output}" "\"height\":48" load_height_index)
|
||||
string(FIND "${load_output}" "\"layers\":2" load_layers_index)
|
||||
string(FIND "${load_output}" "\"frames\":3" load_frames_index)
|
||||
string(FIND "${load_output}" "\"animationDurationMs\":963" load_duration_index)
|
||||
string(FIND "${load_output}" "\"layerNames\":[\"Roundtrip\"]" load_layer_index)
|
||||
string(FIND "${load_output}" "\"layerFrameCounts\":[3]" load_layer_frames_index)
|
||||
string(FIND "${load_output}" "\"layerDurationsMs\":[963]" load_layer_durations_index)
|
||||
string(FIND "${load_output}" "\"layerNames\":[\"Roundtrip 1\",\"Roundtrip 2\"]" load_layer_index)
|
||||
string(FIND "${load_output}" "\"layerFrameCounts\":[3,3]" load_layer_frames_index)
|
||||
string(FIND "${load_output}" "\"layerDurationsMs\":[963,963]" load_layer_durations_index)
|
||||
if(load_command_index LESS 0
|
||||
OR load_width_index LESS 0
|
||||
OR load_height_index LESS 0
|
||||
OR load_layers_index LESS 0
|
||||
OR load_frames_index LESS 0
|
||||
OR load_duration_index LESS 0
|
||||
OR load_layer_index LESS 0
|
||||
|
||||
Reference in New Issue
Block a user