Export layer collections through paint renderer
This commit is contained in:
@@ -152,7 +152,9 @@ public:
|
||||
std::string call_order;
|
||||
};
|
||||
|
||||
class FakeDocumentCubeFaceExportWriteServices final : public pp::app::DocumentCubeFaceExportWriteServices {
|
||||
class FakeDocumentCubeFaceExportWriteServices final
|
||||
: public pp::app::DocumentCubeFaceExportWriteServices
|
||||
, public pp::app::DocumentExportCollectionWriteServices {
|
||||
public:
|
||||
pp::foundation::Status write_binary_file(
|
||||
std::string_view path,
|
||||
@@ -347,6 +349,96 @@ void cube_face_export_writer_rejects_malformed_inputs(pp::tests::Harness& harnes
|
||||
PP_EXPECT(harness, services.publish_calls == 0);
|
||||
}
|
||||
|
||||
void collection_export_builds_legacy_path_suffixes(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::make_document_layer_export_path_suffix(0, "Base") == "-layer00-Base.png");
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::make_document_layer_export_path_suffix(12, "Paint") == "-layer12-Paint.png");
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::make_document_animation_frame_export_path_suffix(0) == "-00.png");
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::make_document_animation_frame_export_path_suffix(125) == "-125.png");
|
||||
}
|
||||
|
||||
void collection_export_writer_writes_and_publishes_payloads_in_order(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::make_document_export_collection_target("D:/Paint", "demo", "_layers");
|
||||
const std::array<std::byte, 2> base_bytes {};
|
||||
const std::array<std::byte, 3> paint_bytes {};
|
||||
const pp::app::DocumentExportCollectionPngPayload payloads[] {
|
||||
{
|
||||
.path_suffix = pp::app::make_document_layer_export_path_suffix(0, "Base"),
|
||||
.bytes = std::span<const std::byte>(base_bytes),
|
||||
},
|
||||
{
|
||||
.path_suffix = pp::app::make_document_layer_export_path_suffix(1, "Paint"),
|
||||
.bytes = std::span<const std::byte>(paint_bytes),
|
||||
},
|
||||
};
|
||||
FakeDocumentCubeFaceExportWriteServices services;
|
||||
|
||||
PP_EXPECT(harness, target);
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_collection_write(target.value(), payloads, 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_layers/demo-layer01-Paint.png");
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
services.call_order
|
||||
== "write:D:/Paint/demo_layers/demo-layer00-Base.png;"
|
||||
"publish:D:/Paint/demo_layers/demo-layer00-Base.png;"
|
||||
"write:D:/Paint/demo_layers/demo-layer01-Paint.png;"
|
||||
"publish:D:/Paint/demo_layers/demo-layer01-Paint.png;");
|
||||
}
|
||||
|
||||
void collection_export_writer_rejects_malformed_inputs(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::make_document_export_collection_target("D:/Paint", "demo", "_frames");
|
||||
const std::array<std::byte, 2> bytes {};
|
||||
pp::app::DocumentExportCollectionPngPayload payloads[] {
|
||||
{
|
||||
.path_suffix = pp::app::make_document_animation_frame_export_path_suffix(0),
|
||||
.bytes = std::span<const std::byte>(bytes),
|
||||
},
|
||||
};
|
||||
FakeDocumentCubeFaceExportWriteServices services;
|
||||
|
||||
PP_EXPECT(harness, target);
|
||||
auto empty_stem = target.value();
|
||||
empty_stem.stem_path.clear();
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::execute_document_export_collection_write(empty_stem, payloads, services).ok());
|
||||
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::execute_document_export_collection_write(
|
||||
target.value(),
|
||||
std::span<const pp::app::DocumentExportCollectionPngPayload>(),
|
||||
services)
|
||||
.ok());
|
||||
|
||||
payloads[0].path_suffix.clear();
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::execute_document_export_collection_write(target.value(), payloads, services).ok());
|
||||
payloads[0].path_suffix = pp::app::make_document_animation_frame_export_path_suffix(0);
|
||||
payloads[0].bytes = {};
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::execute_document_export_collection_write(target.value(), payloads, services).ok());
|
||||
PP_EXPECT(harness, services.write_calls == 0);
|
||||
PP_EXPECT(harness, services.publish_calls == 0);
|
||||
}
|
||||
|
||||
void video_export_builds_suggested_name(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto timelapse = pp::app::make_document_export_suggested_name("demo", "-timelapse");
|
||||
@@ -891,6 +983,11 @@ 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("collection export builds legacy path suffixes", collection_export_builds_legacy_path_suffixes);
|
||||
harness.run(
|
||||
"collection export writer writes and publishes payloads in order",
|
||||
collection_export_writer_writes_and_publishes_payloads_in_order);
|
||||
harness.run("collection export writer rejects malformed inputs", collection_export_writer_rejects_malformed_inputs);
|
||||
harness.run("video export builds suggested name", video_export_builds_suggested_name);
|
||||
harness.run("collection export target plan selects platform destination", collection_export_target_plan_selects_platform_destination);
|
||||
harness.run("export success dialog plans image destinations", export_success_dialog_plans_image_destinations);
|
||||
|
||||
Reference in New Issue
Block a user