[librsvg/librsvg-2.50] Add test with a percentage viewport
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.50] Add test with a percentage viewport
- Date: Fri, 2 Oct 2020 19:24:37 +0000 (UTC)
commit e3be54e0fa0fe750383aa856da432b946362ea09
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Sep 29 16:20:20 2020 -0500
Add test with a percentage viewport
librsvg_crate/tests/intrinsic_dimensions.rs | 33 +++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
---
diff --git a/librsvg_crate/tests/intrinsic_dimensions.rs b/librsvg_crate/tests/intrinsic_dimensions.rs
index ff0363ea..43c8bbbe 100644
--- a/librsvg_crate/tests/intrinsic_dimensions.rs
+++ b/librsvg_crate/tests/intrinsic_dimensions.rs
@@ -208,6 +208,39 @@ fn layer_geometry_with_no_intrinsic_dimensions() {
assert_eq!((ink_r, logical_r), (rect, rect));
}
+#[test]
+fn layer_geometry_with_percentage_viewport() {
+ let svg = load_svg(
+ br#"<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="50%">
+ <rect x="10" y="20" width="50" height="40"/>
+</svg>
+"#,
+ );
+
+ let renderer = CairoRenderer::new(&svg);
+
+ let viewport = cairo::Rectangle {
+ x: 100.0,
+ y: 100.0,
+ width: 100.0,
+ height: 100.0,
+ };
+
+ let (ink_r, logical_r) = renderer.geometry_for_layer(None, &viewport).unwrap();
+
+ // Lack of viewBox means we use an identity transform, so the <rect> is just
+ // offset by (100, 100) because of the viewport.
+ let rect = cairo::Rectangle {
+ x: 110.0,
+ y: 120.0,
+ width: 50.0,
+ height: 40.0,
+ };
+
+ assert_eq!((ink_r, logical_r), (rect, rect));
+}
+
#[test]
fn layer_geometry_with_percent_viewport() {
let svg = load_svg(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]