Plan depth export through document renderer

This commit is contained in:
2026-06-05 21:03:27 +02:00
parent 3c36be4b43
commit 3be7171010
10 changed files with 443 additions and 14 deletions

View File

@@ -154,6 +154,7 @@ public:
class FakeDocumentCubeFaceExportWriteServices final
: public pp::app::DocumentCubeFaceExportWriteServices
, public pp::app::DocumentDepthExportWriteServices
, public pp::app::DocumentExportCollectionWriteServices {
public:
pp::foundation::Status write_binary_file(
@@ -266,6 +267,26 @@ void cube_face_export_rejects_invalid_target_inputs(pp::tests::Harness& harness)
PP_EXPECT(harness, missing_name.status().code == pp::foundation::StatusCode::invalid_argument);
}
void depth_export_builds_legacy_work_paths(pp::tests::Harness& harness)
{
const auto target = pp::app::make_document_depth_export_target("D:/Paint", "demo");
PP_EXPECT(harness, target);
PP_EXPECT(harness, target.value().image_path == "D:/Paint/demo.png");
PP_EXPECT(harness, target.value().depth_path == "D:/Paint/demo_depth.png");
}
void depth_export_rejects_invalid_target_inputs(pp::tests::Harness& harness)
{
const auto missing_work_directory = pp::app::make_document_depth_export_target("", "demo");
const auto missing_name = pp::app::make_document_depth_export_target("D:/Paint", "");
PP_EXPECT(harness, !missing_work_directory);
PP_EXPECT(harness, missing_work_directory.status().code == pp::foundation::StatusCode::invalid_argument);
PP_EXPECT(harness, !missing_name);
PP_EXPECT(harness, missing_name.status().code == pp::foundation::StatusCode::invalid_argument);
}
void cube_face_export_writer_writes_and_publishes_faces_in_order(pp::tests::Harness& harness)
{
const auto target = pp::app::make_document_cube_face_export_target("D:/Paint", "demo");
@@ -349,6 +370,97 @@ void cube_face_export_writer_rejects_malformed_inputs(pp::tests::Harness& harnes
PP_EXPECT(harness, services.publish_calls == 0);
}
void depth_export_writer_writes_and_publishes_image_then_depth(pp::tests::Harness& harness)
{
const auto target = pp::app::make_document_depth_export_target("D:/Paint", "demo");
const std::array<std::byte, 2> image_bytes {};
const std::array<std::byte, 3> depth_bytes {};
FakeDocumentCubeFaceExportWriteServices services;
PP_EXPECT(harness, target);
PP_EXPECT(
harness,
pp::app::execute_document_depth_export_write(
target.value(),
pp::app::DocumentDepthExportPayload {
.image_bytes = std::span<const std::byte>(image_bytes),
.depth_bytes = std::span<const std::byte>(depth_bytes),
},
services)
.ok());
PP_EXPECT(harness, services.write_calls == 2);
PP_EXPECT(harness, services.publish_calls == 2);
PP_EXPECT(harness, services.total_bytes == 5U);
PP_EXPECT(harness, services.last_path == "D:/Paint/demo_depth.png");
PP_EXPECT(
harness,
services.call_order
== "write:D:/Paint/demo.png;publish:D:/Paint/demo.png;"
"write:D:/Paint/demo_depth.png;publish:D:/Paint/demo_depth.png;");
}
void depth_export_writer_stops_before_depth_publish_on_write_failure(pp::tests::Harness& harness)
{
const auto target = pp::app::make_document_depth_export_target("D:/Paint", "demo");
const std::array<std::byte, 2> image_bytes {};
const std::array<std::byte, 3> depth_bytes {};
FakeDocumentCubeFaceExportWriteServices services;
services.fail_on_write_call = 2;
PP_EXPECT(harness, target);
const auto status = pp::app::execute_document_depth_export_write(
target.value(),
pp::app::DocumentDepthExportPayload {
.image_bytes = std::span<const std::byte>(image_bytes),
.depth_bytes = std::span<const std::byte>(depth_bytes),
},
services);
PP_EXPECT(harness, !status.ok());
PP_EXPECT(harness, services.write_calls == 2);
PP_EXPECT(harness, services.publish_calls == 1);
PP_EXPECT(
harness,
services.call_order
== "write:D:/Paint/demo.png;publish:D:/Paint/demo.png;"
"write:D:/Paint/demo_depth.png;");
}
void depth_export_writer_rejects_malformed_inputs(pp::tests::Harness& harness)
{
const auto target = pp::app::make_document_depth_export_target("D:/Paint", "demo");
const std::array<std::byte, 2> image_bytes {};
const std::array<std::byte, 3> depth_bytes {};
FakeDocumentCubeFaceExportWriteServices services;
PP_EXPECT(harness, target);
auto empty_image_path = target.value();
empty_image_path.image_path.clear();
PP_EXPECT(
harness,
!pp::app::execute_document_depth_export_write(
empty_image_path,
pp::app::DocumentDepthExportPayload {
.image_bytes = std::span<const std::byte>(image_bytes),
.depth_bytes = std::span<const std::byte>(depth_bytes),
},
services)
.ok());
PP_EXPECT(
harness,
!pp::app::execute_document_depth_export_write(
target.value(),
pp::app::DocumentDepthExportPayload {
.image_bytes = {},
.depth_bytes = std::span<const std::byte>(depth_bytes),
},
services)
.ok());
PP_EXPECT(harness, services.write_calls == 0);
PP_EXPECT(harness, services.publish_calls == 0);
}
void collection_export_builds_legacy_path_suffixes(pp::tests::Harness& harness)
{
PP_EXPECT(
@@ -976,6 +1088,8 @@ int main()
harness.run("picked directory export builds stem", picked_directory_export_builds_stem);
harness.run("cube face export builds legacy work paths", cube_face_export_builds_legacy_work_paths);
harness.run("cube face export rejects invalid target inputs", cube_face_export_rejects_invalid_target_inputs);
harness.run("depth export builds legacy work paths", depth_export_builds_legacy_work_paths);
harness.run("depth export rejects invalid target inputs", depth_export_rejects_invalid_target_inputs);
harness.run(
"cube face export writer writes and publishes faces in order",
cube_face_export_writer_writes_and_publishes_faces_in_order);
@@ -983,6 +1097,13 @@ int main()
"cube face export writer stops before publish on write failure",
cube_face_export_writer_stops_before_publish_on_write_failure);
harness.run("cube face export writer rejects malformed inputs", cube_face_export_writer_rejects_malformed_inputs);
harness.run(
"depth export writer writes and publishes image then depth",
depth_export_writer_writes_and_publishes_image_then_depth);
harness.run(
"depth export writer stops before depth publish on write failure",
depth_export_writer_stops_before_depth_publish_on_write_failure);
harness.run("depth export writer rejects malformed inputs", depth_export_writer_rejects_malformed_inputs);
harness.run("collection export builds legacy path suffixes", collection_export_builds_legacy_path_suffixes);
harness.run(
"collection export writer writes and publishes payloads in order",