Add multi-frame 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",
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 333,
|
||||
.dirty_faces = {},
|
||||
});
|
||||
@@ -411,6 +412,28 @@ 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_frames(pp::tests::Harness& h)
|
||||
{
|
||||
const auto project = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Frames",
|
||||
.frame_count = 3,
|
||||
.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.declared_frame_count == 3U);
|
||||
PP_EXPECT(h, index.value().body.summary.total_layer_frames == 3U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames.size() == 3U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[0].duration_ms == 111U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[1].duration_ms == 111U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[2].duration_ms == 111U);
|
||||
}
|
||||
|
||||
void creates_minimal_project_with_dirty_face_payload(pp::tests::Harness& h)
|
||||
{
|
||||
const auto png_payload = transparent_png_1x1();
|
||||
@@ -428,6 +451,7 @@ void creates_minimal_project_with_dirty_face_payload(pp::tests::Harness& h)
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Payload",
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 333,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(dirty_faces, 1),
|
||||
});
|
||||
@@ -472,6 +496,7 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.width = 0,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = {},
|
||||
});
|
||||
@@ -479,6 +504,7 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "",
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = {},
|
||||
});
|
||||
@@ -486,13 +512,23 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 0,
|
||||
.dirty_faces = {},
|
||||
});
|
||||
const auto no_frames = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.frame_count = 0,
|
||||
.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",
|
||||
.frame_count = 1,
|
||||
.frame_duration_ms = 100,
|
||||
.dirty_faces = std::span<const pp::assets::PpiDirtyFacePayloadConfig>(duplicate_faces, 2),
|
||||
});
|
||||
@@ -503,6 +539,8 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, no_name.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !no_duration.ok());
|
||||
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, !duplicate_dirty_face.ok());
|
||||
PP_EXPECT(h, duplicate_dirty_face.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
@@ -525,6 +563,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_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);
|
||||
return harness.finish();
|
||||
|
||||
Reference in New Issue
Block a user