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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user