Extract document resize planning
This commit is contained in:
@@ -318,6 +318,16 @@ add_test(NAME pp_app_core_document_recording_tests COMMAND pp_app_core_document_
|
||||
set_tests_properties(pp_app_core_document_recording_tests PROPERTIES
|
||||
LABELS "app;desktop-fast;fuzz")
|
||||
|
||||
add_executable(pp_app_core_document_resize_tests
|
||||
app_core/document_resize_tests.cpp)
|
||||
target_link_libraries(pp_app_core_document_resize_tests PRIVATE
|
||||
pp_app_core
|
||||
pp_test_harness)
|
||||
|
||||
add_test(NAME pp_app_core_document_resize_tests COMMAND pp_app_core_document_resize_tests)
|
||||
set_tests_properties(pp_app_core_document_resize_tests PROPERTIES
|
||||
LABELS "app;desktop-fast;fuzz")
|
||||
|
||||
add_executable(pp_app_core_app_preferences_tests
|
||||
app_core/app_preferences_tests.cpp)
|
||||
target_link_libraries(pp_app_core_app_preferences_tests PRIVATE
|
||||
@@ -668,6 +678,18 @@ if(TARGET pano_cli)
|
||||
LABELS "app;integration;desktop-fast;fuzz"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-app-status\".*\"title\":\"Panodoc: demo \\(unknown\\)\".*\"recording\":\\{\"visible\":false,\"text\":\"\"\\}.*\"fromIndexValid\":false.*\"toIndexValid\":false.*\"labelValid\":false.*\"label\":\"\"")
|
||||
|
||||
add_test(NAME pano_cli_plan_document_resize_smoke
|
||||
COMMAND pano_cli plan-document-resize --current-resolution 2048 --selected-resolution-index 4)
|
||||
set_tests_properties(pano_cli_plan_document_resize_smoke PROPERTIES
|
||||
LABELS "app;integration;desktop-fast"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-document-resize\".*\"currentResolutionText\":\"Current: 8K\".*\"currentResolutionIndex\":3.*\"selectedResolutionIndex\":4.*\"resolution\":4096.*\"width\":4096.*\"height\":4096.*\"clearsHistory\":true")
|
||||
|
||||
add_test(NAME pano_cli_plan_document_resize_rejects_invalid_selection
|
||||
COMMAND pano_cli plan-document-resize --current-resolution 2048 --selected-resolution-index 9)
|
||||
set_tests_properties(pano_cli_plan_document_resize_rejects_invalid_selection PROPERTIES
|
||||
LABELS "app;integration;desktop-fast;fuzz"
|
||||
WILL_FAIL TRUE)
|
||||
|
||||
add_test(NAME pano_cli_plan_share_file_unsaved_smoke
|
||||
COMMAND pano_cli plan-share-file)
|
||||
set_tests_properties(pano_cli_plan_share_file_unsaved_smoke PROPERTIES
|
||||
|
||||
50
tests/app_core/document_resize_tests.cpp
Normal file
50
tests/app_core/document_resize_tests.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "app_core/document_resize.h"
|
||||
#include "test_harness.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void dialog_state_labels_current_resolution(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto state = pp::app::make_document_resize_dialog_state(2048);
|
||||
PP_EXPECT(harness, state.current_resolution == 2048);
|
||||
PP_EXPECT(harness, state.current_resolution_text == "Current: 8K");
|
||||
PP_EXPECT(harness, state.current_resolution_index == 3);
|
||||
}
|
||||
|
||||
void dialog_state_survives_unknown_resolution(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto state = pp::app::make_document_resize_dialog_state(1234);
|
||||
PP_EXPECT(harness, state.current_resolution == 1234);
|
||||
PP_EXPECT(harness, state.current_resolution_text == "Current: unknown");
|
||||
PP_EXPECT(harness, state.current_resolution_index == 6);
|
||||
}
|
||||
|
||||
void resize_plan_maps_selection_to_square_canvas(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto plan = pp::app::plan_document_resize(4);
|
||||
PP_EXPECT(harness, plan);
|
||||
if (plan) {
|
||||
PP_EXPECT(harness, plan.value().resolution == 4096);
|
||||
PP_EXPECT(harness, plan.value().width == 4096);
|
||||
PP_EXPECT(harness, plan.value().height == 4096);
|
||||
PP_EXPECT(harness, plan.value().clears_history);
|
||||
}
|
||||
}
|
||||
|
||||
void resize_plan_rejects_invalid_selection(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(harness, !pp::app::plan_document_resize(-1));
|
||||
PP_EXPECT(harness, !pp::app::plan_document_resize(6));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
pp::tests::Harness harness;
|
||||
harness.run("dialog state labels current resolution", dialog_state_labels_current_resolution);
|
||||
harness.run("dialog state survives unknown resolution", dialog_state_survives_unknown_resolution);
|
||||
harness.run("resize plan maps selection to square canvas", resize_plan_maps_selection_to_square_canvas);
|
||||
harness.run("resize plan rejects invalid selection", resize_plan_rejects_invalid_selection);
|
||||
return harness.finish();
|
||||
}
|
||||
Reference in New Issue
Block a user