forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

polish4.rs151 lines, 6.2 KiBHistoryRawDownload
1//! Round-4 GUI polish: row fit, card padding, plurals, popup-look lists, the
2//! About box, tooltips, the Export tab and the viewer menu. No `TestAppContext`
3//! here, so each check is a pure function or a scan of the wiring.
4
5use super::*;
6use crate::ui::widgets::spans_cover;
7use crate::count_noun;
8use keymap::ActionId;
9
10/// REDESIGN §3.8: a media row is 64px with a 50px poster, name, one caption
11/// line and a chip line (18 + 16 + 18), and a refused row stays the same height.
12#[test]
13fn a_media_row_is_64px_and_a_refused_row_does_not_grow() {
14 use crate::ui::dock_stance::{SOURCE_ROW_H, source_row_h};
15 const { assert!(SOURCE_ROW_H >= 50. + 2. * 6.) };
16 assert_eq!(SOURCE_ROW_H, 64.);
17 assert_eq!(source_row_h(false), source_row_h(true));
18}
19
20/// Card rows are inset on both sides, so a slider's knob at the end of its
21/// bar and the last chip of a row never touch the card's right edge.
22#[test]
23fn card_rows_are_padded_on_both_sides() {
24 for file in ["color", "silence", "transform", "mix"] {
25 let text = src_text(&format!("ui/cards/{file}.rs"));
26 assert!(!text.contains(".pl(px(6.))"), "{file}.rs has a row inset on the left only");
27 }
28}
29
30#[test]
31fn counts_are_pluralised_in_words() {
32 assert_eq!(count_noun(1, "silence", "silences"), "1 silence");
33 assert_eq!(count_noun(0, "silence", "silences"), "0 silences");
34 assert_eq!(count_noun(2, "silence", "silences"), "2 silences");
35 // No message ships a "(s)" any more.
36 for file in ["player/cards.rs", "subs.rs", "player/library.rs"] {
37 let code: String = src_text(file)
38 .lines()
39 .filter(|l| !l.trim_start().starts_with("//"))
40 .collect::<Vec<_>>()
41 .join("\n");
42 for stale in ["clip(s)", "caption(s)", "track(s)"] {
43 assert!(!code.contains(stale), "{file} still says {stale}");
44 }
45 }
46 assert!(src_text("player/cards.rs").contains("count_noun(count, \"silence\", \"silences\")"));
47}
48
49/// A normal toast is not cut short: the bar gives it the room the format and
50/// verbs on the right leave, up to a wide cap.
51#[test]
52fn a_toast_is_wide_enough_for_an_ordinary_message() {
53 let line = "1 silence cut on V1+A1 — other tracks untouched — 2.7s shorter · undo Ctrl+Z";
54 assert!(crate::ui::popup::text_w(line, 14., false) < crate::ui::stance::TOAST_MAX_W);
55 assert!(src_text("ui/stance.rs").contains(".max_w(px(TOAST_MAX_W))"));
56}
57
58/// The effects add-list is the shared popup row on a popup-look plate.
59#[test]
60fn the_effects_add_list_wears_the_popup_look() {
61 let text = src_text("ui/cards/effects.rs");
62 assert!(text.contains("popup_row_icon((\"effects-kind\""));
63 assert!(!text.contains("chip((\"effects-kind\""));
64 assert!(text.contains("kit::plate("));
65}
66
67/// The range hints fit one line of the dock: no orphan "(I and O)".
68#[test]
69fn the_range_hints_are_short() {
70 let none = crate::export_ui::range_options(None, false, 900, 30.);
71 let late = crate::export_ui::range_options(None, true, 900, 30.);
72 for why in [none.marks_off.unwrap(), late.marks_off.unwrap()] {
73 let line = format!("off \u{2014} {why}");
74 assert!(line.chars().count() <= 50, "{line}");
75 assert!(!line.contains('('), "{line}");
76 }
77}
78
79/// A preset that the settings equal is the one that shows checked; Custom is
80/// for settings that equal none.
81#[test]
82fn the_matching_preset_is_checked_and_custom_only_when_none_match() {
83 use crate::export_ui::{matching_preset, picked_with};
84 for p in engine::export_presets::presets() {
85 let picked = picked_with(picked_with_default(), p);
86 assert_eq!(matching_preset(picked, Some(p.id)).map(|m| m.id), Some(p.id), "{}", p.id);
87 }
88 let first = &engine::export_presets::presets()[0];
89 let off = crate::export_ui::Picked { bps: 123_456, ..picked_with(picked_with_default(), first) };
90 assert!(matching_preset(off, None).is_none());
91}
92
93fn picked_with_default() -> crate::export_ui::Picked {
94 crate::export_ui::Picked {
95 format: Format::Mp4,
96 bps: 0,
97 audio_kbps: 128,
98 size: None,
99 depth: None,
100 loudness: None,
101 prores: Default::default(),
102 hdr: Default::default(),
103 }
104}
105
106/// A dock list row's plate only appears to say why it is refused; one that
107/// repeats the row's own words is gone.
108#[test]
109fn a_dock_verb_row_has_no_tooltip_unless_refused() {
110 let text = src_text("ui/dock_stance.rs");
111 let body = &text[text.find("fn section_verb(").expect("section_verb")..];
112 let at = body.find("action_hover").expect("the refusal plate");
113 assert!(body[..at].contains(".when(!on"), "the plate must be inside the refused branch");
114}
115
116#[test]
117fn the_lane_bed_has_no_hover_plate_over_its_clips() {
118 assert!(spans_cover([(30, 60), (200, 10)], 30));
119 assert!(spans_cover([(30, 60), (200, 10)], 89));
120 assert!(!spans_cover([(30, 60), (200, 10)], 90));
121 assert!(!spans_cover([(30, 60), (200, 10)], 150));
122 assert!(!spans_cover([], 0));
123 // The empty bed says nothing on hover: the drop highlight is its feedback.
124 let lane = src_text("ui/bench_stance/lane.rs");
125 assert!(!lane.contains("BedTip") && !lane.contains("Drop media here to add it to this track"));
126}
127
128/// Export done on a visible Export tab is its own panel; no toast beside it.
129#[test]
130fn the_export_outcome_toast_is_skipped_while_the_tab_shows_it() {
131 let body = fn_body("poll_export");
132 assert!(body.contains("export_tab_visible"), "{body}");
133 let visible = fn_body("export_tab_visible");
134 assert!(visible.contains("export_open") && visible.contains("keys_open"));
135}
136
137/// The viewer's menu: existing actions only, each with a label, none unbound.
138#[test]
139fn the_viewer_menu_offers_existing_actions_only() {
140 let keymap = crate::keymap::Keymap::defaults();
141 for a in crate::menus::VIEWER_ITEMS {
142 assert!(ActionId::ALL.contains(&a));
143 assert!(!a.label().is_empty());
144 assert!(!keymap.display(a).contains("unbound"), "{a:?}");
145 }
146 for want in [ActionId::Play, ActionId::Screenshot, ActionId::Settings] {
147 assert!(crate::menus::VIEWER_ITEMS.contains(&want), "{want:?}");
148 }
149 assert!(fn_body("open_viewer_menu").contains("self.menu_allowed()"));
150 assert!(src_text("ui/stance.rs").contains("open_viewer_menu"));
151}