EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge main into feat-gap25-a11y-audit
vangel769ed448d75cc8
diff --cc crates/ui-egui/tests/ui_accessibility_audit.rsindex acbbabf41,000000000..7340be2bcmode 100644,000000..100644--- a/crates/ui-egui/tests/ui_accessibility_audit.rs+++ b/crates/ui-egui/tests/ui_accessibility_audit.rs@@@ -1,373 -1,0 +1,385 @@@+//! Accessibility audit (docs/gaps.md gap 25): renders panels headless and walks the AccessKit+//! tree of the frame. Every interactive node (button, check box, text input, combo box, slider,+//! spin button, tree or list item, tab, link, ...) must have a non-empty name, a role that says+//! what it is, and the state that role needs (checked, selected, a value).+//!+//! * The panels that had their pass (`FIXED`: Effects & Presets, Settings, Render Queue with its+//! Templates dialog) must have **zero** findings.+//! * Every other panel is counted and printed (run with `--nocapture`), and checked against+//! [`BASELINE`], a ratchet that can only shrink: fixing a panel lowers its number, and a number+//! must never go up. When a panel's count falls, lower its entry (the test says so).+//!+//! What this does not measure: how a real screen reader speaks the tree (none was run), colour+//! contrast, focus order or keyboard operation (the `ui_*_keyboard.rs` tests cover those), or+//! widgets that are scrolled out of view and not drawn.++use std::collections::HashSet;++use effectcraft_engine::Session;+use effectcraft_ui_egui::EffectcraftApp;+use effectcraft_ui_egui::dock::PanelKind;+use egui::accesskit::{Action, Role, Toggled};+use egui::{Rect, pos2};+use egui_kittest::Harness;+use egui_kittest::kittest::NodeT;+use serde_json::json;++/// Groups that must be clean. A group is the first part of a scenario name (before the `:`).+const FIXED: &[&str] = &["EffectsPresets", "Settings", "RenderQueue", "Project"];+- /// (scenario, findings, of them unnamed controls) per not-yet-fixed scenario, as measured when- /// this test was written (Effect Controls with one Gaussian Blur on the layer, every other panel++/// (scenario, findings, of them unnamed controls) per not-yet-fixed scenario, as measured in the++/// shared docking layout (Effect Controls with one Gaussian Blur on the layer, every other panel+/// as it opens). A ratchet: a number may only go down, never up; when a pass over a panel lowers+/// it, lower its entry in the same change, and remove the entry (and add the panel to `FIXED`)+/// when it reaches zero. A scenario that is not listed is held to zero.+const BASELINE: &[(&str, usize, usize)] = &[+ ("EffectControls:default", 28, 14),+ ("Composition:default", 4, 2),+ ("Layer:default", 2, 1),+ ("Timeline:default", 89, 42),+ ("Audio:default", 4, 2),- ("Properties:default", 47, 23),- ("Character:default", 8, 4),- ("Paragraph:default", 24, 12),- ("Align:default", 10, 2),++ ("Properties:default", 31, 15),++ ("Character:default", 42, 21),++ ("Paragraph:default", 26, 13),++ ("Align:default", 12, 0),++ ("Tracker:default", 11, 3),++ ("Wiggler:default", 4, 2),+ ("Smoother:default", 2, 1),- ("MotionSketch:default", 4, 2),- ("Paint:default", 6, 3),- ("Brushes:default", 11, 2),++ ("MotionSketch:default", 8, 4),++ ("Paint:default", 38, 18),++ ("Brushes:default", 34, 6),+ ("Flowchart:default", 5, 1),+ ("History:default", 10, 5),- ("Markers:default", 2, 1),- ("MaskInterpolation:default", 2, 1),- ("ScriptConsole:default", 6, 3),++ ("MaskInterpolation:default", 16, 8),++ ("ScriptConsole:default", 5, 3),+ ("EssentialGraphics:default", 1, 1),- ("Footage:default", 2, 1),- ("VrCompEditor:default", 6, 0),++ ("LumetriScopes:default", 2, 1),++ ("MediaBrowser:default", 20, 10),++ ("Metadata:default", 2, 2),++ ("ContentAwareFill:default", 2, 1),+];++/// How many controls the fixed scenarios must at least show, so that "zero findings" is never+/// the result of looking at nothing. Any scenario not listed needs 2.+const MIN_CONTROLS: &[(&str, usize)] = &[+ ("EffectsPresets:default", 10),+ ("EffectsPresets:open", 10),+ ("EffectsPresets:search", 5),+ ("EffectsPresets:menu", 8),+ ("Settings:general", 12),+ ("Settings:appearance", 15),+ ("Settings:labels", 30),+ ("RenderQueue:queued", 8),+ ("RenderQueue:expanded", 12),+ ("RenderQueue:menu", 20),+ ("RenderQueue:templates:renderSettings", 8),+ ("RenderQueue:templates:outputModule", 8),+];++/// The roles that are controls: anything with one of these (or with a click or focus action) is+/// held to the rules below.+const CONTROL_ROLES: &[Role] = &[+ Role::Button,+ Role::CheckBox,+ Role::ColorWell,+ Role::ComboBox,+ Role::Link,+ Role::ListBoxOption,+ Role::ListItem,+ Role::MenuItem,+ Role::MenuItemCheckBox,+ Role::MenuItemRadio,+ Role::MultilineTextInput,+ Role::RadioButton,+ Role::SearchInput,+ Role::Slider,+ Role::SpinButton,+ Role::Switch,+ Role::Tab,+ Role::TextInput,+ Role::TreeItem,+];++#[derive(Debug, Clone)]+struct Finding {+ scenario: String,+ problem: &'static str,+ role: Role,+ name: String,+ rect: [i32; 4],+}++impl std::fmt::Display for Finding {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ write!(f, "[{}] {}: {:?} {:?} at {:?}", self.scenario, self.problem, self.role, self.name, self.rect)+ }+}++fn app_session() -> Session {+ let mut s = Session::default();+ s.execute("comp.new", json!({"name": "Main", "width": 320, "height": 180, "duration": 4})).unwrap();+ s.execute("layer.newSolid", json!({"name": "Red", "color": "#c04040"})).unwrap();+ s.execute("layer.newSolid", json!({"name": "Blue", "color": "#4040c0"})).unwrap();+ s.execute("effect.apply", json!({"effect": "Gaussian Blur"})).ok();+ s+}++fn harness() -> Harness<'static, EffectcraftApp> {+ let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|_| EffectcraftApp::new(app_session()));++ // The default workspace gives Preview a short frame at the top of the right column; its++ // controls below that frame stay in the tree and would be counted against the panel under it.++ // The per-panel pass opens Preview again for its own scenario.++ h.state_mut().close_panel(PanelKind::Preview);+ h.run_steps(4);+ h+}++fn invoke(h: &mut Harness<'_, EffectcraftApp>, id: &str, params: serde_json::Value) {+ let ctx = h.ctx.clone();+ effectcraft_ui_egui::menus::invoke(h.state_mut(), &ctx, id, params).unwrap();+ h.run_steps(4);+}++fn panel_rect(h: &Harness<'_, EffectcraftApp>, p: PanelKind) -> Option<Rect> {+ let e = h.state().auto.find(&format!("panel.{}", p.id()))?;+ Some(Rect::from_min_size(pos2(e.rect[0], e.rect[1]), egui::vec2(e.rect[2], e.rect[3])))+}++fn dialog_rect(h: &Harness<'_, EffectcraftApp>, title: &str) -> Option<Rect> {+ h.ctx.memory(|m| m.area_rect(egui::Id::unique(("modal", title))))+}++/// The ids of every node now, so a later audit can look at what appeared since (a popup).+fn node_ids(h: &Harness<'_, EffectcraftApp>) -> HashSet<String> {+ h.root().children_recursive().map(|n| format!("{:?}", n.accesskit_node().id())).collect()+}++/// Walk the tree and check every control whose centre is inside `scope` (and, when `since` is+/// given, that was not in the tree before).+fn audit(h: &Harness<'_, EffectcraftApp>, scenario: &str, scope: Rect, since: Option<&HashSet<String>>) -> (Vec<Finding>, usize) {+ let mut out = Vec::new();+ let mut controls = 0;+ for n in h.root().children_recursive() {+ let a = n.accesskit_node();+ if a.is_hidden() {+ continue;+ }+ let Some(b) = a.bounding_box() else {+ // No bounds: assistive technology cannot place it. Only a control is a finding (and+ // it is one wherever it is: there is no position to scope it by).+ if CONTROL_ROLES.contains(&a.role()) {+ out.push(Finding { scenario: scenario.to_string(), problem: "no bounds", role: a.role(), name: a.label().unwrap_or_default(), rect: [0; 4] });+ }+ continue;+ };+ if !scope.contains(pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32)) {+ continue;+ }+ if since.is_some_and(|s| s.contains(&format!("{:?}", a.id()))) {+ continue;+ }+ let role = a.role();+ let actionable = a.data().supports_action(Action::Click) || a.data().supports_action(Action::Focus);+ let control = CONTROL_ROLES.contains(&role);+ if !control && !(actionable && matches!(role, Role::Unknown | Role::GenericContainer)) {+ continue;+ }+ let name = a.label().unwrap_or_default();+ controls += 1;+ let finding = |problem: &'static str| Finding {+ scenario: scenario.to_string(),+ problem,+ role,+ name: name.clone(),+ rect: [b.x0 as i32, b.y0 as i32, b.x1 as i32, b.y1 as i32],+ };+ if !control && matches!(role, Role::Unknown | Role::GenericContainer) {+ // Something you can click or focus, that no role describes.+ out.push(finding("clickable or focusable without a control role"));+ }+ if name.trim().is_empty() {+ out.push(finding("no name"));+ }+ let state_missing = match role {+ Role::CheckBox | Role::RadioButton | Role::Switch | Role::MenuItemCheckBox | Role::MenuItemRadio => {+ a.toggled().is_none() || a.toggled() == Some(Toggled::Mixed)+ }+ Role::Slider | Role::SpinButton => a.numeric_value().is_none(),+ Role::ComboBox => a.value().is_none_or(|v| v.trim().is_empty()),+ Role::TreeItem | Role::ListItem | Role::ListBoxOption | Role::Tab => a.is_selected().is_none(),+ _ => false,+ };+ if state_missing {+ out.push(finding("no state or value"));+ }+ }+ (out, controls)+}++fn count_unnamed(f: &[Finding]) -> usize {+ f.iter().filter(|f| f.problem == "no name").count()+}++struct Report {+ findings: Vec<Finding>,+ /// (scenario, findings, of them unnamed, controls looked at)+ rows: Vec<(String, usize, usize, usize)>,+}++impl Report {+ fn add(&mut self, scenario: &str, (f, controls): (Vec<Finding>, usize)) {+ self.rows.push((scenario.to_string(), f.len(), count_unnamed(&f), controls));+ self.findings.extend(f);+ }+}++fn group(scenario: &str) -> &str {+ scenario.split(':').next().unwrap_or(scenario)+}++fn collect() -> Report {+ let mut r = Report { findings: vec![], rows: vec![] };++ // ---- Effects & Presets: closed, everything open, searching, the contents menu.+ let mut h = harness();+ h.state_mut().show_panel(PanelKind::EffectsPresets);+ h.run_steps(4);+ let rect = panel_rect(&h, PanelKind::EffectsPresets).expect("Effects & Presets is drawn");+ r.add("EffectsPresets:default", audit(&h, "EffectsPresets:default", rect, None));+ {+ let s = h.state_mut();+ s.session.prefs.toggle_effect_favorite("ec.blur.gaussian");+ s.ui.effects_open.insert("favorites".into());+ s.ui.effects_open.insert("presets".into());+ s.ui.effects_open.insert("presets/Text".into());+ s.ui.effects_open.insert("Blur & Sharpen".into());+ }+ h.run_steps(4);+ r.add("EffectsPresets:open", audit(&h, "EffectsPresets:open", rect, None));+ h.state_mut().ui.effects_search = "blur".into();+ h.run_steps(4);+ r.add("EffectsPresets:search", audit(&h, "EffectsPresets:search", rect, None));+ let before = node_ids(&h);+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("fx-contents-menu").with("open"), true));+ h.run_steps(4);+ let screen = Rect::from_min_size(pos2(0.0, 0.0), egui::vec2(1600.0, 1000.0));+ r.add("EffectsPresets:menu", audit(&h, "EffectsPresets:menu", screen, Some(&before)));++ // ---- Settings: every page.+ let mut h = harness();+ let before = node_ids(&h);+ for page in effectcraft_engine::prefs::pages() {+ invoke(&mut h, "app.settings", json!({"page": page.id}));+ let name = format!("Settings:{}", page.id);+ let rect = dialog_rect(&h, "Settings").expect("the Settings dialog is open");+ r.add(&name, audit(&h, &name, rect, Some(&before)));+ }++ // ---- Render Queue: empty, queued and expanded, a menu open, the Templates dialogs.+ let mut h = harness();+ h.state_mut().show_panel(PanelKind::RenderQueue);+ h.run_steps(4);+ let rect = panel_rect(&h, PanelKind::RenderQueue).expect("the Render Queue is drawn");+ r.add("RenderQueue:empty", audit(&h, "RenderQueue:empty", rect, None));+ let comp = h.state().session.active_comp_id().expect("a comp").0;+ let mut items = vec![];+ for _ in 0..2 {+ let out = h.state_mut().session.execute("renderQueue.add", json!({"comp": comp})).unwrap();+ items.push(out["item"].as_u64().or_else(|| out["items"][0].as_u64()).unwrap_or(0));+ }+ h.run_steps(4);+ r.add("RenderQueue:queued", audit(&h, "RenderQueue:queued", rect, None));+ let first = h.state().session.project.render_queue.first().map(|i| i.id).expect("a queue item");+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("rq-ui"), (vec![first], Some(first))));+ h.run_steps(4);+ r.add("RenderQueue:expanded", audit(&h, "RenderQueue:expanded", rect, None));+ let before = node_ids(&h);+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique(("rq-dd", first, 0)).with("open"), true));+ h.run_steps(4);+ r.add("RenderQueue:menu", audit(&h, "RenderQueue:menu", screen, Some(&before)));+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique(("rq-dd", first, 0)).with("open"), false));+ let before = node_ids(&h);+ for (kind, title) in [("renderSettings", "Render Settings Templates"), ("outputModule", "Output Module Templates")] {+ invoke(&mut h, "app.templates", json!({"kind": kind}));+ let name = format!("RenderQueue:templates:{kind}");+ let rect = dialog_rect(&h, title).expect("the Templates dialog is open");+ r.add(&name, audit(&h, &name, rect, Some(&before)));+ }+ let _ = items;++ // ---- Everything else, informational: each panel on its own.+ let mut h = harness();+ for p in PanelKind::ALL {+ if matches!(p, PanelKind::EffectsPresets | PanelKind::RenderQueue) {+ continue;+ }+ h.state_mut().show_panel(p);+ h.run_steps(3);+ let name = format!("{}:default", p.id());+ let Some(rect) = panel_rect(&h, p) else {+ r.rows.push((format!("{name} (not drawn)"), 0, 0, 0));+ continue;+ };+ r.add(&name, audit(&h, &name, rect, None));++ if p == PanelKind::Preview {++ // Closed again so it is not counted against the panels after it (see `harness`).++ h.state_mut().close_panel(PanelKind::Preview);++ h.run_steps(3);++ }+ }+ r+}++#[test]+fn fixed_panels_have_no_unnamed_or_roleless_controls_and_the_others_do_not_get_worse() {+ let report = collect();+ println!("\nAccessibility audit: findings per scenario (unnamed in brackets)");+ let mut by_group: Vec<(String, usize, usize, usize)> = vec![];+ for (name, n, unnamed, controls) in &report.rows {+ println!(" {name:<44} {n:>4} findings ({unnamed} unnamed) of {controls} controls");+ let g = group(name).to_string();+ match by_group.iter_mut().find(|(k, ..)| *k == g) {+ Some(e) => {+ e.1 += n;+ e.2 += unnamed;+ e.3 += controls;+ }+ None => by_group.push((g, *n, *unnamed, *controls)),+ }+ }+ println!("\nBy panel (findings, unnamed controls, controls looked at):");+ for (g, n, unnamed, controls) in &by_group {+ let state = if FIXED.contains(&g.as_str()) { "fixed: must be 0" } else { "not yet audited" };+ println!(" {g:<28} {n:>4} findings, {unnamed:>3} unnamed, {controls:>4} controls {state}");+ }+ let total_unnamed: usize = by_group.iter().map(|(_, _, u, _)| u).sum();+ println!(" all panels: {total_unnamed} unnamed controls\n");++ let mut failures = vec![];+ for f in &report.findings {+ if FIXED.contains(&group(&f.scenario)) {+ failures.push(f.to_string());+ }+ }+ assert!(failures.is_empty(), "{} accessibility findings in the fixed panels:\n{}", failures.len(), failures.join("\n"));++ // A clean panel must not be clean because nothing was looked at.+ for (name, _, _, controls) in &report.rows {+ if FIXED.contains(&group(name)) {+ let min = MIN_CONTROLS.iter().find(|(k, _)| k == name).map_or(2, |(_, v)| *v);+ assert!(*controls >= min, "{name}: only {controls} controls found in the tree (expected {min}); the scenario is not showing the panel");+ }+ }++ for (name, n, unnamed, _) in &report.rows {+ if FIXED.contains(&group(name)) {+ continue;+ }+ let (allowed, allowed_unnamed) = BASELINE.iter().find(|(k, ..)| k == name).map_or((0, 0), |(_, v, u)| (*v, *u));+ assert!(*n <= allowed, "{name}: {n} findings, the baseline allows {allowed}; a panel must not get worse");+ assert!(*unnamed <= allowed_unnamed, "{name}: {unnamed} unnamed controls, the baseline allows {allowed_unnamed}; a panel must not get worse");+ if *n < allowed || *unnamed < allowed_unnamed {+ println!("note: {name} improved to {n} findings ({unnamed} unnamed); lower its BASELINE entry from {allowed} ({allowed_unnamed})");+ }+ }+}diff --cc crates/ui-egui/tests/ui_effects_presets_keyboard.rsindex 7c4c52413,000000000..27151b324mode 100644,000000..100644--- a/crates/ui-egui/tests/ui_effects_presets_keyboard.rs+++ b/crates/ui-egui/tests/ui_effects_presets_keyboard.rs@@@ -1,271 -1,0 +1,276 @@@+//! Effects & Presets keyboard operation and accessible names (docs/gaps.md gap 25): the list is one+//! Tab stop; the arrow keys, Home / End, Right / Left, Enter and Space work it; the focus follows+//! the cursor; rows are tree items with a name, a selected state, a depth and (folders) an open+//! state; the favourite star is a named button.++use effectcraft_engine::Session;+use effectcraft_ui_egui::EffectcraftApp;+use effectcraft_ui_egui::dock::PanelKind;+use egui::accesskit::Role;+use egui::{Event, Key, Modifiers, Pos2, pos2};+use egui_kittest::Harness;+use egui_kittest::kittest::{NodeT, Queryable};+use serde_json::json;++fn harness() -> Harness<'static, EffectcraftApp> {+ let mut s = Session::default();+ s.execute("comp.new", json!({"name": "Main", "width": 320, "height": 180, "duration": 4})).unwrap();+ s.execute("layer.newSolid", json!({"name": "Red", "color": "#c04040"})).unwrap();+ let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|_| EffectcraftApp::new(s));+ h.state_mut().show_panel(PanelKind::EffectsPresets);+ h.run_steps(4);+ h+}++fn center(h: &Harness<'_, EffectcraftApp>, id: &str) -> Pos2 {+ let e = h.state().auto.find(id).unwrap_or_else(|| panic!("no {id}")).clone();+ pos2(e.rect[0] + e.rect[2] / 2.0, e.rect[1] + e.rect[3] / 2.0)+}++fn click(h: &mut Harness<'_, EffectcraftApp>, id: &str) {+ let p = center(h, id);+ h.input_mut().events.push(Event::PointerMoved(p));+ h.step();+ for pressed in [true, false] {+ h.input_mut().events.push(Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE });+ h.step();+ }+ h.run_steps(3);+}++fn key(h: &mut Harness<'_, EffectcraftApp>, key: Key, modifiers: Modifiers) {+ for pressed in [true, false] {+ h.input_mut().events.push(Event::Key { key, physical_key: None, pressed, repeat: false, modifiers });+ h.step();+ }+ h.run_steps(3);+}++/// The role and name of the node that has the keyboard focus.+fn focused(h: &Harness<'_, EffectcraftApp>) -> Option<(Role, String)> {+ h.root().children_recursive().find(|n| n.is_focused()).map(|n| (n.accesskit_node().role(), n.accesskit_node().label().unwrap_or_default()))+}++fn selected_rows(h: &Harness<'_, EffectcraftApp>) -> Vec<String> {+ let panel = h.state().auto.find("panel.EffectsPresets").expect("the panel is drawn").rect;+ let panel = egui::Rect::from_min_size(pos2(panel[0], panel[1]), egui::vec2(panel[2], panel[3]));+ h.root()+ .children_recursive()+ .filter(|n| n.accesskit_node().role() == Role::TreeItem && n.accesskit_node().is_selected() == Some(true))+ .filter(|n| n.accesskit_node().bounding_box().is_some_and(|b| panel.contains(pos2(b.x0 as f32 + 1.0, b.y0 as f32 + 1.0))))+ .map(|n| n.accesskit_node().label().unwrap_or_default())+ .collect()+}++/// Put the keyboard on the first row the way Tab does: from the search field, the menu button,+/// then the list.+fn tab_into_list(h: &mut Harness<'_, EffectcraftApp>) {+ h.get_by_label("Search effects and presets").focus();+ h.run_steps(3);+ key(h, Key::Tab, Modifiers::NONE);+ assert_eq!(focused(h).map(|f| f.1), Some("Effects & Presets options".to_string()), "Tab leaves the search field for the options button");+ key(h, Key::Tab, Modifiers::NONE);+}++#[test]+fn tab_reaches_the_list_once_and_leaves_it() {+ let mut h = harness();+ tab_into_list(&mut h);+ let (role, name) = focused(&h).expect("a row has the focus");+ assert_eq!(role, Role::TreeItem);+ assert!(!name.is_empty());+ // The first row is a folder: no star. The next Tab leaves the list instead of walking the+ // hundreds of effects.+ key(&mut h, Key::Tab, Modifiers::NONE);+ let after = focused(&h);+ assert!(after.as_ref().is_none_or(|(r, _)| *r != Role::TreeItem), "the second Tab is past the list: {after:?}");+}++#[test]+fn arrows_home_end_move_the_cursor_and_the_focus() {+ let mut h = harness();+ tab_into_list(&mut h);+ let first = focused(&h).unwrap().1;+ assert_eq!(selected_rows(&h), Vec::<String>::new(), "Tab alone selects nothing");+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ let second = focused(&h).unwrap().1;+ assert_ne!(first, second, "Down Arrow moves to the next row");+ assert_eq!(selected_rows(&h), vec![second.clone()], "the row the cursor is on is selected");+ key(&mut h, Key::ArrowUp, Modifiers::NONE);+ assert_eq!(focused(&h).unwrap().1, first);+ key(&mut h, Key::End, Modifiers::NONE);+ let last = focused(&h).unwrap().1;+ assert_ne!(last, first, "End goes to the last row");+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ assert_eq!(focused(&h).unwrap().1, last, "Down Arrow stays on the last row");+ key(&mut h, Key::Home, Modifiers::NONE);+ assert_eq!(focused(&h).unwrap().1, first, "Home goes to the first row");+ key(&mut h, Key::PageDown, Modifiers::NONE);+ assert_ne!(focused(&h).unwrap().1, first, "Page Down moves a page");+ // The cursor row is scrolled into view: its node is on screen.+ let name = focused(&h).unwrap().1;+ let r = h.get_by_label(&name).rect();+ assert!(r.min.y >= 0.0 && r.max.y <= 1000.0, "the focused row is on screen: {r:?}");+}++#[test]+fn right_and_left_open_and_close_folders_and_step_through_the_tree() {+ let mut h = harness();+ h.state_mut().ui.effects_search.clear();+ tab_into_list(&mut h);+ // Walk to a category folder (not the presets folder).+ let mut guard = 0;+ loop {+ let n = focused(&h).unwrap().1;+ if n == "Blur & Sharpen" {+ break;+ }+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ guard += 1;+ assert!(guard < 40, "no Blur & Sharpen folder reached");+ }+ let folder = h.get_by_label("Blur & Sharpen");+ assert_eq!(folder.accesskit_node().data().is_expanded(), Some(false));+ assert_eq!(folder.accesskit_node().data().level(), Some(1));+ key(&mut h, Key::ArrowRight, Modifiers::NONE);+ assert!(h.state().ui.effects_open.contains("Blur & Sharpen"), "Right Arrow opens the folder");+ assert_eq!(h.get_by_label("Blur & Sharpen").accesskit_node().data().is_expanded(), Some(true));+ key(&mut h, Key::ArrowRight, Modifiers::NONE);+ let child = focused(&h).unwrap();+ assert_eq!(child.0, Role::TreeItem);+ assert_ne!(child.1, "Blur & Sharpen", "Right Arrow on an open folder steps into it");+ assert_eq!(h.get_by_label(&child.1).accesskit_node().data().level(), Some(2));+ key(&mut h, Key::ArrowLeft, Modifiers::NONE);+ assert_eq!(focused(&h).unwrap().1, "Blur & Sharpen", "Left Arrow on an effect steps out to its folder");+ key(&mut h, Key::ArrowLeft, Modifiers::NONE);+ assert!(!h.state().ui.effects_open.contains("Blur & Sharpen"), "Left Arrow closes the folder");+ key(&mut h, Key::Enter, Modifiers::NONE);+ assert!(h.state().ui.effects_open.contains("Blur & Sharpen"), "Enter opens a closed folder");+ key(&mut h, Key::Space, Modifiers::NONE);+ assert!(!h.state().ui.effects_open.contains("Blur & Sharpen"), "Space closes it again");+}++#[test]+fn enter_and_space_apply_an_effect_to_the_selected_layer() {+ for apply_key in [Key::Enter, Key::Space] {+ let mut h = harness();+ tab_into_list(&mut h);+ h.state_mut().ui.effects_open.insert("Blur & Sharpen".into());+ h.run_steps(3);+ let mut guard = 0;+ while focused(&h).map(|f| f.1) != Some("Blur & Sharpen".to_string()) {+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ guard += 1;+ assert!(guard < 40);+ }+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ let effect = focused(&h).unwrap().1;+ assert!(h.state().session.state.last_effect.is_none());+ key(&mut h, apply_key, Modifiers::NONE);+ let applied = h.state().session.state.last_effect.clone();+ assert!(applied.is_some(), "{apply_key:?} on `{effect}` applies it to the selected layer");+ let pb = &h.state().playback;+ assert!(!pb.playing && !pb.caching && pb.plan.is_none(), "{apply_key:?} on a focused row is the row's, it does not start a preview");+ }+}++#[test]+fn the_star_is_a_named_button_on_the_cursor_row_and_enter_toggles_it() {+ let mut h = harness();+ tab_into_list(&mut h);+ h.state_mut().ui.effects_open.insert("Blur & Sharpen".into());+ h.run_steps(3);+ while focused(&h).map(|f| f.1) != Some("Blur & Sharpen".to_string()) {+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ }+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ let effect = focused(&h).unwrap().1;+ key(&mut h, Key::Tab, Modifiers::NONE);+ let (role, name) = focused(&h).expect("the star has the focus");+ assert_eq!(role, Role::Button);+ assert_eq!(name, format!("Add to favorites: {effect}"));+ key(&mut h, Key::Enter, Modifiers::NONE);+ assert_eq!(h.state().session.prefs.effects_favorites.len(), 1, "Enter on the star adds the favourite");+ let (_, name) = focused(&h).expect("the star keeps the focus");+ assert_eq!(name, format!("Remove from favorites: {effect}"));+}++#[test]+fn the_search_field_keeps_its_arrows_and_the_layer_does_not_nudge() {+ let mut h = harness();+ h.get_by_label("Search effects and presets").focus();+ h.run_steps(3);+ h.get_by_label("Search effects and presets").type_text("blur");+ h.run_steps(3);+ assert_eq!(h.state().ui.effects_search, "blur");+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ assert!(selected_rows(&h).is_empty(), "arrows in the search field belong to the field");+ // A click on a row, then the arrows: the list moves, the selected layer stays where it is.+ let layer_before = layer_position(&h);+ h.state_mut().ui.effects_search.clear();+ h.run_steps(3);+ click(&mut h, "effects.category.presets");+ assert_eq!(h.state().ui.focused, PanelKind::EffectsPresets);+ key(&mut h, Key::ArrowDown, Modifiers::NONE);+ assert_eq!(selected_rows(&h).len(), 1, "the arrows work after a click, without keyboard focus on a row");+ key(&mut h, Key::ArrowRight, Modifiers::NONE);+ assert_eq!(layer_position(&h), layer_before, "the arrow keys did not nudge the selected layer");+}++fn layer_position(h: &Harness<'_, EffectcraftApp>) -> String {+ let s = &h.state().session;+ let comp = s.active_comp().expect("a comp");+ let layer = comp.layers.first().expect("a layer");+ format!("{:?}", layer.transform())+}++#[test]+fn rows_and_controls_have_names_roles_and_states() {+ let mut h = harness();+ h.state_mut().ui.effects_open.insert("Blur & Sharpen".into());+ h.state_mut().session.prefs.toggle_effect_favorite("ec.blur.gaussian");+ h.run_steps(4);+ assert_eq!(h.get_by_label("Search effects and presets").accesskit_node().role(), Role::TextInput);+ let menu = h.get_by_label("Effects & Presets options");+ assert_eq!(menu.accesskit_node().role(), Role::Button);+ assert_eq!(menu.accesskit_node().data().is_expanded(), Some(false), "the options button says its menu is closed");+ let folder = h.get_by_label("Blur & Sharpen");+ assert_eq!(folder.accesskit_node().role(), Role::TreeItem);+ assert_eq!(folder.accesskit_node().data().is_expanded(), Some(true));+ assert_eq!(folder.accesskit_node().is_selected(), Some(false));+ let favorites = h.get_by_label("Favorites");+ assert_eq!(favorites.accesskit_node().data().is_expanded(), Some(false));+ // Every effect row in an open category is a leaf at depth 2.+ let leaves: Vec<_> =+ h.root().children_recursive().filter(|n| n.accesskit_node().role() == Role::TreeItem && n.accesskit_node().data().level() == Some(2)).collect();+ assert!(!leaves.is_empty());+ assert!(leaves.iter().all(|n| n.accesskit_node().data().is_expanded().is_none()), "effects are leaves: they have no open state");- assert!(h.query_by_label_contains("Remove from favorites: ").is_none(), "a favourite hidden in a closed Favorites folder draws no rows");++ let gaussian_rows = h++ .root()++ .children_recursive()++ .filter(|n| n.accesskit_node().role() == Role::TreeItem && n.accesskit_node().label().as_deref() == Some("Gaussian Blur"))++ .count();++ assert!(gaussian_rows <= 1, "a favourite hidden in a closed Favorites folder draws no rows");+ assert!(h.query_all_by_label_contains("Add to favorites: ").count() > 1, "the effects' stars are named");+}++/// A pick from the options menu with the mouse leaves no widget with the keyboard focus, and Enter+/// after a click in the panel is the panel's: it opens or applies the row and does not start the+/// layer rename the Timeline binds to Enter.+#[test]+fn mouse_picks_leave_no_focus_and_enter_after_a_click_is_the_panels() {+ let mut h = harness();+ click(&mut h, "effects.menu");+ assert!(h.ctx.memory(|m| m.focused()).is_none(), "opening the menu with the mouse takes no keyboard focus");+ h.get_by_label_contains("Alphabetical").click();+ h.run_steps(4);+ assert!(h.ctx.memory(|m| m.focused()).is_none(), "choosing an entry with the mouse leaves no keyboard focus");+ assert!(h.state().ui.effects_view.alphabetical);+ h.state_mut().ui.effects_view.alphabetical = false;+ h.run_steps(3);+ click(&mut h, "effects.category.presets");+ let open = h.state().ui.effects_open.contains("presets");+ key(&mut h, Key::Enter, Modifiers::NONE);+ assert_ne!(h.state().ui.effects_open.contains("presets"), open, "Enter toggles the clicked folder");+ assert!(h.state().auto.query("timeline.layer.").iter().all(|e| !e.id.ends_with(".nameEdit")), "no layer rename started");+}diff --cc docs/ui-parity.mdindex 03e012245,d4473c266..cbb936271--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@@ -41,9 -41,8 +41,8 @@@ cover shape paths and masks, corner-ver## Estimate- **≈ 60–120 h**: the open interaction issues above (25–45 h, about 0.2–0.5 h each with a scripted- test), 3D gizmos 8–15 h, multi-monitor panels 10–20 h, the 26.x interface changes 10–20 h, an- accessibility pass 12–25 h (the first slice, three panels and the audit, is done). Checking feel against After Effects needs the owner's Mac with After+ **≈ 60–110 h**: the open interaction issues above (25–45 h, about 0.2–0.5 h each with a scripted-test), 3D gizmos 8–15 h, the 26.x interface changes 10–20 h, an accessibility pass 15–30 h. Checking feel against After Effects needs the owner's Mac with After++test), 3D gizmos 8–15 h, the 26.x interface changes 10–20 h, an accessibility pass 12–25 h (the first slice, three panels and the audit, is done). Checking feel against After Effects needs the owner's Mac with AfterEffects running; most of the rest parallelises.## Revision history