mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-28 17:19:31 +01:00
test(engine): typed hostile PPM table and an in-range fuzz index; shell fixes before CI (M5)
This commit is contained in:
1 parent
c441f489ef
commit
9a45a3db29
3 files changed
+8
-11
No files matched your search
@@ -147,8 +147,9 @@ fn pictures_are_read_from_a_pipe_with_every_size_checked() {
|
||||
// Larger than asked for, other kinds of image, and headers that lie.
|
||||
assert!(read_ppm(&mut &ppm(9, 2, 0)[..], 8, 8).unwrap_err().contains("larger"));
|
||||
assert!(read_ppm(&mut &ppm(2, 9, 0)[..], 8, 8).is_err());
|
||||
for bad in [&b"P5\n1 1\n255\n\0"[..], b"P6\n0 1\n255\n", b"P6\n1 1\n65535\n\0\0\0\0\0\0", b"P6\n1 -1\n255\n\0\0\0", b"P6 # note\n1 1\n255\n\0\0\0", b"P6\n9999999999 1\n255\n", b"P6\n1 1\n255", b"\x89PNG\r\n\x1a\n", b"P6\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n1 1\n255\n\0\0\0"] {
|
||||
assert!(read_ppm(&mut &bad[..], 4096, 4096).is_err(), "{:?}", String::from_utf8_lossy(bad));
|
||||
let hostile: [&[u8]; 9] = [&b"P5\n1 1\n255\n\0"[..], b"P6\n0 1\n255\n", b"P6\n1 1\n65535\n\0\0\0\0\0\0", b"P6\n1 -1\n255\n\0\0\0", b"P6 # note\n1 1\n255\n\0\0\0", b"P6\n9999999999 1\n255\n", b"P6\n1 1\n255", b"\x89PNG\r\n\x1a\n", b"P6\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n1 1\n255\n\0\0\0"];
|
||||
for bad in hostile {
|
||||
assert!(read_ppm(&mut &*bad, 4096, 4096).is_err(), "{:?}", String::from_utf8_lossy(bad));
|
||||
}
|
||||
// A header promising the largest picture with nothing behind it fails without a crash.
|
||||
assert!(read_ppm(&mut &b"P6\n4096 4096\n255\n"[..], 4096, 4096).is_err());
|
||||
@@ -166,7 +167,7 @@ fn fuzz_hostile_pictures_never_panic() {
|
||||
let at = rng.below(bytes.len().max(1));
|
||||
match rng.below(3) {
|
||||
0 => bytes.truncate(at),
|
||||
1 if at < bytes.len() => bytes[at] = b"0123456789 \nP6\xff"[rng.below(16)],
|
||||
1 if at < bytes.len() => bytes[at] = b"0123456789 \nP6\xff"[rng.below(15)],
|
||||
_ => bytes.insert(at.min(bytes.len()), b"0123456789 \n"[rng.below(12)]),
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1386,7 +1386,7 @@ impl App {
|
||||
}
|
||||
self.perform_here("file.import_video", json!({"path": clip.display().to_string(), "mode": "reference"}));
|
||||
// Traced over it, on the layer above: an outline in ink, as a rotoscoper draws.
|
||||
self.run("timeline.new_layer", json!({"name": "Tracing"}));
|
||||
self.run("layer.new", json!({"name": "Tracing"}));
|
||||
let stage = self.s.doc.stage;
|
||||
let (cx, cy) = (stage.width as f32 * 0.5, stage.height as f32 * 0.5);
|
||||
let ring: Vec<[f32; 2]> = (0..=72).map(|i| (i as f32 * 5.0).to_radians()).map(|a| [cx + a.cos() * 118.0, cy + a.sin() * 118.0]).collect();
|
||||
|
||||
+3
-7
@@ -182,6 +182,7 @@ fn poll(app: &mut App, ctx: &egui::Context) {
|
||||
app.video_import = Some(d);
|
||||
return;
|
||||
}
|
||||
// i18n-exempt: an engine-style message, translated where it is shown
|
||||
Err(TryRecvError::Disconnected) => Err(EngineError::State("the video could not be read".into())),
|
||||
};
|
||||
// Done, one way or another: the window closes.
|
||||
@@ -211,11 +212,6 @@ pub fn cancel(app: &mut App) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the window is open (it takes the keyboard, as a dialog does).
|
||||
pub fn is_open(app: &App) -> bool {
|
||||
app.video_import.is_some()
|
||||
}
|
||||
|
||||
pub fn window(app: &mut App, ctx: &egui::Context) {
|
||||
poll(app, ctx);
|
||||
let Some(mut d) = app.video_import.take() else { return };
|
||||
@@ -306,10 +302,10 @@ fn form(app: &App, ui: &mut egui::Ui, d: &mut VideoImport, probe: &Probe) {
|
||||
// What the file is: numbers in the data face.
|
||||
let mut facts = format!("{} × {}", probe.width, probe.height);
|
||||
if let Some(s) = probe.duration {
|
||||
facts.push_str(&format!(" · {s:.2} s"));
|
||||
facts.push_str(&format!(" · {s:.2} s")); // i18n-exempt: a number with its unit
|
||||
}
|
||||
if let Some(f) = probe.fps {
|
||||
facts.push_str(&format!(" · {f:.2} fps"));
|
||||
facts.push_str(&format!(" · {f:.2} fps")); // i18n-exempt: a number with its unit
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(text(Type::Data, facts).color(T.text_dim));
|
||||
|
||||
Reference in new issue
Block a user