Make document session history effects explicit
This commit is contained in:
@@ -203,6 +203,22 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
void expect_history_clear(pp::tests::Harness& harness, const pp::app::HistoryUiPlan& plan)
|
||||
{
|
||||
PP_EXPECT(harness, plan.operation == pp::app::HistoryUiOperation::clear);
|
||||
PP_EXPECT(harness, plan.clears_history);
|
||||
PP_EXPECT(harness, plan.updates_memory_label);
|
||||
PP_EXPECT(harness, !plan.no_op);
|
||||
}
|
||||
|
||||
void expect_history_no_op(pp::tests::Harness& harness, const pp::app::HistoryUiPlan& plan)
|
||||
{
|
||||
PP_EXPECT(harness, plan.operation == pp::app::HistoryUiOperation::clear);
|
||||
PP_EXPECT(harness, !plan.clears_history);
|
||||
PP_EXPECT(harness, !plan.updates_memory_label);
|
||||
PP_EXPECT(harness, plan.no_op);
|
||||
}
|
||||
|
||||
void project_open_clean_document_executes_immediately(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(harness, pp::app::plan_project_open(false) == pp::app::ProjectOpenDecision::open_now);
|
||||
@@ -319,6 +335,13 @@ void document_open_executor_rejects_mismatched_routes(pp::tests::Harness& harnes
|
||||
PP_EXPECT(harness, services.call_order.empty());
|
||||
}
|
||||
|
||||
void document_open_history_clears_only_for_projects(pp::tests::Harness& harness)
|
||||
{
|
||||
expect_history_clear(harness, pp::app::plan_document_open_history(project_route()));
|
||||
expect_history_no_op(harness, pp::app::plan_document_open_history(abr_route()));
|
||||
expect_history_no_op(harness, pp::app::plan_document_open_history(ppbr_route()));
|
||||
}
|
||||
|
||||
void close_clean_document_executes_immediately(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(
|
||||
@@ -526,6 +549,53 @@ void workflow_executor_dispatches_continue_prompt_and_unavailable(pp::tests::Har
|
||||
PP_EXPECT(harness, services.call_order == "continue;prompt-save;");
|
||||
}
|
||||
|
||||
void document_session_history_effects_stay_explicit_and_stable(pp::tests::Harness& harness)
|
||||
{
|
||||
expect_history_no_op(
|
||||
harness,
|
||||
pp::app::plan_close_request_history(pp::app::CloseRequestDecision::close_now));
|
||||
expect_history_no_op(
|
||||
harness,
|
||||
pp::app::plan_close_request_history(pp::app::CloseRequestDecision::show_unsaved_prompt));
|
||||
expect_history_no_op(
|
||||
harness,
|
||||
pp::app::plan_document_save_history(pp::app::DocumentSaveDecision::show_save_dialog));
|
||||
expect_history_no_op(
|
||||
harness,
|
||||
pp::app::plan_document_save_history(pp::app::DocumentSaveDecision::save_existing));
|
||||
expect_history_no_op(
|
||||
harness,
|
||||
pp::app::plan_document_save_history(pp::app::DocumentSaveDecision::save_version));
|
||||
expect_history_no_op(
|
||||
harness,
|
||||
pp::app::plan_document_workflow_history(pp::app::DocumentWorkflowDecision::continue_now));
|
||||
expect_history_no_op(
|
||||
harness,
|
||||
pp::app::plan_document_workflow_history(
|
||||
pp::app::DocumentWorkflowDecision::prompt_save_before_continue));
|
||||
|
||||
auto file_plan = pp::app::plan_document_file_save(
|
||||
"D:/Paint",
|
||||
"demo",
|
||||
[](const std::string&) { return false; });
|
||||
PP_EXPECT(harness, file_plan);
|
||||
expect_history_no_op(harness, pp::app::plan_document_file_save_history(file_plan.value()));
|
||||
|
||||
const pp::app::DocumentVersionTarget version_target {
|
||||
.name = "demo.02",
|
||||
.path = "D:/Paint/demo.02.ppi",
|
||||
};
|
||||
expect_history_no_op(harness, pp::app::plan_document_version_save_history(version_target));
|
||||
|
||||
auto new_document = pp::app::plan_new_document(
|
||||
"D:/Paint",
|
||||
"demo",
|
||||
1,
|
||||
[](const std::string&) { return false; });
|
||||
PP_EXPECT(harness, new_document);
|
||||
expect_history_clear(harness, pp::app::plan_new_document_history(new_document.value()));
|
||||
}
|
||||
|
||||
void document_file_target_rejects_empty_name(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::make_document_file_target("D:/Paint", "");
|
||||
@@ -791,6 +861,7 @@ int main()
|
||||
document_open_brush_imports_prompt_regardless_of_unsaved_state);
|
||||
harness.run("document open executor dispatches all actions", document_open_executor_dispatches_all_actions);
|
||||
harness.run("document open executor rejects mismatched routes", document_open_executor_rejects_mismatched_routes);
|
||||
harness.run("document open history clears only for projects", document_open_history_clears_only_for_projects);
|
||||
harness.run("close clean document executes immediately", close_clean_document_executes_immediately);
|
||||
harness.run("close dirty document opens one prompt", close_dirty_document_opens_one_prompt);
|
||||
harness.run("close request executor dispatches and preserves wait", close_request_executor_dispatches_and_preserves_wait);
|
||||
@@ -809,6 +880,9 @@ int main()
|
||||
harness.run("workflow with clean canvas continues now", workflow_with_clean_canvas_continues_now);
|
||||
harness.run("workflow with dirty canvas prompts for save", workflow_with_dirty_canvas_prompts_for_save);
|
||||
harness.run("workflow executor dispatches continue prompt and unavailable", workflow_executor_dispatches_continue_prompt_and_unavailable);
|
||||
harness.run(
|
||||
"document session history effects stay explicit and stable",
|
||||
document_session_history_effects_stay_explicit_and_stable);
|
||||
harness.run("document file target rejects empty name", document_file_target_rejects_empty_name);
|
||||
harness.run("document file target builds legacy ppi path", document_file_target_builds_legacy_ppi_path);
|
||||
harness.run("document file write prompts only for existing targets", document_file_write_prompts_only_for_existing_targets);
|
||||
|
||||
Reference in New Issue
Block a user