Critical: undo toast now trashes only batch output files (not entire dir), JPEG scanline write errors propagated, selective metadata write result returned. High: zero-dimension guards in ResizeConfig/fit_within, negative aspect ratio rejection, FM integration toggle infinite recursion guard, saturating counter arithmetic in executor. Medium: PNG compression level passed to oxipng, pct mode updates job_config, external file loading updates step indicator, CLI undo removes history entries, watch config write failures reported, fast-copy path reads image dimensions for rename templates, discovery excludes unprocessable formats (heic/svg/ico/jxl), CLI warns on invalid algorithm/overwrite values, resolve_collision trailing dot fix, generation guards on all preview threads to cancel stale results, default DPI aligned to 0, watermark text width uses char count not byte length. Low: binary path escaped in Nautilus extension, file dialog filter aligned with discovery, reset_wizard clears preset_mode and output_dir.
60 lines
1.9 KiB
Rust
60 lines
1.9 KiB
Rust
use pixstrip_core::preset::*;
|
|
use pixstrip_core::operations::*;
|
|
|
|
#[test]
|
|
fn builtin_preset_blog_photos() {
|
|
let preset = Preset::builtin_blog_photos();
|
|
assert_eq!(preset.name, "Blog Photos");
|
|
assert!(preset.resize.is_some());
|
|
assert!(preset.compress.is_some());
|
|
assert!(preset.metadata.is_some());
|
|
assert!(!preset.is_custom);
|
|
}
|
|
|
|
#[test]
|
|
fn builtin_preset_privacy_clean() {
|
|
let preset = Preset::builtin_privacy_clean();
|
|
assert_eq!(preset.name, "Privacy Clean");
|
|
assert!(preset.resize.is_none());
|
|
assert!(preset.compress.is_none());
|
|
assert!(preset.metadata.is_some());
|
|
if let Some(MetadataConfig::StripAll) = &preset.metadata {
|
|
// correct
|
|
} else {
|
|
panic!("Expected StripAll metadata config");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn preset_serialization_roundtrip() {
|
|
let preset = Preset::builtin_blog_photos();
|
|
let json = serde_json::to_string_pretty(&preset).unwrap();
|
|
let deserialized: Preset = serde_json::from_str(&json).unwrap();
|
|
assert_eq!(deserialized.name, preset.name);
|
|
assert_eq!(deserialized.is_custom, preset.is_custom);
|
|
}
|
|
|
|
#[test]
|
|
fn all_builtin_presets() {
|
|
let presets = Preset::all_builtins();
|
|
assert_eq!(presets.len(), 9);
|
|
let names: Vec<&str> = presets.iter().map(|p| p.name.as_str()).collect();
|
|
assert!(names.contains(&"Blog Photos"));
|
|
assert!(names.contains(&"Social Media"));
|
|
assert!(names.contains(&"Web Optimization"));
|
|
assert!(names.contains(&"Email Friendly"));
|
|
assert!(names.contains(&"Privacy Clean"));
|
|
assert!(names.contains(&"Photographer Export"));
|
|
assert!(names.contains(&"Archive Compress"));
|
|
assert!(names.contains(&"Fediverse Ready"));
|
|
}
|
|
|
|
#[test]
|
|
fn preset_to_processing_job() {
|
|
let preset = Preset::builtin_blog_photos();
|
|
let job = preset.to_job("/tmp/input/", "/tmp/output/");
|
|
assert!(job.resize.is_some());
|
|
assert!(job.compress.is_some());
|
|
assert!(job.metadata.is_some());
|
|
}
|