[librsvg: 1/15] tests/src/primitive_geometries.rs: Start a new suite of tests for the geometries of primitives
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/15] tests/src/primitive_geometries.rs: Start a new suite of tests for the geometries of primitives
- Date: Tue, 10 May 2022 02:13:50 +0000 (UTC)
commit 0c1be141222a48140ebcc36195e6de03d5d0119a
Author: Federico Mena Quintero <federico gnome org>
Date: Mon May 2 17:45:52 2022 -0500
tests/src/primitive_geometries.rs: Start a new suite of tests for the geometries of primitives
Just a plain rectangle for now.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/697>
tests/Makefile.am | 1 +
tests/src/main.rs | 3 +++
tests/src/primitive_geometries.rs | 47 +++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b020af3a0..cbc6a5995 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,6 +10,7 @@ test_sources = \
src/legacy_sizing.rs \
src/loading_crash.rs \
src/main.rs \
+ src/primitive_geometries.rs \
src/primitives.rs \
src/reference.rs \
src/reference_utils.rs \
diff --git a/tests/src/main.rs b/tests/src/main.rs
index 8e12b9e52..71bc4a09c 100644
--- a/tests/src/main.rs
+++ b/tests/src/main.rs
@@ -28,6 +28,9 @@ mod loading_crash;
#[cfg(test)]
mod predicates;
+#[cfg(test)]
+mod primitive_geometries;
+
#[cfg(test)]
mod primitives;
diff --git a/tests/src/primitive_geometries.rs b/tests/src/primitive_geometries.rs
new file mode 100644
index 000000000..dea05c963
--- /dev/null
+++ b/tests/src/primitive_geometries.rs
@@ -0,0 +1,47 @@
+use cairo;
+use librsvg::CairoRenderer;
+
+use crate::utils::load_svg;
+
+#[test]
+fn rect() {
+ 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"/>
+</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: 10.0,
+ y: 20.0,
+ width: 30.0,
+ height: 40.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]