[librsvg] Test for rsvg_handle_get_intrinsic_dimensions() and fix a bug, damnit
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Test for rsvg_handle_get_intrinsic_dimensions() and fix a bug, damnit
- Date: Thu, 28 Mar 2019 00:40:15 +0000 (UTC)
commit c1df6ad3e7972581ecf5d4f58a47386e1333c4a1
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Mar 27 18:39:13 2019 -0600
Test for rsvg_handle_get_intrinsic_dimensions() and fix a bug, damnit
rsvg_internals/src/c_api.rs | 2 +-
tests/api.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/c_api.rs b/rsvg_internals/src/c_api.rs
index 4a9b32d7..650ff543 100644
--- a/rsvg_internals/src/c_api.rs
+++ b/rsvg_internals/src/c_api.rs
@@ -880,7 +880,7 @@ pub unsafe extern "C" fn rsvg_rust_handle_get_intrinsic_dimensions(
let d = rhandle.get_intrinsic_dimensions();
let w = d.width.map(|l| l.to_length());
- let h = d.width.map(|l| l.to_length());
+ let h = d.height.map(|l| l.to_length());
let r = d.vbox.map(RsvgRectangle::from);
set_out_param(out_has_width, out_width, &w);
diff --git a/tests/api.c b/tests/api.c
index 54b23a8c..8a7f4b5f 100644
--- a/tests/api.c
+++ b/tests/api.c
@@ -905,6 +905,44 @@ render_cairo_sub (void)
cairo_surface_destroy (surf);
}
+static void
+get_intrinsic_dimensions (void)
+{
+ char *filename = get_test_filename ("example.svg");
+ GError *error = NULL;
+
+ RsvgHandle *handle = rsvg_handle_new_from_file (filename, &error);
+ g_free (filename);
+
+ g_assert (handle != NULL);
+ g_assert (error == NULL);
+
+ gboolean has_width;
+ RsvgLength width;
+ gboolean has_height;
+ RsvgLength height;
+ gboolean has_viewbox;
+ RsvgRectangle viewbox;
+
+ rsvg_handle_get_intrinsic_dimensions (handle, &has_width, &width, &has_height, &height, &has_viewbox,
&viewbox);
+
+ g_assert (has_width);
+ g_assert_cmpfloat (width.length, ==, 100.0);
+ g_assert (width.unit == RSVG_UNIT_PX);
+
+ g_assert (has_height);
+ g_assert_cmpfloat (height.length, ==, 400.0);
+ g_assert (height.unit == RSVG_UNIT_PX);
+
+ g_assert (has_viewbox);
+ g_assert_cmpfloat (viewbox.x, ==, 0.0);
+ g_assert_cmpfloat (viewbox.y, ==, 0.0);
+ g_assert_cmpfloat (viewbox.width, ==, 100.0);
+ g_assert_cmpfloat (viewbox.height, ==, 400.0);
+
+ g_object_unref (handle);
+}
+
static void
get_geometry_for_element (void)
{
@@ -1166,6 +1204,7 @@ main (int argc, char **argv)
g_test_add_func ("/api/detects_cairo_context_in_error", detects_cairo_context_in_error);
g_test_add_func ("/api/can_draw_to_non_image_surface", can_draw_to_non_image_surface);
g_test_add_func ("/api/render_cairo_sub", render_cairo_sub);
+ g_test_add_func ("/api/get_intrinsic_dimensions", get_intrinsic_dimensions);
g_test_add_func ("/api/get_geometry_for_element", get_geometry_for_element);
g_test_add_func ("/api/no_write_before_close", no_write_before_close);
g_test_add_func ("/api/empty_write_close", empty_write_close);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]