Skip to content

Commit

Permalink
extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Nov 26, 2024
1 parent 2e9b4be commit f47be8f
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 6 deletions.
3 changes: 2 additions & 1 deletion apps/desktop/src-tauri/src/recording.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
let mut passed_duration = 0.0;

// multi-segment
// for segment in recording.segments {
// for segment in &completed_recording.segments {
// let start = passed_duration;
// passed_duration += segment.end - segment.start;
// segments.push(TimelineSegment {
Expand All @@ -227,6 +227,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
// });
// }

// single-segment
for i in (0..completed_recording.segments.len()).step_by(2) {
let start = passed_duration;
passed_duration +=
Expand Down
6 changes: 3 additions & 3 deletions crates/flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct Flags {

pub const FLAGS: Flags = Flags {
record_mouse: false, // cfg!(debug_assertions),
split: false,
pause_resume: false, // cfg!(debug_assertions),
zoom: false, // cfg!(debug_assertions),
split: false, // cfg!(debug_assertions),
pause_resume: cfg!(debug_assertions),
zoom: false, // cfg!(debug_assertions),
};
106 changes: 104 additions & 2 deletions crates/project/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,111 @@ impl MultipleSegment {

#[cfg(test)]
mod test {
use super::RecordingMeta;

fn test_meta_deserialize(s: &str) {
let _: RecordingMeta = serde_json::from_str(s).unwrap();
}

#[test]
fn single_segment() {}
fn single_segment() {
test_meta_deserialize(
r#"{
"pretty_name": "Cap 2024-11-15 at 16.35.36",
"sharing": null,
"display": {
"path": "content/display.mp4"
},
"camera": null,
"audio": null,
"segments": [
{
"start": 0.0,
"end": 10.683263063430786
}
],
"cursor": "cursor.json"
}"#,
);

test_meta_deserialize(
r#"{
"pretty_name": "Cap 2024-11-26 at 22.16.36",
"sharing": null,
"display": {
"path": "content/display.mp4"
},
"camera": {
"path": "content/camera.mp4"
},
"audio": {
"path": "content/audio-input.mp3"
},
"segments": [],
"cursor": "cursor.json"
}"#,
);
}

#[test]
fn multi_segment() {}
fn multi_segment() {
// single segment
test_meta_deserialize(
r#"{
"pretty_name": "Cap 2024-11-26 at 22.29.30",
"sharing": null,
"segments": [
{
"display": {
"path": "content/segments/segment-0/display.mp4"
},
"camera": {
"path": "content/segments/segment-0/camera.mp4"
},
"audio": {
"path": "content/segments/segment-0/audio-input.mp3"
}
}
],
"cursors": {
"0": "content/cursors/cursor_0.png",
"3": "content/cursors/cursor_3.png",
"2": "content/cursors/cursor_2.png",
"1": "content/cursors/cursor_1.png"
}
}"#,
);

// multi segment, no cursor
test_meta_deserialize(
r#"{
"pretty_name": "Cap 2024-11-26 at 22.32.26",
"sharing": null,
"segments": [
{
"display": {
"path": "content/segments/segment-0/display.mp4"
},
"camera": {
"path": "content/segments/segment-0/camera.mp4"
},
"audio": {
"path": "content/segments/segment-0/audio-input.mp3"
}
},
{
"display": {
"path": "content/segments/segment-1/display.mp4"
},
"camera": {
"path": "content/segments/segment-1/camera.mp4"
},
"audio": {
"path": "content/segments/segment-1/audio-input.mp3"
}
}
]
}"#,
);
}
}

0 comments on commit f47be8f

Please sign in to comment.