libcaesium/tests/gif.rs

90 lines
2.8 KiB
Rust
Raw Normal View History

2021-10-23 17:18:52 +02:00
use std::sync::Once;
use std::fs;
static INIT: Once = Once::new();
pub fn initialize(file: &str) {
INIT.call_once(|| {
if fs::metadata(file).is_ok() {
fs::remove_file(file).unwrap();
}
});
}
pub fn cleanup(file: &str) {
if fs::metadata(file).is_ok() {
fs::remove_file(file).unwrap();
}
}
// #[test]
// fn compress_20() {
// let output = "tests/samples/output/compressed_20.gif";
// initialize(output);
2022-02-23 17:50:48 +01:00
// let mut params = caesium::initialize_parameters();
2022-02-12 14:10:12 +01:00
// params.gif.quality = 20;
2022-02-23 17:50:48 +01:00
// caesium::compress(String::from("tests/samples/uncompressed_은하.gif"),
2021-10-23 17:18:52 +02:00
// String::from(output),
// params)
// .unwrap();
// assert!(std::path::Path::new(output).exists());
2022-02-12 14:10:12 +01:00
// assert_eq!(infer::get_from_path(output).unwrap().unwrap().mime_type(), "image/webp");
2021-10-23 17:18:52 +02:00
// cleanup(output)
// }
//
// #[test]
// fn compress_50() {
// let output = "tests/samples/output/compressed_50.gif";
// initialize(output);
2022-02-23 17:50:48 +01:00
// let mut params = caesium::initialize_parameters();
2021-10-23 17:18:52 +02:00
// params.gif.level = 50;
2022-02-23 17:50:48 +01:00
// caesium::compress(String::from("tests/samples/uncompressed_은하.gif"),
2021-10-23 17:18:52 +02:00
// String::from(output),
// params)
// .unwrap();
// assert!(std::path::Path::new(output).exists());
// cleanup(output)
// }
//
// #[test]
// fn compress_80() {
// let output = "tests/samples/output/compressed_80.gif";
// initialize(output);
2022-02-23 17:50:48 +01:00
// let mut params = caesium::initialize_parameters();
2021-10-23 17:18:52 +02:00
// params.gif.level = 80;
2022-02-23 17:50:48 +01:00
// caesium::compress(String::from("tests/samples/uncompressed_은하.gif"),
2021-10-23 17:18:52 +02:00
// String::from(output),
// params)
// .unwrap();
// assert!(std::path::Path::new(output).exists());
// cleanup(output)
// }
//
// #[test]
// fn compress_100() {
// let output = "tests/samples/output/compressed_100.gif";
// initialize(output);
2022-02-23 17:50:48 +01:00
// let mut params = caesium::initialize_parameters();
2021-10-23 17:18:52 +02:00
// params.gif.level = 100;
2022-02-23 17:50:48 +01:00
// caesium::compress(String::from("tests/samples/uncompressed_은하.gif"),
2021-10-23 17:18:52 +02:00
// String::from(output),
// params)
// .unwrap();
// assert!(std::path::Path::new(output).exists());
// cleanup(output)
// }
//
// #[test]
// fn optimize_gif() {
// let output = "tests/samples/output/optimized.gif";
// initialize(output);
2022-02-23 17:50:48 +01:00
// let mut params = caesium::initialize_parameters();
2021-10-23 17:18:52 +02:00
// params.optimize = true;
2022-02-23 17:50:48 +01:00
// caesium::compress(String::from("tests/samples/uncompressed_은하.gif"),
2021-10-23 17:18:52 +02:00
// String::from(output),
// params)
// .unwrap();
// assert!(std::path::Path::new(output).exists());
// cleanup(output)
// }