Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Timeline: test a regular trim that leaves a transition longer than its clips

dotCooCoodbed07f0983c
diff --git a/crates/edit/src/tests.rs b/crates/edit/src/tests.rs
index 9a99193ed..978453a90 100644
--- a/crates/edit/src/tests.rs
+++ b/crates/edit/src/tests.rs
@@ -563,6 +563,33 @@ fn a_transition_stays_within_its_clips_after_a_regular_trim_or_speed_change() {
}
}
+/// A regular trim that leaves the two clips of a transition shorter than it, together, shortens
+/// the transition to the clips.
+#[test]
+fn a_regular_trim_shortens_a_transition_longer_than_its_clips() {
+ let mut fx = Fx::new();
+ let v1 = fx.v(0);
+ let a = fx.put(v1, 0, 2, 10);
+ let b = fx.put(v1, 2, 10, 10);
+ fx.seq.track_mut(v1).unwrap().transitions = vec![Transition {
+ id: TransitionId(1),
+ effect: filmcraft_project::find_effect("cross_dissolve").unwrap().instance(),
+ start: f(0),
+ duration: f(4),
+ from: Some(a),
+ to: Some(b),
+ align: filmcraft_project::TransitionAlign::StartAtCut,
+ reverse: false,
+ }];
+ let mut n = fx.next;
+ trim(&mut fx.seq, b, Edge::Out, TrimMode::Regular, -f(9), &mut Fx::ctx(&mut n)).unwrap();
+ assert_eq!(fx.spans(v1), vec![(0, 2), (2, 1)]);
+ let tr = &fx.seq.track(v1).unwrap().transitions[0];
+ assert_eq!((tr.start, tr.duration), (f(0), f(3)), "the transition covers both clips and no more");
+ assert_eq!(tr.align, filmcraft_project::TransitionAlign::CenterAtCut);
+ fx.seq.check().unwrap();
+}
+
#[test]
fn transitions_travel_with_moved_clips() {
// V1: a [0,10) fading in, b [10,20), c [20,30); b→c crossfade, c fading out