refactor(v0.2): вынести headless render в shturman-render (shell использует)
P6.1: общий хелпер render_to_png<C: ComponentHandle>(build, w, h, path) поверх Slint software-renderer (thread_local окно + set_platform once + draw + png). shturman-shell.render_screenshot теперь зовёт его; плумбинг-дубль удалён. png в shell → dev-deps (рендер в render-крейте, тест декодирует). Тесты зелёные. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Alexander <akotenev2003@gmail.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
//! Общий headless-рендер: произвольный Slint-компонент → непустой PNG (План 6 P6.1).
|
||||
|
||||
use shturman_render::render_to_png;
|
||||
|
||||
slint::slint! {
|
||||
export component Probe inherits Window {
|
||||
width: 64px; height: 48px; background: #101418;
|
||||
Rectangle { background: #ffffff; width: 20px; height: 20px; }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renders_component_to_nonempty_png() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("probe.png");
|
||||
render_to_png(|| Ok(Probe::new()?), 64, 48, &path).expect("render");
|
||||
|
||||
let dec = png::Decoder::new(std::fs::File::open(&path).unwrap());
|
||||
let mut r = dec.read_info().unwrap();
|
||||
assert_eq!((r.info().width, r.info().height), (64, 48));
|
||||
let mut buf = vec![0u8; r.output_buffer_size()];
|
||||
let info = r.next_frame(&mut buf).unwrap();
|
||||
let px = &buf[..info.buffer_size()];
|
||||
assert!(px.iter().any(|&b| b != px[0]), "кадр одноцветный");
|
||||
}
|
||||
Reference in New Issue
Block a user