Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(verify): transitions on every boundary for odd editing export seeds, caption templates independent of the export projection

Richie McIlroy74a769df0e18
diff --git a/crates/verify/tests/captions.rs b/crates/verify/tests/captions.rs
index c548614c5..f9c2932c8 100644
--- a/crates/verify/tests/captions.rs
+++ b/crates/verify/tests/captions.rs
@@ -1347,6 +1347,7 @@ fn templates(
rt: &tokio::runtime::Runtime,
project: &common::Project,
texts: &[String],
+ durations: &[f64],
out: &Path,
) -> Result<Vec<(String, CaptionPixels)>, String> {
let slot = 0.3;
@@ -1368,6 +1369,9 @@ fn templates(
settings: render_settings(),
source_timed: true,
});
+ // Projected here so the templates do not depend on the export's own
+ // projection (which `render_*` checks).
+ cap_project::synchronize_captions(&mut config, durations);
let duration = edits::timeline(&config).duration();
if texts.len() as f64 * slot > duration {
return Err(format!(
@@ -1430,11 +1434,17 @@ fn render_case(
let mut texts: Vec<String> = pieces.iter().map(|p| p.text.clone()).collect();
texts.sort();
texts.dedup();
- let result =
- templates(rt, &project, &texts, &dir.path().join("templates.mp4")).and_then(|templates| {
- render_export(rt, &project, config.clone(), &dir.path().join("out.mp4"))
- .map(|frames| (templates, frames))
- });
+ let result = templates(
+ rt,
+ &project,
+ &texts,
+ &durations,
+ &dir.path().join("templates.mp4"),
+ )
+ .and_then(|templates| {
+ render_export(rt, &project, config.clone(), &dir.path().join("out.mp4"))
+ .map(|frames| (templates, frames))
+ });
match result {
Err(e) => case.problem("error", format!("export failed: {e}")),
Ok((templates, frames)) => {
diff --git a/crates/verify/tests/editing.rs b/crates/verify/tests/editing.rs
index 7e37ba977..926e6f2c0 100644
--- a/crates/verify/tests/editing.rs
+++ b/crates/verify/tests/editing.rs
@@ -313,7 +313,7 @@ fn export_cases(spec: cap_verify::fixture::FixtureSpec, seeds: u64) -> Vec<Strin
}
let mut rng = Rng::new(0xED17_1000 ^ (seed << 8) ^ spec.name.len() as u64);
let count = rng.range(3, 8) as usize;
- let ops = edits::random_sequence(
+ let mut ops = edits::random_sequence(
&mut rng,
&base,
count,
@@ -322,6 +322,17 @@ fn export_cases(spec: cap_verify::fixture::FixtureSpec, seeds: u64) -> Vec<Strin
holds: false,
},
);
+ // Odd seeds end with a transition on every boundary, long ones and
+ // ones below the minimum included, so clamping is always exercised.
+ if seed % 2 == 1 {
+ let segments = edits::timeline(&edits::replay(&base, &ops)).segments.len();
+ for segment in 1..segments {
+ ops.push(Op::Transition {
+ segment,
+ duration: [3.0, 0.02, 0.4][(segment + seed as usize) % 3],
+ });
+ }
+ }
let config = edits::replay(&base, &ops);
let mut case = Case::new(&id);
case.note(format!("ops: {ops:?}"));