Add animation panel action planner
This commit is contained in:
@@ -328,6 +328,91 @@ void playback_toggle_plans_capture_start_and_stop_intent(pp::tests::Harness& har
|
||||
PP_EXPECT(harness, stop.value().playback_idle_ms == 100);
|
||||
}
|
||||
|
||||
void panel_actions_plan_timeline_and_playback_intent(pp::tests::Harness& harness)
|
||||
{
|
||||
const pp::app::DocumentAnimationPanelState state {
|
||||
.total_duration = 5,
|
||||
.current_frame = 4,
|
||||
.playback_active = false,
|
||||
};
|
||||
|
||||
const auto goto_frame = pp::app::plan_animation_panel_action(
|
||||
pp::app::DocumentAnimationPanelAction::goto_frame,
|
||||
state,
|
||||
2);
|
||||
PP_REQUIRE(harness, goto_frame);
|
||||
PP_EXPECT(harness, goto_frame.value().operation == pp::app::DocumentAnimationOperation::goto_frame);
|
||||
PP_EXPECT(harness, goto_frame.value().target_frame == 2);
|
||||
|
||||
const auto next = pp::app::plan_animation_panel_action(
|
||||
pp::app::DocumentAnimationPanelAction::next_frame,
|
||||
state);
|
||||
PP_REQUIRE(harness, next);
|
||||
PP_EXPECT(harness, next.value().operation == pp::app::DocumentAnimationOperation::goto_next);
|
||||
PP_EXPECT(harness, next.value().target_frame == 0);
|
||||
|
||||
const auto previous = pp::app::plan_animation_panel_action(
|
||||
pp::app::DocumentAnimationPanelAction::previous_frame,
|
||||
state);
|
||||
PP_REQUIRE(harness, previous);
|
||||
PP_EXPECT(harness, previous.value().operation == pp::app::DocumentAnimationOperation::goto_previous);
|
||||
PP_EXPECT(harness, previous.value().target_frame == 3);
|
||||
|
||||
const auto playback = pp::app::plan_animation_panel_action(
|
||||
pp::app::DocumentAnimationPanelAction::playback_step,
|
||||
state);
|
||||
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().reloads_animation_layers);
|
||||
|
||||
const auto play_toggle = pp::app::plan_animation_panel_action(
|
||||
pp::app::DocumentAnimationPanelAction::toggle_playback,
|
||||
state);
|
||||
PP_REQUIRE(harness, play_toggle);
|
||||
PP_EXPECT(harness, play_toggle.value().operation == pp::app::DocumentAnimationOperation::toggle_playback);
|
||||
PP_EXPECT(harness, play_toggle.value().playback_active);
|
||||
PP_EXPECT(harness, play_toggle.value().playback_idle_ms == 10);
|
||||
}
|
||||
|
||||
void panel_actions_reject_invalid_timeline_state(pp::tests::Harness& harness)
|
||||
{
|
||||
const pp::app::DocumentAnimationPanelState empty {
|
||||
.total_duration = 0,
|
||||
.current_frame = 0,
|
||||
.playback_active = false,
|
||||
};
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::plan_animation_panel_action(pp::app::DocumentAnimationPanelAction::goto_frame, empty, 0));
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::plan_animation_panel_action(pp::app::DocumentAnimationPanelAction::next_frame, empty));
|
||||
|
||||
const pp::app::DocumentAnimationPanelState out_of_range {
|
||||
.total_duration = 3,
|
||||
.current_frame = 3,
|
||||
.playback_active = true,
|
||||
};
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::plan_animation_panel_action(pp::app::DocumentAnimationPanelAction::playback_step, out_of_range));
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
!pp::app::plan_animation_panel_action(
|
||||
pp::app::DocumentAnimationPanelAction::goto_frame,
|
||||
out_of_range,
|
||||
-1));
|
||||
|
||||
const auto stop_playback = pp::app::plan_animation_panel_action(
|
||||
pp::app::DocumentAnimationPanelAction::toggle_playback,
|
||||
out_of_range);
|
||||
PP_REQUIRE(harness, stop_playback);
|
||||
PP_EXPECT(harness, stop_playback.value().operation == pp::app::DocumentAnimationOperation::toggle_playback);
|
||||
PP_EXPECT(harness, !stop_playback.value().playback_active);
|
||||
PP_EXPECT(harness, stop_playback.value().playback_idle_ms == 100);
|
||||
}
|
||||
|
||||
void onion_size_updates_canvas_without_document_mutation(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto plan = pp::app::plan_animation_onion_size(2);
|
||||
@@ -502,6 +587,8 @@ int main()
|
||||
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("playback toggle plans capture start and stop intent", playback_toggle_plans_capture_start_and_stop_intent);
|
||||
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("executor dispatches mutating frame operations", executor_dispatches_mutating_frame_operations);
|
||||
harness.run("executor dispatches timeline and parameter operations", executor_dispatches_timeline_and_parameter_operations);
|
||||
|
||||
Reference in New Issue
Block a user