Files
effectcraft/crates/ui-egui/tests/ui_frame_step.rs
T
pravdomilandClaude Opus 5.5 88bf89ea5d Shortcuts: Cmd+Left / Cmd+Right Arrow step a frame
Previous / Next Frame also answer to Cmd+Left / Cmd+Right Arrow, and Back / Forward
10 Frames to Cmd+Shift+Left / Right, next to the Page keys (After Effects' second
default keys). A command spec can now list several default shortcuts
(`alt_shortcuts`, `cmd!(…, ["PageDown", "Cmd+ArrowRight"], …)`); menus and tooltips
keep showing the first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 16:26:27 +02:00

45 lines
1.8 KiB
Rust

//! Stepping the current time from the keyboard: Page Down / Page Up and Cmd+Right / Cmd+Left
//! Arrow move one frame, with Shift ten.
use effectcraft_engine::Session;
use effectcraft_ui_egui::EffectcraftApp;
use egui::{Event, Key, Modifiers};
use egui_kittest::Harness;
use serde_json::json;
fn key(h: &mut Harness<'_, EffectcraftApp>, key: Key, modifiers: Modifiers) {
h.event(Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers });
h.step();
h.event(Event::Key { key, physical_key: None, pressed: false, repeat: false, modifiers });
h.step();
}
#[test]
fn cmd_arrows_step_the_current_frame() {
let mut session = Session::default();
session.execute("comp.new", json!({"name": "Main", "width": 320, "height": 180, "frameRate": 30.0, "duration": 4.0})).unwrap();
let cid = session.state.active_comp.unwrap();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_| EffectcraftApp::new(session));
h.run_steps(2);
let frame = |h: &Harness<'_, EffectcraftApp>| {
let app = h.state();
app.session.project.comp(cid).unwrap().frame_rate.frame_at(app.session.time())
};
assert_eq!(frame(&h), 0);
let cmd = Modifiers::COMMAND;
let cmd_shift = Modifiers::COMMAND | Modifiers::SHIFT;
key(&mut h, Key::ArrowRight, cmd);
assert_eq!(frame(&h), 1);
key(&mut h, Key::PageDown, Modifiers::NONE);
assert_eq!(frame(&h), 2);
key(&mut h, Key::ArrowRight, cmd_shift);
assert_eq!(frame(&h), 12);
key(&mut h, Key::ArrowLeft, cmd);
assert_eq!(frame(&h), 11);
key(&mut h, Key::ArrowLeft, cmd_shift);
assert_eq!(frame(&h), 1);
// The plain arrows still nudge layers, not the time.
key(&mut h, Key::ArrowRight, Modifiers::NONE);
assert_eq!(frame(&h), 1);
}