Route equirectangular export writes through app core
This commit is contained in:
@@ -155,6 +155,7 @@ public:
|
||||
class FakeDocumentCubeFaceExportWriteServices final
|
||||
: public pp::app::DocumentCubeFaceExportWriteServices
|
||||
, public pp::app::DocumentDepthExportWriteServices
|
||||
, public pp::app::DocumentExportFileWriteServices
|
||||
, public pp::app::DocumentExportCollectionWriteServices {
|
||||
public:
|
||||
pp::foundation::Status write_binary_file(
|
||||
@@ -461,6 +462,83 @@ void depth_export_writer_rejects_malformed_inputs(pp::tests::Harness& harness)
|
||||
PP_EXPECT(harness, services.publish_calls == 0);
|
||||
}
|
||||
|
||||
void file_export_writer_writes_and_publishes_target(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::make_document_export_file_target("D:/Paint", "demo", ".png");
|
||||
const std::array<std::byte, 4> bytes {};
|
||||
FakeDocumentCubeFaceExportWriteServices services;
|
||||
|
||||
PP_EXPECT(harness, target);
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_file_write(
|
||||
target.value(),
|
||||
pp::app::DocumentExportFilePayload {
|
||||
.bytes = std::span<const std::byte>(bytes),
|
||||
},
|
||||
services)
|
||||
.ok());
|
||||
PP_EXPECT(harness, services.write_calls == 1);
|
||||
PP_EXPECT(harness, services.publish_calls == 1);
|
||||
PP_EXPECT(harness, services.total_bytes == 4U);
|
||||
PP_EXPECT(harness, services.last_path == "D:/Paint/demo.png");
|
||||
PP_EXPECT(harness, services.last_published_path == "D:/Paint/demo.png");
|
||||
PP_EXPECT(harness, services.call_order == "write:D:/Paint/demo.png;publish:D:/Paint/demo.png;");
|
||||
}
|
||||
|
||||
void file_export_writer_stops_before_publish_on_write_failure(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::make_document_export_file_target("D:/Paint", "demo", ".jpg");
|
||||
const std::array<std::byte, 4> bytes {};
|
||||
FakeDocumentCubeFaceExportWriteServices services;
|
||||
services.fail_on_write_call = 1;
|
||||
|
||||
PP_EXPECT(harness, target);
|
||||
const auto status = pp::app::execute_document_export_file_write(
|
||||
target.value(),
|
||||
pp::app::DocumentExportFilePayload {
|
||||
.bytes = std::span<const std::byte>(bytes),
|
||||
},
|
||||
services);
|
||||
PP_EXPECT(harness, !status.ok());
|
||||
PP_EXPECT(harness, services.write_calls == 1);
|
||||
PP_EXPECT(harness, services.publish_calls == 0);
|
||||
PP_EXPECT(harness, services.call_order == "write:D:/Paint/demo.jpg;");
|
||||
}
|
||||
|
||||
void file_export_writer_rejects_malformed_inputs(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::make_document_export_file_target("D:/Paint", "demo", ".png");
|
||||
const std::array<std::byte, 4> bytes {};
|
||||
FakeDocumentCubeFaceExportWriteServices services;
|
||||
|
||||
PP_EXPECT(harness, target);
|
||||
auto empty_path = target.value();
|
||||
empty_path.path.clear();
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::execute_document_export_file_write(
|
||||
empty_path,
|
||||
pp::app::DocumentExportFilePayload {
|
||||
.bytes = std::span<const std::byte>(bytes),
|
||||
},
|
||||
services)
|
||||
.ok());
|
||||
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::execute_document_export_file_write(
|
||||
target.value(),
|
||||
pp::app::DocumentExportFilePayload {
|
||||
.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(
|
||||
@@ -1273,6 +1351,11 @@ int main()
|
||||
"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("file export writer writes and publishes target", file_export_writer_writes_and_publishes_target);
|
||||
harness.run(
|
||||
"file export writer stops before publish on write failure",
|
||||
file_export_writer_stops_before_publish_on_write_failure);
|
||||
harness.run("file export writer rejects malformed inputs", file_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",
|
||||
|
||||
Reference in New Issue
Block a user