1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
extern crate jpeg_decoder as jpeg;
extern crate png;
extern crate walkdir;
use std::path::Path;
use std::fs::File;
//mod common;
//mod crashtest;
//mod reftest;
/*
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn included_file() {
const FILE: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/reftest/images/mozilla/jpg-progressive.jpg"));
let mut data = FILE;
let mut decoder = jpeg::Decoder::new(&mut data);
let ref_data = decoder.decode().unwrap();
let ref_info = decoder.info().unwrap();
let mut data = FILE;
decoder = jpeg::Decoder::new(&mut data);
decoder.read_info().unwrap();
let info = decoder.info().unwrap();
let data = decoder.decode().unwrap();
assert_eq!(info, decoder.info().unwrap());
assert_eq!(info, ref_info);
assert_eq!(data, ref_data);
}
#[test]
fn read_info() {
let path = Path::new("tests").join("reftest").join("images").join("mozilla").join("jpg-progressive.jpg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
let ref_data = decoder.decode().unwrap();
let ref_info = decoder.info().unwrap();
decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.read_info().unwrap();
let info = decoder.info().unwrap();
let data = decoder.decode().unwrap();
assert_eq!(info, decoder.info().unwrap());
assert_eq!(info, ref_info);
assert_eq!(data, ref_data);
}
#[test]
fn read_icc_profile() {
let path = Path::new("tests")
.join("reftest")
.join("images")
.join("mozilla")
.join("jpg-srgb-icc.jpg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.decode().unwrap();
let profile = decoder.icc_profile().unwrap();
// "acsp" is a mandatory string in ICC profile headers.
assert_eq!(&profile[36..40], b"acsp");
}
*/
// Test if chunks are concatenated in the correct order
#[test]
#[ignore = "broken, skipping"]
fn read_icc_profile_random_order() {
let path = Path::new("tests")
.join("icc")
.join("icc_chunk_order.jpeg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.decode().unwrap();
let profile = decoder.icc_profile().unwrap();
assert_eq!(profile.len(), 254);
for i in 1..=254 {
assert_eq!(profile[i - 1], i as u8);
}
}
// Check if ICC profiles with invalid chunk number 0 are discarded
#[test]
#[ignore = "broken, skipping"]
fn read_icc_profile_seq_no_0() {
let path = Path::new("tests")
.join("icc")
.join("icc_chunk_seq_no_0.jpeg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.decode().unwrap();
let profile = decoder.icc_profile();
assert!(profile.is_none());
}
// Check if ICC profiles with multiple chunks with the same number are discarded
#[test]
#[ignore = "broken, skipping"]
fn read_icc_profile_double_seq_no() {
let path = Path::new("tests")
.join("icc")
.join("icc_chunk_double_seq_no.jpeg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.decode().unwrap();
let profile = decoder.icc_profile();
assert!(profile.is_none());
}
// Check if ICC profiles with mismatching number of chunks and total chunk count are discarded
#[test]
#[ignore = "broken, skipping"]
fn read_icc_profile_chunk_count_mismatch() {
let path = Path::new("tests")
.join("icc")
.join("icc_chunk_count_mismatch.jpeg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.decode().unwrap();
let profile = decoder.icc_profile();
assert!(profile.is_none());
}
// Check if ICC profiles with missing chunk are discarded
#[test]
#[ignore = "broken, skipping"]
fn read_icc_profile_missing_chunk() {
let path = Path::new("tests")
.join("icc")
.join("icc_missing_chunk.jpeg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.decode().unwrap();
let profile = decoder.icc_profile();
assert!(profile.is_none());
}
/*
#[test]
fn read_exif_data() {
let path = Path::new("tests")
.join("reftest")
.join("images")
.join("ycck.jpg");
let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
decoder.decode().unwrap();
let exif_data = decoder.exif_data().unwrap();
// exif data start as a TIFF header
assert_eq!(&exif_data[0..8], b"\x49\x49\x2A\x00\x08\x00\x00\x00");
}*/
|