| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | use super::*; |
| 6 | use crate::player::caption_cues::{cue_secs, scrubbed_us}; |
| 7 | |
| 8 | #[test] |
| 9 | fn a_scrubbed_caption_number_moves_by_frames_and_clamps() { |
| 10 | |
| 11 | assert_eq!(scrubbed_us(2_000_000, 0., false, 25.), 2_000_000); |
| 12 | assert_eq!(scrubbed_us(2_000_000, 50., false, 25.), 3_000_000); |
| 13 | |
| 14 | assert_eq!(scrubbed_us(2_000_000, 100., true, 25.), 2_200_000); |
| 15 | |
| 16 | assert_eq!(scrubbed_us(100_000, -1_000., false, 25.), 0); |
| 17 | assert_eq!(scrubbed_us(35_000_000_000, 1_000_000., false, 25.), 36_000_000_000); |
| 18 | |
| 19 | assert_eq!(scrubbed_us(2_000_000, 50., false, 0.), 3_000_000); |
| 20 | } |
| 21 | |
| 22 | #[test] |
| 23 | fn a_caption_number_reads_in_seconds_with_two_places() { |
| 24 | assert_eq!(cue_secs(1_840_000), "1.84"); |
| 25 | assert_eq!(cue_secs(0), "0.00"); |
| 26 | } |
| 27 | |
| 28 | #[test] |
| 29 | fn a_selected_caption_panel_has_its_actions_and_read_only_length() { |
| 30 | let card = src_text("ui/cards/caption.rs"); |
| 31 | for label in ["Split at playhead", "Merge with next", "Delete", "Caption {} of {}"] { |
| 32 | assert!(card.contains(label), "{label}"); |
| 33 | } |
| 34 | |
| 35 | for run in ["split_cue_at_playhead", "merge_cue_with_next", "delete_cue_at"] { |
| 36 | assert!(card.contains(run), "{run}"); |
| 37 | } |
| 38 | |
| 39 | assert!(!card.contains("num(\"caption-length\""), "length is read-only"); |
| 40 | |
| 41 | let cues = src_text("player/caption_cues.rs"); |
| 42 | assert!(cues.contains("fn cue_num_scrub_end") && cues.contains("set_cue_times")); |
| 43 | } |
| 44 | |
| 45 | #[test] |
| 46 | fn the_empty_clip_hero_waits_for_nothing_selected() { |
| 47 | let dock = src_text("ui/dock_stance.rs"); |
| 48 | |
| 49 | assert!(dock.contains("let empty = anchor.is_none() && !player.clip_card_open() && !title_up && !cue_up;")); |
| 50 | |
| 51 | let at = dock.find("if cue_up {").expect("the caption branch"); |
| 52 | let branch = &dock[at..at + 260]; |
| 53 | assert!(branch.contains("player.caption_card(cx)") && branch.contains("subtitle_style_card"), "{branch}"); |
| 54 | } |