Route onion frame planning through app core

This commit is contained in:
2026-06-05 00:19:12 +02:00
parent 2feeffd6c8
commit 59210c28ea
6 changed files with 132 additions and 16 deletions

View File

@@ -426,6 +426,46 @@ void onion_size_updates_canvas_without_document_mutation(pp::tests::Harness& har
PP_EXPECT(harness, !pp::app::plan_animation_onion_size(-1));
}
void onion_frame_ranges_clamp_edges_and_alpha(pp::tests::Harness& harness)
{
const auto center = pp::app::plan_animation_onion_frame_range(5, 2, 1);
PP_REQUIRE(harness, center);
PP_EXPECT(harness, center.value().first_frame == 1);
PP_EXPECT(harness, center.value().last_frame == 3);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(center.value(), 2) == 1.0f);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(center.value(), 1) == 0.5f);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(center.value(), 3) == 0.5f);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(center.value(), 0) == 0.0f);
const auto left = pp::app::plan_animation_onion_frame_range(5, 0, 3);
PP_REQUIRE(harness, left);
PP_EXPECT(harness, left.value().first_frame == 0);
PP_EXPECT(harness, left.value().last_frame == 3);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(left.value(), 0) == 1.0f);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(left.value(), 3) == 0.25f);
const auto right = pp::app::plan_animation_onion_frame_range(5, 4, 3);
PP_REQUIRE(harness, right);
PP_EXPECT(harness, right.value().first_frame == 1);
PP_EXPECT(harness, right.value().last_frame == 4);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(right.value(), 1) == 0.25f);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(right.value(), 4) == 1.0f);
const auto single = pp::app::plan_animation_onion_frame_range(1, 0, 8);
PP_REQUIRE(harness, single);
PP_EXPECT(harness, single.value().first_frame == 0);
PP_EXPECT(harness, single.value().last_frame == 0);
PP_EXPECT(harness, pp::app::animation_onion_frame_alpha(single.value(), 0) == 1.0f);
}
void onion_frame_ranges_reject_invalid_inputs(pp::tests::Harness& harness)
{
PP_EXPECT(harness, !pp::app::plan_animation_onion_frame_range(0, 0, 1));
PP_EXPECT(harness, !pp::app::plan_animation_onion_frame_range(3, -1, 1));
PP_EXPECT(harness, !pp::app::plan_animation_onion_frame_range(3, 3, 1));
PP_EXPECT(harness, !pp::app::plan_animation_onion_frame_range(3, 1, -1));
}
void executor_dispatches_mutating_frame_operations(pp::tests::Harness& harness)
{
FakeDocumentAnimationServices services;
@@ -590,6 +630,8 @@ int main()
harness.run("panel actions plan timeline and playback intent", panel_actions_plan_timeline_and_playback_intent);
harness.run("panel actions reject invalid timeline state", panel_actions_reject_invalid_timeline_state);
harness.run("onion size updates canvas without document mutation", onion_size_updates_canvas_without_document_mutation);
harness.run("onion frame ranges clamp edges and alpha", onion_frame_ranges_clamp_edges_and_alpha);
harness.run("onion frame ranges reject invalid inputs", onion_frame_ranges_reject_invalid_inputs);
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);
harness.run("executor rejects malformed animation plans", executor_rejects_malformed_animation_plans);