Port of the Python/PyQt6 app: same library database, playlists, hero panel, lyrics, tag editor, MusicBrainz/cover tools, CD ripping, MPRIS and tray. New: right-click 'Set <tag> to "value"' writes the clicked cell's tag into every selected file (with undo). The seek bar now runs off a monotonic position clock so it can't jump back and forth. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
46 lines
2.1 KiB
Rust
46 lines
2.1 KiB
Rust
//! Tag writing round trips on freshly generated files (never touches real music).
|
|
|
|
use mulberry::tags::{self, Field};
|
|
|
|
fn make(dir: &std::path::Path, name: &str, args: &[&str]) -> String {
|
|
let path = dir.join(name);
|
|
let st = std::process::Command::new("ffmpeg")
|
|
.args(["-v", "quiet", "-y", "-f", "lavfi", "-i", "sine=frequency=440:duration=1"])
|
|
.args(args)
|
|
.arg(&path)
|
|
.status()
|
|
.expect("ffmpeg");
|
|
assert!(st.success(), "ffmpeg failed for {name}");
|
|
path.to_string_lossy().into_owned()
|
|
}
|
|
|
|
#[test]
|
|
fn set_album_roundtrip_all_formats() {
|
|
let dir = std::env::temp_dir().join(format!("mulberry-tagtest-{}", std::process::id()));
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
let files = [
|
|
make(&dir, "a.opus", &["-c:a", "libopus"]),
|
|
make(&dir, "b.flac", &["-c:a", "flac"]),
|
|
make(&dir, "c.mp3", &["-c:a", "libmp3lame"]),
|
|
make(&dir, "d.m4a", &["-c:a", "aac"]),
|
|
make(&dir, "e.ogg", &["-c:a", "libvorbis"]),
|
|
make(&dir, "f.wav", &["-c:a", "pcm_s16le"]),
|
|
];
|
|
for f in &files {
|
|
tags::write_tags(f, &[(Field::Album, "Disclaimer II".into()), (Field::Artist, "Seether".into()), (Field::Title, "Gasoline".into()), (Field::Year, "2002".into()), (Field::Track, "7".into())]).unwrap_or_else(|e| panic!("{f}: {e}"));
|
|
let s = tags::read_song(f).unwrap_or_else(|| panic!("{f}: unreadable"));
|
|
assert_eq!(s.album, "Disclaimer II", "{f}");
|
|
assert_eq!(s.artist, "Seether", "{f}");
|
|
assert_eq!(s.title, "Gasoline", "{f}");
|
|
assert_eq!(s.year, 2002, "{f}");
|
|
assert_eq!(s.track, 7, "{f}");
|
|
// changing one field must not drop the others
|
|
tags::write_tags(f, &[(Field::Album, "Other".into())]).unwrap();
|
|
let s = tags::read_song(f).unwrap();
|
|
assert_eq!((s.album.as_str(), s.artist.as_str()), ("Other", "Seether"), "{f}");
|
|
// clearing
|
|
tags::write_tags(f, &[(Field::Album, String::new())]).unwrap();
|
|
assert_eq!(tags::read_song(f).unwrap().album, "", "{f}");
|
|
}
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
}
|