[librsvg: 2/15] Test stroked, and stroked/unfilled rectangles




commit 00c3909e443ae766809302c90e65b99e05740241
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon May 2 19:30:17 2022 -0500

    Test stroked, and stroked/unfilled rectangles
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/697>

 tests/src/primitive_geometries.rs | 86 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
---
diff --git a/tests/src/primitive_geometries.rs b/tests/src/primitive_geometries.rs
index dea05c963..dc28f37f2 100644
--- a/tests/src/primitive_geometries.rs
+++ b/tests/src/primitive_geometries.rs
@@ -45,3 +45,89 @@ fn rect() {
     assert_eq!(ink_rect, expected_ink);
     assert_eq!(logical_rect, expected_logical);
 }
+
+#[test]
+fn rect_stroke() {
+    let svg = load_svg(
+        br#"<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; width="100" height="100">
+  <rect id="a" x="10" y="20" width="30" height="40" stroke-width="10" stroke="black"/>
+</svg>
+"#,
+    )
+    .unwrap();
+
+    let renderer = CairoRenderer::new(&svg).test_mode(true);
+
+    let (ink_rect, logical_rect) = renderer
+        .geometry_for_layer(
+            Some("#a"),
+            &cairo::Rectangle {
+                x: 0.0,
+                y: 0.0,
+                width: 100.0,
+                height: 100.0,
+            },
+        )
+        .unwrap();
+
+    let expected_ink = cairo::Rectangle {
+        x: 5.0,
+        y: 15.0,
+        width: 40.0,
+        height: 50.0,
+    };
+
+    let expected_logical = cairo::Rectangle {
+        x: 10.0,
+        y: 20.0,
+        width: 30.0,
+        height: 40.0,
+    };
+
+    assert_eq!(ink_rect, expected_ink);
+    assert_eq!(logical_rect, expected_logical);
+}
+
+#[test]
+fn rect_stroke_unfilled() {
+    let svg = load_svg(
+        br#"<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; width="100" height="100">
+  <rect id="a" x="10" y="20" width="30" height="40" stroke-width="10" stroke="black" fill="none"/>
+</svg>
+"#,
+    )
+    .unwrap();
+
+    let renderer = CairoRenderer::new(&svg).test_mode(true);
+
+    let (ink_rect, logical_rect) = renderer
+        .geometry_for_layer(
+            Some("#a"),
+            &cairo::Rectangle {
+                x: 0.0,
+                y: 0.0,
+                width: 100.0,
+                height: 100.0,
+            },
+        )
+        .unwrap();
+
+    let expected_ink = cairo::Rectangle {
+        x: 5.0,
+        y: 15.0,
+        width: 40.0,
+        height: 50.0,
+    };
+
+    let expected_logical = cairo::Rectangle {
+        x: 10.0,
+        y: 20.0,
+        width: 30.0,
+        height: 40.0,
+    };
+
+    assert_eq!(ink_rect, expected_ink);
+    assert_eq!(logical_rect, expected_logical);
+}


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