forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

nocycle.rs120 lines, 5.3 KiBHistoryRawDownload
1//! Nothing in the window steps a multi-value setting to its next value on a press:
2//! a setting with more than two values is a list the person picks from, so the
3//! value they land on is the one they chose.
4
5use super::*;
6use crate::export_ui::{ease_label, fit_choices, resolution_choices};
7use crate::menus::{Choice, Pick};
8use engine::transform::KeyEase;
9use keymap::ActionId;
10
11/// The lines of `text` that are code or strings, not comments.
12fn live(text: &str) -> String {
13 text.lines().filter(|l| !l.trim_start().starts_with("//")).collect::<Vec<_>>().join("\n")
14}
15
16/// Spelled in two halves so this file never matches its own scan.
17fn press_to(verb: &str) -> String {
18 format!("{verb} to {}", "cycle")
19}
20
21#[test]
22fn no_handler_or_key_steps_a_setting_to_its_next_value() {
23 let src = ui_source();
24 // `cycle_on_key_down` is the Tab ring between panels, not a setting.
25 assert!(!src.replace("fn cycle_on_key_down(", "").contains("fn cycle_"), "a `cycle_*` handler is back in the window's source");
26 let act = live(&fn_body("run_action"));
27 for needle in ["cycle", ".next()", "next_fit", "next_resolution"] {
28 assert!(!act.contains(needle), "act() steps a value with `{needle}`");
29 }
30 // The three actions that used to step now open their list.
31 for arm in [
32 "ActionId::Resolution => self.open_picker(Pick::Resolution",
33 "ActionId::Fit => self.open_fit_list(",
34 "ActionId::KeyEasing => self.open_key_easing(",
35 ] {
36 assert!(act.contains(arm), "act() lacks `{arm}`");
37 }
38}
39
40#[test]
41fn no_user_visible_string_says_cycle() {
42 let src = live(&ui_source());
43 for verb in ["click", "press", "Click", "Press"] {
44 let phrase = press_to(verb);
45 assert!(!src.contains(&phrase), "user-visible `{phrase}`");
46 }
47 for action in ActionId::ALL {
48 let label = action.label().to_lowercase();
49 assert!(!label.contains("cycle") && !label.contains("next colour"), "{action:?}: {label}");
50 }
51 let marker = src_text("ui/cards/markers.rs");
52 assert!(!marker.contains("Next colour"), "the marker swatch still says it steps");
53}
54
55#[test]
56fn the_rows_that_became_lists_say_so_in_their_labels() {
57 assert_eq!(ActionId::Resolution.label(), "Project resolution…");
58 assert_eq!(ActionId::Fit.label(), "Fit to frame…");
59 assert_eq!(ActionId::KeyEasing.label(), "Key easing…");
60 assert_eq!(ActionId::SpeedRampFastSlowFast.label(), "Speed ramp fast-slow-fast");
61 assert_eq!(ActionId::ToggleProxies.label(), "Use proxies for playback");
62}
63
64#[test]
65fn key_easing_offers_every_easing_by_name() {
66 let names: Vec<_> = KeyEase::ALL.into_iter().map(ease_label).collect();
67 assert_eq!(names, ["Linear", "Ease in", "Ease out", "Ease in-out", "Hold"]);
68}
69
70#[test]
71fn the_resolution_and_fit_lists_hold_every_value_and_mark_one() {
72 let rows = resolution_choices((1920, 1080), (1920, 1080));
73 assert!(rows.len() >= 4);
74 assert_eq!(rows.iter().filter(|r| r.3).count(), 1);
75 assert!(rows.iter().all(|r| matches!(r.0, Choice::Size(..))));
76 let fits = fit_choices(Lane::V1, 0, FitPolicy::Fill, (1920, 1080));
77 assert_eq!(fits.len(), 4);
78 assert_eq!(fits.iter().filter(|r| r.3).count(), 1);
79 // The pickers exist for the new doors.
80 let _ = (Pick::KeyEase(engine::project::KeyKind::Placement), Pick::MarkerColor(0));
81}
82
83#[test]
84fn settings_says_what_it_means_in_words_a_person_uses() {
85 let page = live(&src_text("ui/settings_stance.rs"));
86 for jargon in ["stand-in", "\"Palette\"", "\"Auto proxies\"", "cd/m^2", "'Reference' tonemap"] {
87 assert!(!page.contains(jargon), "settings still says `{jargon}`");
88 }
89 assert!(page.contains("\"Theme\"") && page.contains("\"Make them on import\""));
90}
91
92/// The lists open next to what opened them: a menu row as a flyout beside it, a shortcut
93/// above the status-bar item it is about, a dock button under itself -- never at the pointer.
94#[test]
95fn every_list_opens_beside_the_thing_that_opened_it() {
96 let act = live(&fn_body("run_action"));
97 assert!(!act.contains("mouse_position"), "a shortcut opens a list at a stale pointer position");
98 for arm in [
99 "self.open_picker(Pick::Resolution, self.ledger_anchor(LedgerItem::Size)",
100 "self.open_fit_list(self.ledger_anchor(LedgerItem::Clip)",
101 "self.open_key_easing(self.ledger_anchor(LedgerItem::Clip)",
102 ] {
103 assert!(act.contains(arm), "act() lacks `{arm}`");
104 }
105 // The menu bar's rows are flyouts, not actions.
106 for action in [ActionId::Fit, ActionId::KeyEasing] {
107 let door = format!("Choice(ActionId::{action:?})");
108 assert!(src_text("ui/menubar.rs").contains(&door), "{action:?} is not a flyout row");
109 assert!(!src_text("ui/menubar.rs").contains(&format!("Act(ActionId::{action:?})")));
110 }
111 // The status bar's size and rate are the doors for the same two lists, and report where
112 // they paint so a shortcut can hang its list above them.
113 let ledger = src_text("ui/stance.rs");
114 assert!(ledger.contains("ledger_readout"), "the status bar lost `ledger_readout`");
115 // Dock and card buttons hang the list from their own foot, off the timeline floor.
116 assert!(src_text("ui/dock_stance.rs").contains("p.floored = false"));
117 assert!(src_text("ui/cards/markers.rs").contains("picker_under(Pick::MarkerColor"));
118 let overlays = src_text("ui/overlays.rs");
119 assert!(overlays.matches("!picker.floored").count() == 2);
120}