[librsvg: 6/8] tests/dimensions.c: Add infrastructure to test for object positions
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 6/8] tests/dimensions.c: Add infrastructure to test for object positions
- Date: Tue, 25 Sep 2018 23:50:50 +0000 (UTC)
commit 99e1440b595965d2336bef3127eb24553cf45d19
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Sep 25 18:28:06 2018 -0500
tests/dimensions.c: Add infrastructure to test for object positions
tests/dimensions.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 9 deletions(-)
---
diff --git a/tests/dimensions.c b/tests/dimensions.c
index 61c197a5..18cd42ff 100644
--- a/tests/dimensions.c
+++ b/tests/dimensions.c
@@ -5,19 +5,24 @@
#include "librsvg/rsvg.h"
#include "test-utils.h"
-typedef struct _FixtureData
+typedef struct
{
const gchar *test_name;
const gchar *file_path;
const gchar *id;
+ gint x;
+ gint y;
gint width;
gint height;
+ gboolean has_position;
+ gboolean has_dimensions;
} FixtureData;
static void
test_dimensions (FixtureData *fixture)
{
RsvgHandle *handle;
+ RsvgPositionData position;
RsvgDimensionData dimension;
gchar *target_file;
GError *error = NULL;
@@ -31,25 +36,64 @@ test_dimensions (FixtureData *fixture)
if (fixture->id) {
gboolean got_sub;
+ got_sub = rsvg_handle_has_sub (handle, fixture->id);
+ g_assert (got_sub);
+
+ got_sub = rsvg_handle_get_position_sub (handle, &position, fixture->id);
+ g_assert (got_sub);
+
got_sub = rsvg_handle_get_dimensions_sub (handle, &dimension, fixture->id);
g_assert (got_sub);
+
g_message ("w=%d h=%d", dimension.width, dimension.height);
- } else
+ } 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);
+ }
- g_assert_cmpint (fixture->width, ==, dimension.width);
- g_assert_cmpint (fixture->height, ==, dimension.height);
+ if (fixture->has_dimensions) {
+ g_assert_cmpint (fixture->width, ==, dimension.width);
+ g_assert_cmpint (fixture->height, ==, dimension.height);
+ }
g_object_unref (handle);
}
static FixtureData fixtures[] =
{
- {"/dimensions/no viewbox, width and height", "dimensions/bug608102.svg", NULL, 16, 16},
- {"/dimensions/100% width and height", "dimensions/bug612951.svg", NULL, 47, 47},
- {"/dimensions/viewbox only", "dimensions/bug614018.svg", NULL, 972, 546},
- {"/dimensions/sub/rect no unit", "dimensions/sub-rect-no-unit.svg", "#rect-no-unit", 44, 45},
- /* {"/dimensions/sub/rect with transform", "dimensions/bug564527.svg", "#back", 144, 203} */
+ {
+ "/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,
+ 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/rect with transform", "dimensions/bug564527.svg", "#back", 0, 0, 144, 203} */
};
static const gint n_fixtures = G_N_ELEMENTS (fixtures);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]