Extend animation panel frame dispatch

This commit is contained in:
2026-06-03 16:39:14 +02:00
parent 93f3037410
commit 5752bc6ae9
7 changed files with 269 additions and 22 deletions

View File

@@ -55,6 +55,22 @@ public:
return move_result;
}
void select_frame(std::uint32_t layer_id, int layer_index, int selected_frame) override
{
frame_selects += 1;
last_layer_id = layer_id;
last_layer_index = layer_index;
last_selected_frame = selected_frame;
call_order += "select-frame;";
}
void select_layer(int layer_index) override
{
layer_selects += 1;
last_layer_index = layer_index;
call_order += "select-layer;";
}
void goto_frame(int target_frame) override
{
gotos += 1;
@@ -62,6 +78,13 @@ public:
call_order += "goto;";
}
void set_timeline_frame(int target_frame) override
{
timeline_sets += 1;
last_timeline_frame = target_frame;
call_order += "timeline;";
}
void set_onion_size(int onion_size) override
{
onion_sets += 1;
@@ -75,6 +98,12 @@ public:
call_order += "update;";
}
void update_frame_status() override
{
frame_status_updates += 1;
call_order += "frame-status;";
}
void reload_animation_layers() override
{
reloads += 1;
@@ -92,16 +121,23 @@ public:
int removes = 0;
int duration_sets = 0;
int moves = 0;
int frame_selects = 0;
int layer_selects = 0;
int gotos = 0;
int timeline_sets = 0;
int onion_sets = 0;
int canvas_updates = 0;
int frame_status_updates = 0;
int reloads = 0;
int unsaved_marks = 0;
int last_selected_frame = -1;
int last_target_frame = -1;
int last_timeline_frame = -1;
int last_duration = -1;
int last_move_offset = 0;
int last_onion_size = -1;
int last_layer_index = -1;
std::uint32_t last_layer_id = 0;
int move_result = 0;
std::string call_order;
};
@@ -199,6 +235,34 @@ void move_and_timeline_plans_handle_edges(pp::tests::Harness& harness)
PP_EXPECT(harness, !pp::app::plan_animation_step_frame(0, 0, 1));
}
void frame_selection_and_playback_plans_keep_ui_refresh_scoped(pp::tests::Harness& harness)
{
const auto select = pp::app::plan_animation_select_frame(3, 2, 42, 1);
PP_REQUIRE(harness, select);
PP_EXPECT(harness, select.value().operation == pp::app::DocumentAnimationOperation::select_frame);
PP_EXPECT(harness, select.value().layer_index == 2);
PP_EXPECT(harness, select.value().layer_id == 42);
PP_EXPECT(harness, select.value().selected_frame == 1);
PP_EXPECT(harness, select.value().target_frame == 1);
PP_EXPECT(harness, select.value().updates_canvas_animation);
PP_EXPECT(harness, !select.value().reloads_animation_layers);
PP_EXPECT(harness, !select.value().mutates_document);
const auto playback = pp::app::plan_animation_playback_step(4, 3, 1);
PP_REQUIRE(harness, playback);
PP_EXPECT(harness, playback.value().operation == pp::app::DocumentAnimationOperation::playback_step);
PP_EXPECT(harness, playback.value().target_frame == 0);
PP_EXPECT(harness, playback.value().move_offset == 1);
PP_EXPECT(harness, playback.value().updates_canvas_animation);
PP_EXPECT(harness, !playback.value().reloads_animation_layers);
PP_EXPECT(harness, !playback.value().mutates_document);
PP_EXPECT(harness, !pp::app::plan_animation_select_frame(2, -1, 42, 0));
PP_EXPECT(harness, !pp::app::plan_animation_select_frame(2, 0, 42, 2));
PP_EXPECT(harness, !pp::app::plan_animation_playback_step(0, 0, 1));
PP_EXPECT(harness, !pp::app::plan_animation_playback_step(3, 0, 0));
}
void onion_size_updates_canvas_without_document_mutation(pp::tests::Harness& harness)
{
const auto plan = pp::app::plan_animation_onion_size(2);
@@ -267,20 +331,37 @@ void executor_dispatches_timeline_and_parameter_operations(pp::tests::Harness& h
PP_REQUIRE(harness, onion);
PP_EXPECT(harness, pp::app::execute_animation_operation_plan(onion.value(), services).ok());
const auto select = pp::app::plan_animation_select_frame(3, 2, 42, 1);
PP_REQUIRE(harness, select);
PP_EXPECT(harness, pp::app::execute_animation_operation_plan(select.value(), services).ok());
const auto playback = pp::app::plan_animation_playback_step(5, 4, 1);
PP_REQUIRE(harness, playback);
PP_EXPECT(harness, pp::app::execute_animation_operation_plan(playback.value(), services).ok());
PP_EXPECT(harness, services.duration_sets == 1);
PP_EXPECT(harness, services.last_duration == 5);
PP_EXPECT(harness, services.moves == 1);
PP_EXPECT(harness, services.last_move_offset == 1);
PP_EXPECT(harness, services.gotos == 2);
PP_EXPECT(harness, services.frame_selects == 1);
PP_EXPECT(harness, services.layer_selects == 1);
PP_EXPECT(harness, services.gotos == 4);
PP_EXPECT(harness, services.timeline_sets == 1);
PP_EXPECT(harness, services.last_target_frame == 0);
PP_EXPECT(harness, services.last_timeline_frame == 0);
PP_EXPECT(harness, services.last_layer_index == 2);
PP_EXPECT(harness, services.last_layer_id == 42);
PP_EXPECT(harness, services.onion_sets == 1);
PP_EXPECT(harness, services.last_onion_size == 3);
PP_EXPECT(harness, services.unsaved_marks == 2);
PP_EXPECT(harness, services.canvas_updates == 2);
PP_EXPECT(harness, services.frame_status_updates == 1);
PP_EXPECT(harness, services.reloads == 3);
PP_EXPECT(
harness,
services.call_order == "duration;unsaved;update;reload;move;unsaved;goto;reload;goto;reload;onion;update;");
services.call_order
== "duration;unsaved;update;reload;move;unsaved;goto;reload;goto;reload;onion;update;"
"select-frame;goto;select-layer;goto;timeline;frame-status;");
}
void executor_rejects_malformed_animation_plans(pp::tests::Harness& harness)
@@ -307,6 +388,14 @@ void executor_rejects_malformed_animation_plans(pp::tests::Harness& harness)
go.target_frame = 3;
PP_EXPECT(harness, !pp::app::execute_animation_operation_plan(go, services).ok());
auto select = pp::app::plan_animation_select_frame(2, 0, 42, 1).value();
select.layer_index = -1;
PP_EXPECT(harness, !pp::app::execute_animation_operation_plan(select, services).ok());
auto playback = pp::app::plan_animation_playback_step(3, 1, 1).value();
playback.move_offset = 0;
PP_EXPECT(harness, !pp::app::execute_animation_operation_plan(playback, services).ok());
PP_EXPECT(harness, services.adds == 0);
PP_EXPECT(harness, services.duration_sets == 0);
PP_EXPECT(harness, services.gotos == 0);
@@ -321,6 +410,7 @@ int main()
harness.run("add duplicate and remove validate frame bounds", add_duplicate_and_remove_validate_frame_bounds);
harness.run("duration plans clamp floor and reject overflow", duration_plans_clamp_floor_and_reject_overflow);
harness.run("move and timeline plans handle edges", move_and_timeline_plans_handle_edges);
harness.run("frame selection and playback plans keep ui refresh scoped", frame_selection_and_playback_plans_keep_ui_refresh_scoped);
harness.run("onion size updates canvas without document mutation", onion_size_updates_canvas_without_document_mutation);
harness.run("executor dispatches mutating frame operations", executor_dispatches_mutating_frame_operations);
harness.run("executor dispatches timeline and parameter operations", executor_dispatches_timeline_and_parameter_operations);