Extract document resize planning
This commit is contained in:
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