Add metadata-only PPI save automation
This commit is contained in:
@@ -283,6 +283,14 @@ if(TARGET pano_cli)
|
||||
LABELS "assets;document;integration;desktop-fast"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"load-project\".*\"pixelDataLoaded\":false.*\"facePayloads\":0.*\"document\":\\{\"width\":64,\"height\":32,\"layers\":1,\"frames\":1,\"animationDurationMs\":100,\"layerNames\":\\[\"Ink\"\\],\"layerFrameCounts\":\\[1\\],\"layerDurationsMs\":\\[100\\]")
|
||||
|
||||
add_test(NAME pano_cli_save_project_roundtrip_smoke
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-DPANO_CLI=$<TARGET_FILE:pano_cli>
|
||||
-DOUTPUT_PATH=${CMAKE_CURRENT_BINARY_DIR}/data/generated/roundtrip.ppi
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pano_cli_save_project_roundtrip.cmake")
|
||||
set_tests_properties(pano_cli_save_project_roundtrip_smoke PROPERTIES
|
||||
LABELS "assets;document;integration;desktop-fast")
|
||||
|
||||
add_test(NAME pano_cli_parse_layout_smoke
|
||||
COMMAND pano_cli parse-layout --path "${CMAKE_CURRENT_SOURCE_DIR}/data/layouts/simple-layout.xml")
|
||||
set_tests_properties(pano_cli_parse_layout_smoke PROPERTIES
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
using pp::assets::parse_ppi_header;
|
||||
using pp::assets::create_minimal_ppi_project;
|
||||
using pp::assets::decode_ppi_project_images;
|
||||
using pp::assets::parse_ppi_project_index;
|
||||
using pp::assets::parse_ppi_project_summary;
|
||||
@@ -384,6 +385,59 @@ void rejects_invalid_project_body_summaries(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, bad_layer_name_result.status().code == StatusCode::out_of_range);
|
||||
}
|
||||
|
||||
void creates_minimal_project_for_roundtrip_load(pp::tests::Harness& h)
|
||||
{
|
||||
const auto project = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layer_name = "Roundtrip",
|
||||
.frame_duration_ms = 333,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, project.ok());
|
||||
const auto index = parse_ppi_project_index(project.value());
|
||||
PP_EXPECT(h, index.ok());
|
||||
PP_EXPECT(h, index.value().layout.thumbnail_bytes == 128U * 128U * 4U);
|
||||
PP_EXPECT(h, index.value().body.summary.width == 256U);
|
||||
PP_EXPECT(h, index.value().body.summary.height == 128U);
|
||||
PP_EXPECT(h, index.value().body.summary.layer_count == 1U);
|
||||
PP_EXPECT(h, index.value().body.summary.declared_frame_count == 1U);
|
||||
PP_EXPECT(h, index.value().body.summary.dirty_face_count == 0U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].name == "Roundtrip");
|
||||
PP_EXPECT(h, index.value().body.layers[0].opacity == 1.0F);
|
||||
PP_EXPECT(h, index.value().body.layers[0].visible);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[0].duration_ms == 333U);
|
||||
}
|
||||
|
||||
void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
{
|
||||
const auto no_size = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 0,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.frame_duration_ms = 100,
|
||||
});
|
||||
const auto no_name = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "",
|
||||
.frame_duration_ms = 100,
|
||||
});
|
||||
const auto no_duration = create_minimal_ppi_project(pp::assets::PpiMinimalProjectConfig {
|
||||
.width = 128,
|
||||
.height = 128,
|
||||
.layer_name = "Ink",
|
||||
.frame_duration_ms = 0,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !no_size.ok());
|
||||
PP_EXPECT(h, no_size.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !no_name.ok());
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -401,5 +455,7 @@ int main()
|
||||
harness.run("rejects_metadata_only_payload_when_decoding_pixels", rejects_metadata_only_payload_when_decoding_pixels);
|
||||
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("rejects_invalid_minimal_project_writer_inputs", rejects_invalid_minimal_project_writer_inputs);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
59
tests/cmake/pano_cli_save_project_roundtrip.cmake
Normal file
59
tests/cmake/pano_cli_save_project_roundtrip.cmake
Normal file
@@ -0,0 +1,59 @@
|
||||
if(NOT DEFINED PANO_CLI)
|
||||
message(FATAL_ERROR "PANO_CLI must be set")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED OUTPUT_PATH)
|
||||
message(FATAL_ERROR "OUTPUT_PATH must be set")
|
||||
endif()
|
||||
|
||||
get_filename_component(output_dir "${OUTPUT_PATH}" DIRECTORY)
|
||||
file(MAKE_DIRECTORY "${output_dir}")
|
||||
file(REMOVE "${OUTPUT_PATH}")
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PANO_CLI}" save-project
|
||||
--path "${OUTPUT_PATH}"
|
||||
--width 96
|
||||
--height 48
|
||||
--layer-name Roundtrip
|
||||
--frame-duration-ms 321
|
||||
RESULT_VARIABLE save_result
|
||||
OUTPUT_VARIABLE save_output
|
||||
ERROR_VARIABLE save_error)
|
||||
|
||||
if(NOT save_result EQUAL 0)
|
||||
message(FATAL_ERROR "save-project failed: ${save_output}${save_error}")
|
||||
endif()
|
||||
|
||||
string(FIND "${save_output}" "\"command\":\"save-project\"" save_command_index)
|
||||
string(FIND "${save_output}" "\"bytes\":65655" save_bytes_index)
|
||||
if(save_command_index LESS 0 OR save_bytes_index LESS 0)
|
||||
message(FATAL_ERROR "save-project output did not contain expected summary: ${save_output}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${OUTPUT_PATH}")
|
||||
message(FATAL_ERROR "save-project did not create ${OUTPUT_PATH}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PANO_CLI}" load-project --path "${OUTPUT_PATH}"
|
||||
RESULT_VARIABLE load_result
|
||||
OUTPUT_VARIABLE load_output
|
||||
ERROR_VARIABLE load_error)
|
||||
|
||||
if(NOT load_result EQUAL 0)
|
||||
message(FATAL_ERROR "load-project failed after save-project: ${load_output}${load_error}")
|
||||
endif()
|
||||
|
||||
string(FIND "${load_output}" "\"command\":\"load-project\"" load_command_index)
|
||||
string(FIND "${load_output}" "\"width\":96" load_width_index)
|
||||
string(FIND "${load_output}" "\"height\":48" load_height_index)
|
||||
string(FIND "${load_output}" "\"animationDurationMs\":321" load_duration_index)
|
||||
string(FIND "${load_output}" "\"layerNames\":[\"Roundtrip\"]" load_layer_index)
|
||||
if(load_command_index LESS 0
|
||||
OR load_width_index LESS 0
|
||||
OR load_height_index LESS 0
|
||||
OR load_duration_index LESS 0
|
||||
OR load_layer_index LESS 0)
|
||||
message(FATAL_ERROR "load-project output did not contain expected round-trip summary: ${load_output}")
|
||||
endif()
|
||||
Reference in New Issue
Block a user