[librsvg] Add test for computing the geometry of a specific element



commit 1342431d1a316d223a24e15a5301037fa89a3baf
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Feb 19 09:37:15 2019 -0600

    Add test for computing the geometry of a specific element

 librsvg_crate/tests/intrinsic-dimensions.rs | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
---
diff --git a/librsvg_crate/tests/intrinsic-dimensions.rs b/librsvg_crate/tests/intrinsic-dimensions.rs
index fabaaa77..d52b4d4f 100644
--- a/librsvg_crate/tests/intrinsic-dimensions.rs
+++ b/librsvg_crate/tests/intrinsic-dimensions.rs
@@ -80,3 +80,26 @@ fn root_geometry_with_percent_viewport() {
 
     assert_eq!((ink_r, logical_r), (rect, rect));
 }
+
+#[test]
+fn element_geometry_with_percent_viewport() {
+    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="foo" x="10" y="20" width="30" height="40"/>
+</svg>
+"#,
+    );
+
+    let renderer = svg.get_cairo_renderer();
+    let (ink_r, logical_r) = renderer.get_geometry_for_element(Some("#foo")).unwrap();
+
+    let rect = cairo::Rectangle {
+        x: 10.0,
+        y: 20.0,
+        width: 30.0,
+        height: 40.0,
+    };
+
+    assert_eq!((ink_r, logical_r), (rect, rect));
+}


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