Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Merge pull request #3106 from CapSoftware/fix/gpui-instant-crash-recovery
Richie McIlroyc33d7d6ab228
diff --cc apps/desktop-gpui/src/upload.rsindex 14f42282d,53878a197..2e9c4aa6f--- a/apps/desktop-gpui/src/upload.rs+++ b/apps/desktop-gpui/src/upload.rs@@@ -2791,60 -2746,58 +2791,112 @@@ mod tests}}+ /// The finished segment manifest this app uploads, checked against the+ /// files the web server's own parser is tested with+ /// (`apps/web/__tests__/unit/desktop-segments-manifest-contract.test.ts`),+ /// so neither side can change the format without the other noticing. Run+ /// with `CAP_UPDATE_CONTRACT_FIXTURES=1` to rewrite the files after an+ /// intended change.+ #[test]+ fn finished_segment_manifests_match_the_server_contract_fixtures() {+ let fixtures = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))+ .join("../web/__tests__/fixtures/desktop-segments");+ for (name, audio) in [("with-audio", 2), ("video-only", 0)] {+ let mut manifest = SegmentUploadManifest::default();+ manifest.record(&segment_event(0, 0.0, true, SegmentMediaType::Video));+ for (index, duration) in [(1, 2.0), (2, 2.0), (3, 1.25)] {+ manifest.record(&segment_event(+ index,+ duration,+ false,+ SegmentMediaType::Video,+ ));+ }+ if audio > 0 {+ manifest.record(&segment_event(0, 0.0, true, SegmentMediaType::Audio));+ for index in 1..=audio {+ manifest.record(&segment_event(index, 3.0, false, SegmentMediaType::Audio));+ }+ }+ manifest.is_complete = true;+ let uploaded = serde_json::to_value(&manifest).unwrap();+ let path = fixtures.join(format!("finished-manifest-{name}.json"));+ if std::env::var_os("CAP_UPDATE_CONTRACT_FIXTURES").is_some() {+ std::fs::create_dir_all(&fixtures).unwrap();+ let mut json = Vec::new();+ let formatter = serde_json::ser::PrettyFormatter::with_indent(b"\t");+ let mut serializer = serde_json::Serializer::with_formatter(&mut json, formatter);+ serde::Serialize::serialize(&uploaded, &mut serializer).unwrap();+ json.push(b'\n');+ std::fs::write(&path, json).unwrap();+ }+ let fixture: serde_json::Value = serde_json::from_slice(+ &std::fs::read(&path).unwrap_or_else(|error| panic!("{}: {error}", path.display())),+ )+ .unwrap();+ assert_eq!(+ fixture,+ uploaded,+ "{} no longer matches what the app uploads",+ path.display()+ );+ }+ }++ #[test]+ fn recorded_length_sums_the_complete_local_video_track() {+ let mut manifest = SegmentUploadManifest::default();+ manifest.record(&segment_event(0, 0.0, true, SegmentMediaType::Video));+ manifest.record(&segment_event(2, 2.0, false, SegmentMediaType::Video));+ manifest.record(&segment_event(1, 2.0, false, SegmentMediaType::Video));+ manifest.record(&segment_event(3, 0.5, false, SegmentMediaType::Video));+ manifest.record(&segment_event(1, 2.0, false, SegmentMediaType::Audio));++ let value: Value =+ serde_json::from_slice(&recorded_length_json(&manifest).unwrap()).unwrap();+ assert_eq!(+ value,+ json!({ "version": 1, "duration": 4.5, "video_segments": 3, "audio_segments": 1 })+ );+ }++ #[test]+ fn recorded_length_is_skipped_without_a_usable_video_length() {+ assert!(recorded_length_json(&SegmentUploadManifest::default()).is_none());+ for duration in [0.0, f64::NAN, f64::INFINITY] {+ let mut manifest = SegmentUploadManifest::default();+ manifest.record(&segment_event(1, duration, false, SegmentMediaType::Video));+ assert!(recorded_length_json(&manifest).is_none(), "{duration}");+ }+ }++ #[tokio::test]+ async fn alongside_never_waits_for_its_side_task() {+ let side_ran = Arc::new(AtomicBool::new(false));+ let flag = side_ran.clone();+ let output = alongside(async { 7 }, async move {+ std::future::pending::<()>().await;+ flag.store(true, Ordering::SeqCst);+ })+ .await;+ assert_eq!(output, 7);+ assert!(!side_ran.load(Ordering::SeqCst));+ }++ #[tokio::test]+ async fn alongside_finishes_its_main_task_after_a_quick_side_task() {+ let (sender, receiver) = tokio::sync::oneshot::channel::<u32>();+ let side_ran = Arc::new(AtomicBool::new(false));+ let flag = side_ran.clone();+ let output = alongside(async { receiver.await.unwrap() }, async move {+ flag.store(true, Ordering::SeqCst);+ sender.send(9).unwrap();+ })+ .await;+ assert_eq!(output, 9);+ assert!(side_ran.load(Ordering::SeqCst));+ }+#[test]fn segment_manifest_requires_init_and_orders_video_and_audio() {let mut manifest = SegmentUploadManifest::default();