use bone_render::{IconInstance, IconPipeline, Style};

mod common;

use common::{extent_square, make_context};

#[test]
fn icon_pipeline_draws_visible_pixels() {
    let extent = extent_square(64);
    let ctx = make_context(extent);
    let mut pipeline = IconPipeline::new(ctx.gpu(), ctx.color_format());

    let style = Style::light();
    let Ok(cleared) = ctx.render_clear(&style) else {
        panic!("render_clear failed");
    };

    let viewport_px = [64.0, 64.0];
    let instance = IconInstance::new([8.0, 8.0, 48.0, 48.0], 0, [1.0, 1.0, 1.0, 1.0]);
    pipeline.upload(viewport_px, &[instance]);
    ctx.render_passes(|encoder, color, _pick, _depth| {
        pipeline.draw_range(encoder, color, 0..1);
    });
    let Ok(drawn) = ctx.capture() else {
        panic!("capture failed");
    };

    assert_ne!(
        cleared.rgba(),
        drawn.rgba(),
        "icon draw left the framebuffer unchanged; shader or sampling regressed",
    );
}
