use rsvg::test_utils::reference_utils::{Compare, Evaluate, Reference}; use rsvg::test_utils::{load_svg, render_document, SurfaceSize}; use rsvg::{test_compare_render_output, test_svg_reference}; #[test] fn invalid_filter_reference_cancels_filter_chain() { // The has a filter chain with two URLs listed, but the second one doesn't resolve. // The whole filter chain should be ignored. let svg = load_svg( br##" "##, ).unwrap(); let output_surf = render_document( &svg, SurfaceSize(400, 400), |_| (), cairo::Rectangle::new(0.0, 0.0, 400.0, 400.0), ) .unwrap(); let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 400, 400).unwrap(); { let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context"); cr.rectangle(100.0, 100.0, 200.0, 200.0); cr.set_source_rgb(0.0, 1.0, 0.0); cr.fill().unwrap(); } Reference::from_surface(reference_surf) .compare(&output_surf) .evaluate( &output_surf, "invalid_filter_reference_cancels_filter_chain", ); } #[test] fn non_filter_reference_cancels_filter_chain() { // The has a filter chain, but one of the URLs does not point to a . // The whole filter chain should be ignored. let svg = load_svg( br##" "##, ).unwrap(); let output_surf = render_document( &svg, SurfaceSize(400, 400), |_| (), cairo::Rectangle::new(0.0, 0.0, 400.0, 400.0), ) .unwrap(); let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 400, 400).unwrap(); { let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context"); cr.rectangle(100.0, 100.0, 200.0, 200.0); cr.set_source_rgb(0.0, 1.0, 0.0); cr.fill().unwrap(); } Reference::from_surface(reference_surf) .compare(&output_surf) .evaluate(&output_surf, "non_filter_reference_cancels_filter_chain"); } test_compare_render_output!( blur_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( brightness_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( contrast_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( dropshadow_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( grayscale_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( huerotate_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( invert_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( opacity_filter_func, 400, 400, br##" "##, br##" "## ); test_compare_render_output!( saturate_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( sepia_filter_func, 400, 400, br##" "##, br##" "##, ); test_compare_render_output!( mask_type, 200, 100, br##" "##, br##" "##, ); test_svg_reference!( bug_743_fe_drop_shadow, "tests/fixtures/reftests/svg2/bug743-fe-drop-shadow.svg", "tests/fixtures/reftests/svg2/bug743-fe-drop-shadow-ref.svg" );