[librsvg: 2/4] New test for drawing to a non-image surface in the Rust tests




commit 3035e42b111e4e1334ff689ef95994986471fc45
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jun 24 11:11:16 2021 -0500

    New test for drawing to a non-image surface in the Rust tests
    
    This is slightly different from the one in tests/api.c - that one
    tests that the cr's transform is preserved.
    
    We'll leave that one as it is, and use the Rust one to test for the
    tricky code paths in drawing_ctx.rs.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/553>

 tests/src/bugs.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
---
diff --git a/tests/src/bugs.rs b/tests/src/bugs.rs
index c3a08ff4..a9358757 100644
--- a/tests/src/bugs.rs
+++ b/tests/src/bugs.rs
@@ -461,3 +461,32 @@ fn accepted_children_inside_clip_path() {
         .compare(&output_surf)
         .evaluate(&output_surf, "accepted_children_inside_clip_path");
 }
+
+#[test]
+fn can_draw_to_non_image_surface() {
+    let svg = load_svg(
+        br##"<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; width="100" height="400" viewBox="0 0 100 400">
+  <rect id="one" x="0" y="0" width="100" height="200" fill="rgb(0,255,0)"/>
+  <rect id="two" x="0" y="200" width="100" height="200" fill="rgb(0,0,255)"/>
+</svg>
+"##,
+    )
+    .unwrap();
+
+    let renderer = CairoRenderer::new(&svg);
+
+    let viewport = cairo::Rectangle {
+        x: 0.0,
+        y: 0.0,
+        width: 200.0,
+        height: 200.0,
+    };
+
+    let output = cairo::RecordingSurface::create(cairo::Content::ColorAlpha, viewport).unwrap();
+
+    let cr = cairo::Context::new(&output).expect("Failed to create a cairo context");
+    renderer
+        .render_document(&cr, &viewport)
+        .expect("Failed to render to non-image surface");
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]