[librsvg: 1/8] Start adding tests for the legacy sizing algorithm




commit fa4711e9192c6d103a30561e2bde295c791a1da8
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Sep 30 16:49:14 2021 -0500

    Start adding tests for the legacy sizing algorithm
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/595>

 tests/Makefile.am          |  1 +
 tests/src/legacy_sizing.rs | 31 +++++++++++++++++++++++++++++++
 tests/src/main.rs          |  3 +++
 3 files changed, 35 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cedb30f2..11cd4ebf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,6 +7,7 @@ test_sources =                          \
        src/errors.rs                   \
        src/filters.rs                  \
        src/intrinsic_dimensions.rs     \
+       src/legacy_sizing.rs            \
        src/loading_crash.rs            \
        src/main.rs                     \
        src/primitives.rs               \
diff --git a/tests/src/legacy_sizing.rs b/tests/src/legacy_sizing.rs
new file mode 100644
index 00000000..c8a9cb65
--- /dev/null
+++ b/tests/src/legacy_sizing.rs
@@ -0,0 +1,31 @@
+use cairo;
+
+use librsvg::{rsvg_convert_only::LegacySize, CairoRenderer};
+
+use crate::utils::load_svg;
+
+#[test]
+fn just_viewbox_uses_viewbox_size() {
+    let svg = load_svg(
+        br#"<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; viewBox="0 0 100 200"/>
+"#,
+    )
+        .unwrap();
+
+    assert_eq!(
+        CairoRenderer::new(&svg).legacy_layer_geometry(None).unwrap(),
+        (cairo::Rectangle {
+            x: 0.0,
+            y: 0.0,
+            width: 100.0,
+            height: 200.0,
+        },
+         cairo::Rectangle {
+             x: 0.0,
+             y: 0.0,
+             width: 100.0,
+             height: 200.0,
+         })
+    );
+}
diff --git a/tests/src/main.rs b/tests/src/main.rs
index 79a323b0..c560f8b1 100644
--- a/tests/src/main.rs
+++ b/tests/src/main.rs
@@ -23,6 +23,9 @@ mod filters;
 #[cfg(test)]
 mod intrinsic_dimensions;
 
+#[cfg(test)]
+mod legacy_sizing;
+
 #[cfg(test)]
 mod loading_crash;
 


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