FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
style: cargo fmt the moved test files
aiongg806fbe8af568
diff --git a/apps/filmcraft/src/control_server/tests.rs b/apps/filmcraft/src/control_server/tests.rsindex 0e65bc2cb..e69ef964d 100644--- a/apps/filmcraft/src/control_server/tests.rs+++ b/apps/filmcraft/src/control_server/tests.rs@@ -41,12 +41,9 @@ fn http_request_closes_before_the_body_runs() {#[test]fn non_request_json_closes_the_connection() {- for junk in [- &b"[1,2]\n{\"method\":\"a\"}\n"[..],- b"{\"id\":1}\n{\"method\":\"a\"}\n",- b"{\"method\":5}\n{\"method\":\"a\"}\n",- b"\xff\xfe\n{\"method\":\"a\"}\n",- ] {+ for junk in+ [&b"[1,2]\n{\"method\":\"a\"}\n"[..], b"{\"id\":1}\n{\"method\":\"a\"}\n", b"{\"method\":5}\n{\"method\":\"a\"}\n", b"\xff\xfe\n{\"method\":\"a\"}\n"]+ {let (r, calls) = run(junk);assert!(calls.is_empty(), "{calls:?}");assert_eq!(r.len(), 1);@@ -246,8 +243,7 @@ fn missing_or_invalid_token_leaves_the_listener_closed() {#[test]fn unauthenticated_save_as_closes_before_any_command_runs() {- for token in- [Value::Null, json!(false), json!(42), json!([]), json!({}), json!(""), json!("a".repeat(64)), json!(&TOKEN[..63]), json!(format!("{TOKEN}0"))]+ for token in [Value::Null, json!(false), json!(42), json!([]), json!({}), json!(""), json!("a".repeat(64)), json!(&TOKEN[..63]), json!(format!("{TOKEN}0"))]{let mut request = json!({"id": 1, "method": "engine.execute", "params": {"command": "file.saveAs", "params": {"path": "/owner/project.fcproj"}}});if !token.is_null() {@@ -263,12 +259,8 @@ fn unauthenticated_save_as_closes_before_any_command_runs() {#[test]fn authentication_is_required_on_every_request() {- let input = format!(- "{}\n{}\n{}\n",- json!({"token": TOKEN, "method": "ui.inspect"}),- json!({"method": "app.quit"}),- json!({"token": TOKEN, "method": "app.quit"})- );+ let input =+ format!("{}\n{}\n{}\n", json!({"token": TOKEN, "method": "ui.inspect"}), json!({"method": "app.quit"}), json!({"token": TOKEN, "method": "app.quit"}));let (replies, calls) = run(input.as_bytes());assert_eq!(calls, ["ui.inspect"]);assert_eq!(replies.len(), 2);diff --git a/crates/automation/src/server/tests.rs b/crates/automation/src/server/tests.rsindex 1eb0bf7b1..d7dda01f4 100644--- a/crates/automation/src/server/tests.rs+++ b/crates/automation/src/server/tests.rs@@ -142,8 +142,7 @@ async fn strict_arguments_and_parse_errors() {let r = c.ask(json!({"jsonrpc":"2.0","id":6,"method":"ping"})).await;assert!(r["result"].is_object(), "{r}");// batch: stops at the first failure and reports both- let r =- c.call(7, "command_batch", json!({"steps": [{"id": "playhead.set", "params": {"seconds": 0.5}}, {"id": "no.such"}, {"id": "playhead.set"}]})).await;+ let r = c.call(7, "command_batch", json!({"steps": [{"id": "playhead.set", "params": {"seconds": 0.5}}, {"id": "no.such"}, {"id": "playhead.set"}]})).await;assert_eq!(r["result"]["isError"], true, "{r}");let v: Value = serde_json::from_str(r["result"]["content"][0]["text"].as_str().unwrap()).unwrap();assert_eq!((v["completed"].as_u64(), v["failed"].as_u64(), v["results"].as_array().map(Vec::len)), (Some(1), Some(1), Some(2)), "{v}");diff --git a/crates/codecs/src/gop/tests.rs b/crates/codecs/src/gop/tests.rsindex d577a110e..23cf9d7cc 100644--- a/crates/codecs/src/gop/tests.rs+++ b/crates/codecs/src/gop/tests.rs@@ -409,11 +409,7 @@ fn a_burst_of_single_requests_does_not_keep_every_decoder_and_frame() {assert_eq!(index_of(&c[k].frame(&s[k], 10_000).expect("frame")), 10);std::thread::sleep(Duration::from_millis(3));}- assert!(- pool.decoders.load(Ordering::Relaxed) <= HARD_DECODERS + 1,- "{} live decoders after a burst over {n} clips",- pool.decoders.load(Ordering::Relaxed)- );+ assert!(pool.decoders.load(Ordering::Relaxed) <= HARD_DECODERS + 1, "{} live decoders after a burst over {n} clips", pool.decoders.load(Ordering::Relaxed));// the clip asked last, and a clip in use together with it, keep theirs and carry onlet resets = s[n - 1].resets.load(Ordering::Relaxed);assert_eq!(index_of(&c[n - 1].frame(&s[n - 1], 11_000).expect("frame")), 11);diff --git a/crates/codecs/src/mp4/tests.rs b/crates/codecs/src/mp4/tests.rsindex 33744a58d..45910d333 100644--- a/crates/codecs/src/mp4/tests.rs+++ b/crates/codecs/src/mp4/tests.rs@@ -52,8 +52,7 @@ fn duration_follows_the_edit_list() {let skip = vec![Edit { segment_duration: 120, media_time: 1, media_rate: 0x10000 }];assert_eq!(frames(&Mp4Source::open("skip.mov", mov_with_edits(skip)).expect("open")), 3);// a one-frame empty edit, then all four frames: five frames, and the last one is there- let delayed =- vec![Edit { segment_duration: 40, media_time: -1, media_rate: 0x10000 }, Edit { segment_duration: 160, media_time: 0, media_rate: 0x10000 }];+ let delayed = vec![Edit { segment_duration: 40, media_time: -1, media_rate: 0x10000 }, Edit { segment_duration: 160, media_time: 0, media_rate: 0x10000 }];let s = Mp4Source::open("delayed.mov", mov_with_edits(delayed)).expect("open");assert_eq!(frames(&s), 5);assert!(s.video_frame(FrameRequest::full(Tick::from_rational(4, 1, 25))).is_ok());@@ -263,8 +262,7 @@ fn high_sps(profile: u8, chroma: u32, bits: u32) -> Vec<u8> {#[test]fn avc_pixel_format_comes_from_avcc_not_the_profile() {- let avc =- |profile: u8, sps: Vec<u8>, ext: Vec<u8>| CodecConfig::Avc(filmcraft_isobmff::AvcConfig { profile, sps: vec![sps], ext, ..Default::default() });+ let avc = |profile: u8, sps: Vec<u8>, ext: Vec<u8>| CodecConfig::Avc(filmcraft_isobmff::AvcConfig { profile, sps: vec![sps], ext, ..Default::default() });// High 4:2:2 at 10 and 8 bits, from the avcC extension (chroma_format 2, bit_depth_luma_minus8)assert_eq!(pixfmt_label(&avc(122, high_sps(122, 2, 10), vec![0xFE, 0xFA, 0xFA, 0])), "YUV 4:2:2 10-bit");assert_eq!(pixfmt_label(&avc(122, high_sps(122, 2, 8), vec![0xFE, 0xF8, 0xF8, 0])), "YUV 4:2:2 8-bit");diff --git a/crates/frame/src/tests.rs b/crates/frame/src/tests.rsindex 7ab661aad..310361b01 100644--- a/crates/frame/src/tests.rs+++ b/crates/frame/src/tests.rs@@ -234,10 +234,7 @@ fn sample_frames_sized(w: usize, h: usize) -> Vec<(&'static str, VideoFrame)> {alpha: Some(Arc::new(a16)),}),),- (- "yuv16 4:4:4",- mk(PixelData::Yuv16 { planes: [Arc::new(y16), Arc::new(c16.clone()), Arc::new(c16)], chroma: Chroma::C444, bits: 12, alpha: None }),- ),+ ("yuv16 4:4:4", mk(PixelData::Yuv16 { planes: [Arc::new(y16), Arc::new(c16.clone()), Arc::new(c16)], chroma: Chroma::C444, bits: 12, alpha: None })),]}diff --git a/crates/project/src/tests.rs b/crates/project/src/tests.rsindex 089aa20a3..7f682bb12 100644--- a/crates/project/src/tests.rs+++ b/crates/project/src/tests.rs@@ -140,8 +140,7 @@ fn placed_auto_points_resolve_once_the_source_size_is_final() {}let st = p.sequence(seq).unwrap().settings.clone();let point = |p: &Project, id: ClipId, k: &str| p.sequence(seq).unwrap().find_item(id).unwrap().1.effect("motion").unwrap().vec2_at(k, Tick::ZERO);- let (frame_centre, source_centre) =- (Vec2::new(st.width as f64 / 2.0, st.height as f64 / 2.0), Vec2::new(src.width as f64 / 2.0, src.height as f64 / 2.0));+ let (frame_centre, source_centre) = (Vec2::new(st.width as f64 / 2.0, st.height as f64 / 2.0), Vec2::new(src.width as f64 / 2.0, src.height as f64 / 2.0));// sequences that are not selected are left alonelet mut untouched = p.clone();untouched.resolve_placed_auto_points(|_| false, |_| true);diff --git a/crates/text/src/layout/tests.rs b/crates/text/src/layout/tests.rsindex 3d23e0a0d..94a51025a 100644--- a/crates/text/src/layout/tests.rs+++ b/crates/text/src/layout/tests.rs@@ -198,10 +198,7 @@ fn vertical_cells_keep_combining_marks_with_their_base() {assert_eq!(decomposed.lines[0].range, 0..3);assert_eq!(decomposed.lines[1].range, 3..4);assert_eq!(decomposed.text_len, 4, "retain the original UTF-8 source offsets");- assert_eq!(- decomposed.glyphs.iter().map(|g| (g.id, g.x, g.y)).collect::<Vec<_>>(),- composed.glyphs.iter().map(|g| (g.id, g.x, g.y)).collect::<Vec<_>>()- );+ assert_eq!(decomposed.glyphs.iter().map(|g| (g.id, g.x, g.y)).collect::<Vec<_>>(), composed.glyphs.iter().map(|g| (g.id, g.x, g.y)).collect::<Vec<_>>());assert_eq!(decomposed.bounds, composed.bounds);assert_eq!(decomposed.caret(0).1, decomposed.caret(1).1, "base and combining mark occupy the same cell");for text in ["葛\u{e0101}x", "👩\u{200d}👧x"] {diff --git a/crates/tts-text/src/normalize/tests.rs b/crates/tts-text/src/normalize/tests.rsindex b3a8a56bc..45e48fc4f 100644--- a/crates/tts-text/src/normalize/tests.rs+++ b/crates/tts-text/src/normalize/tests.rs@@ -71,10 +71,7 @@ fn cardinals() {words("999,999,999,999", Lang::EnUs),"nine hundred ninety-nine billion nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine");- assert_eq!(- words("123456789012", Lang::EnUs),- "one hundred twenty-three billion four hundred fifty-six million seven hundred eighty-nine thousand twelve"- );+ assert_eq!(words("123456789012", Lang::EnUs), "one hundred twenty-three billion four hundred fifty-six million seven hundred eighty-nine thousand twelve");}#[test]diff --git a/crates/tts-text/src/phonemize/tests.rs b/crates/tts-text/src/phonemize/tests.rsindex 8620a4011..6fba30797 100644--- a/crates/tts-text/src/phonemize/tests.rs+++ b/crates/tts-text/src/phonemize/tests.rs@@ -104,8 +104,7 @@ fn parses_cmudict() {#[test]fn skips_malformed_lines_and_counts_them() {- let input =- b";;; a comment\n\nGOOD AE1\nBADLINE\nONLYWORD\nWORD XX1 YY2\nBAD( AE1\nWORD(2) AA1\nWORD AE1 # trailing comment\nTRAIL AE1 T # note\n";+ let input = b";;; a comment\n\nGOOD AE1\nBADLINE\nONLYWORD\nWORD XX1 YY2\nBAD( AE1\nWORD(2) AA1\nWORD AE1 # trailing comment\nTRAIL AE1 T # note\n";let lex = Lexicon::parse_cmudict(input).unwrap();assert_eq!(lex.len(), 3); // GOOD, WORD (two pronunciations), TRAILassert_eq!(lex.skipped(), 4); // BADLINE, ONLYWORD, WORD XX1 YY2, BAD(@@ -284,10 +283,7 @@ fn chunks_are_bounded_and_split_at_punctuation() {// The split happened at commas: no chunk ends mid-word.for c in &chunks[..chunks.len() - 1] {let Chunk::Phonemes(p) = c else { continue };- assert!(- p.ends_with(',') || p.ends_with(';') || p.ends_with(':') || p.ends_with('w') || p.ends_with("ʌn") || p.ends_with("tˈu"),- "bad split: {p:?}"- );+ assert!(p.ends_with(',') || p.ends_with(';') || p.ends_with(':') || p.ends_with('w') || p.ends_with("ʌn") || p.ends_with("tˈu"), "bad split: {p:?}");}}diff --git a/crates/ui-egui/src/capture/tests.rs b/crates/ui-egui/src/capture/tests.rsindex 0122caa8c..6d1acb940 100644--- a/crates/ui-egui/src/capture/tests.rs+++ b/crates/ui-egui/src/capture/tests.rs@@ -15,13 +15,7 @@ fn app() -> FilmcraftApp {/// A fixed 800×600, 1 px/pt capture identity for the app's current document with no focus.fn geometry(app: &FilmcraftApp) -> CaptureGeometry {CaptureGeometry {- surface: SurfaceGeometry {- viewport: Some(egui::vec2(800.0, 600.0)),- pixels_per_point: 1.0,- max_texture_side: 8192,- minimized: false,- occluded: false,- },+ surface: SurfaceGeometry { viewport: Some(egui::vec2(800.0, 600.0)), pixels_per_point: 1.0, max_texture_side: 8192, minimized: false, occluded: false },document: active_document(app),focus: None,}@@ -142,10 +136,7 @@ fn downscaled_capture_crops_with_the_rendered_scale() {assert_eq!([reply["result"]["width"].as_u64(), reply["result"]["height"].as_u64()], [Some(200), Some(100)]);let decoded = image::load_from_memory(&std::fs::read(&path).expect("the saved crop")).expect("decode the saved crop").to_rgba8();assert_eq!(decoded.dimensions(), (200, 100));- assert!(- decoded.pixels().all(|pixel| *pixel == image::Rgba([255, 0, 0, 255])),- "the crop must select the red region where the downscaled surface drew it"- );+ assert!(decoded.pixels().all(|pixel| *pixel == image::Rgba([255, 0, 0, 255])), "the crop must select the red region where the downscaled surface drew it");}/// A 1.5x surface whose point size rounds up by one window pixel is still uncapped, so its@@ -265,13 +256,7 @@ fn near_limit_images_are_rejected_for_encode_buffer_memory() {// 8000×4000 RGBA is exactly 128,000,000 raw bytes, under the per-image bound, but the// crop/PNG/base64 copies make its real peak several times larger than the aggregate bound.app.capture_geometry = Some(CaptureGeometry {- surface: SurfaceGeometry {- viewport: Some(vec2(8000.0, 4000.0)),- pixels_per_point: 1.0,- max_texture_side: 16384,- minimized: false,- occluded: false,- },+ surface: SurfaceGeometry { viewport: Some(vec2(8000.0, 4000.0)), pixels_per_point: 1.0, max_texture_side: 16384, minimized: false, occluded: false },document: active_document(&app),focus: None,});@@ -370,13 +355,7 @@ fn mixed_order_geometry_failures_reject_every_shot_without_shifting_indices() {// A resize makes both queued shots need more crop/encode buffers than the aggregate// budget, so the geometry retry fails for the last shot first.app.capture_geometry = Some(CaptureGeometry {- surface: SurfaceGeometry {- viewport: Some(vec2(8000.0, 4000.0)),- pixels_per_point: 1.0,- max_texture_side: 16384,- minimized: false,- occluded: false,- },+ surface: SurfaceGeometry { viewport: Some(vec2(8000.0, 4000.0)), pixels_per_point: 1.0, max_texture_side: 16384, minimized: false, occluded: false },document: active_document(&app),focus: None,});