[librsvg: 4/11] tests/api.c: Test the case where get_intrinsic_dimensions() reports no viewBox




commit 8bfc6bc410b0cd415ac0fb5f232cf2a5f5681894
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Aug 9 11:29:13 2022 -0500

    tests/api.c: Test the case where get_intrinsic_dimensions() reports no viewBox
    
    After SVG2, where width/height always compute to 100% because their
    initial value is "auto", has_width and has_height will always be
    TRUE.  It is only has_viewbox that needs testing.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/727>

 tests/api.c                       | 27 +++++++++++++++++++++++++++
 tests/fixtures/api/no-viewbox.svg |  1 +
 2 files changed, 28 insertions(+)
---
diff --git a/tests/api.c b/tests/api.c
index 746d052d4..ab91acdab 100644
--- a/tests/api.c
+++ b/tests/api.c
@@ -988,6 +988,32 @@ get_intrinsic_dimensions (void)
     g_object_unref (handle);
 }
 
+static void
+get_intrinsic_dimensions_missing_values (void)
+{
+    char *filename = get_test_filename ("no-viewbox.svg");
+    GError *error = NULL;
+
+    RsvgHandle *handle = rsvg_handle_new_from_file (filename, &error);
+    g_free (filename);
+
+    g_assert_nonnull (handle);
+    g_assert_no_error (error);
+
+    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_true (has_width);
+    g_assert_true (has_height);
+    g_assert_false (has_viewbox);
+    g_object_unref (handle);
+}
+
 static void
 get_intrinsic_size_in_pixels_yes (void)
 {
@@ -1742,6 +1768,7 @@ add_api_tests (void)
     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_intrinsic_dimensions_missing_values", 
get_intrinsic_dimensions_missing_values);
     g_test_add_func ("/api/get_intrinsic_size_in_pixels/yes", get_intrinsic_size_in_pixels_yes);
     g_test_add_func ("/api/get_intrinsic_size_in_pixels/no", get_intrinsic_size_in_pixels_no);
     g_test_add_func ("/api/set_stylesheet", set_stylesheet);
diff --git a/tests/fixtures/api/no-viewbox.svg b/tests/fixtures/api/no-viewbox.svg
new file mode 100644
index 000000000..1a45cb320
--- /dev/null
+++ b/tests/fixtures/api/no-viewbox.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg"; width="100%" height="100%"/>


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