[librsvg: 1/5] Move the legacy dimensions tests to tests/api.c
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/5] Move the legacy dimensions tests to tests/api.c
- Date: Fri, 9 Oct 2020 22:50:44 +0000 (UTC)
commit 85af02a849c0571cfe145d961990e430d675c336
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Oct 9 17:03:20 2020 -0500
Move the legacy dimensions tests to tests/api.c
dimensions.c was really only testing the deprecated API for getting
geometry, so we may as well move it to the C API tests.
This is part of https://gitlab.gnome.org/GNOME/librsvg/-/issues/427
tests/Makefile.am | 5 --
tests/api.c | 102 ++++++++++++++++++++++++++++++++++++++
tests/dimensions.c | 143 -----------------------------------------------------
3 files changed, 102 insertions(+), 148 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 13c2d51f..255d0193 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,7 +21,6 @@ test_programs = \
rsvg-test \
crash \
render-crash \
- dimensions \
errors \
infinite-loop
@@ -53,10 +52,6 @@ render_crash_SOURCES = \
render-crash.c \
$(test_utils_common_sources)
-dimensions_SOURCES = \
- dimensions.c \
- $(test_utils_common_sources)
-
loading_SOURCES = \
loading.c \
$(test_utils_common_sources)
diff --git a/tests/api.c b/tests/api.c
index 8d23c6fc..fa31d9a3 100644
--- a/tests/api.c
+++ b/tests/api.c
@@ -1427,6 +1427,103 @@ library_version_constants (void)
g_assert_cmpuint (rsvg_micro_version, ==, LIBRSVG_MICRO_VERSION);
}
+typedef struct
+{
+ const gchar *test_name;
+ const gchar *file_path;
+ const gchar *id;
+ gdouble x;
+ gdouble y;
+ gdouble width;
+ gdouble height;
+ gboolean has_position;
+ gboolean has_dimensions;
+} DimensionsFixtureData;
+
+static void
+test_dimensions (DimensionsFixtureData *fixture)
+{
+ RsvgHandle *handle;
+ RsvgPositionData position;
+ RsvgDimensionData dimension;
+ gchar *target_file;
+ GError *error = NULL;
+
+ target_file = g_build_filename (test_utils_get_test_data_path (),
+ fixture->file_path, NULL);
+ handle = rsvg_handle_new_from_file (target_file, &error);
+ g_free (target_file);
+ g_assert_no_error (error);
+
+ if (fixture->id) {
+ g_assert (rsvg_handle_has_sub (handle, fixture->id));
+ g_assert (rsvg_handle_get_position_sub (handle, &position, fixture->id));
+ g_assert (rsvg_handle_get_dimensions_sub (handle, &dimension, fixture->id));
+
+ g_message ("w=%d h=%d", dimension.width, dimension.height);
+ } else {
+ rsvg_handle_get_dimensions (handle, &dimension);
+ }
+
+ if (fixture->has_position) {
+ g_assert_cmpint (fixture->x, ==, position.x);
+ g_assert_cmpint (fixture->y, ==, position.y);
+ }
+
+ if (fixture->has_dimensions) {
+ g_assert_cmpint (fixture->width, ==, dimension.width);
+ g_assert_cmpint (fixture->height, ==, dimension.height);
+ }
+
+ g_object_unref (handle);
+}
+
+static DimensionsFixtureData dimensions_fixtures[] =
+{
+ {
+ "/dimensions/no viewbox, width and height",
+ "dimensions/bug608102.svg",
+ NULL,
+ 0, 0, 16, 16,
+ FALSE, TRUE
+ },
+ {
+ "/dimensions/100% width and height",
+ "dimensions/bug612951.svg",
+ NULL,
+ 0, 0, 47, 47.14,
+ FALSE, TRUE
+ },
+ {
+ "/dimensions/viewbox only",
+ "dimensions/bug614018.svg",
+ NULL,
+ 0, 0, 972, 546,
+ FALSE, TRUE
+ },
+ {
+ "/dimensions/sub/rect no unit",
+ "dimensions/sub-rect-no-unit.svg",
+ "#rect-no-unit",
+ 0, 0, 44, 45,
+ FALSE, TRUE
+ },
+ {
+ "/dimensions/sub/text_position",
+ "dimensions/347-wrapper.svg",
+ "#LabelA",
+ 80, 48.90, 0, 0,
+ TRUE, FALSE
+ },
+ {
+ "/dimensions/with-viewbox",
+ "dimensions/521-with-viewbox.svg",
+ "#foo",
+ 50.0, 60.0, 70.0, 80.0,
+ TRUE, TRUE
+ },
+};
+
int
main (int argc, char **argv)
{
@@ -1434,6 +1531,8 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
+ test_utils_setup_font_map ();
+
for (i = 0; i < G_N_ELEMENTS (pixbuf_tests); i++) {
g_test_add_data_func (pixbuf_tests[i].test_name, &pixbuf_tests[i], test_pixbuf);
}
@@ -1484,5 +1583,8 @@ main (int argc, char **argv)
g_test_add_func ("/api/library_version_check", library_version_check);
g_test_add_func ("/api/library_version_constants", library_version_constants);
+ for (i = 0; i < G_N_ELEMENTS (dimensions_fixtures); i++)
+ g_test_add_data_func (dimensions_fixtures[i].test_name, &dimensions_fixtures[i],
(void*)test_dimensions);
+
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]