forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

caps.rs82 lines, 4.0 KiBHistoryRawDownload
1//! Captions as an NLE draws them: a block per cue with its words inside, edits through the
2//! engine's cue ops, the plain tool names, and the subtitle style card built from kit rows.
3
4use super::*;
5use crate::player::caption_cues::{CueGrab, dragged_times};
6
7#[test]
8fn a_caption_drag_stays_between_its_neighbours() {
9 let (orig, room) = ((3_000_000, 5_000_000), (2_000_000, 6_000_000));
10 assert_eq!(dragged_times(CueGrab::Start, orig, room, 0, 0), (2_000_000, 5_000_000));
11 assert_eq!(dragged_times(CueGrab::End, orig, room, 0, 9_000_000), (3_000_000, 6_000_000));
12 assert_eq!(dragged_times(CueGrab::Body, orig, room, 4_000_000, 9_000_000), (4_000_000, 6_000_000));
13}
14
15#[test]
16fn speech_models_have_plain_names() {
17 assert_eq!(crate::creator::model_label("tiny"), "Fast");
18 assert_eq!(crate::creator::model_label("base"), "Balanced");
19 assert_eq!(crate::creator::model_label("small"), "Accurate");
20 assert_eq!(crate::creator::model_label("medium"), "Medium");
21}
22
23#[test]
24fn each_caption_is_a_block_with_a_menu_an_editor_and_an_edit_hint() {
25 let sub = src_text("ui/bench_stance/sub.rs");
26 for row in ["Edit text", "Split at playhead", "Merge with next", "Delete", "Style\\u{2026}"] {
27 assert!(sub.contains(row), "the caption menu offers {row}");
28 }
29 assert!(sub.contains("Double-click to edit"), "the hover tooltip names the double-click");
30 assert!(sub.contains("start_cue_drag(lane, track, cue, CueGrab::Body"), "a body press arms the move");
31 assert!(sub.contains("kit::plate"), "the editor and the menu are on the one plate");
32 let cues = src_text("player/caption_cues.rs");
33 for call in ["set_cue_times", "merge_cue_next", "split_cues_at", "delete_cue"] {
34 assert!(cues.contains(call), "{call} is one engine edit, so one undo step");
35 }
36}
37
38#[test]
39fn the_tools_card_leads_with_the_transcript_and_names_its_tabs_plainly() {
40 let tools = src_text("ui/cards/tools.rs");
41 assert!(tools.contains("From the transcript") && tools.contains("Listen again"));
42 assert!(tools.contains("segmented_equal"), "the tab strip is kit segments, never clipped");
43 let p = src_text("player/tools.rs");
44 for name in ["Normalize", "Captions", "Filler words", "Voiceover"] {
45 assert!(p.contains(&format!("\"{name}\"")), "{name} is a tab name");
46 }
47}
48
49#[test]
50fn the_subtitle_style_card_is_settings_style_rows() {
51 let s = src_text("ui/cards/substyle.rs");
52 assert!(s.contains("HIGHLIGHT_SWATCHES") && s.contains("subtitle-hl-hex"), "highlight swatches, then the hex on its own row");
53 assert!(s.contains("segmented_equal") && s.contains("kit::switch"));
54 assert!(s.contains("LABEL_W"), "every label shares one column");
55}
56
57/// Only Settings and the project dialogs cover the room. A card docked in the right panel never
58/// blocks the timeline's menus, drags or clicks, however many are up at once.
59#[test]
60fn only_real_overlays_cover_the_room() {
61 let cards = src_text("player/cards.rs");
62 let at = cards.find("pub(crate) fn covers_room").unwrap();
63 let body = &cards[at..at + 120];
64 assert!(body.contains("self.settings_open || self.proj_dialog.is_some()"), "{body}");
65 for docked in ["export_open", "eq_open", "tools", "markers_open", "silence_open", "subtitle_style_open"] {
66 assert!(!body.contains(docked), "{docked} is docked and must not cover the room");
67 }
68}
69
70/// A selected caption is the Clip tab's own panel: its words, start, end and length, then the
71/// Subtitle style section -- never the "Select a clip" hero.
72#[test]
73fn a_selected_caption_has_its_own_panel_in_the_clip_tab() {
74 let dock = src_text("ui/dock_stance.rs");
75 assert!(dock.contains("player.sel_cue_span().is_some()") && dock.contains("player.caption_card(cx)"));
76 let card = src_text("ui/cards/caption.rs");
77 for id in ["caption-text", "caption-start", "caption-end", "caption-length"] {
78 assert!(card.contains(id), "{id}");
79 }
80 let cues = src_text("player/caption_cues.rs");
81 assert!(cues.contains("set_cue_times"), "a number is one cue edit, so one undo step");
82}