[librsvg] Now test programs can be run from top directory.
- From: Hiroyuki Ikezoe <hiikezoe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Now test programs can be run from top directory.
- Date: Thu, 29 Apr 2010 11:09:11 +0000 (UTC)
commit c3e9ad76dee91ab28afc50d3e563e15b8d3b55f4
Author: Hiroyuki Ikezoe <hiikezoe gnome org>
Date: Thu Apr 29 20:08:23 2010 +0900
Now test programs can be run from top directory.
tests/Makefile.am | 14 +++++++++---
tests/dimensions.c | 17 ++++++++++-----
tests/styles.c | 56 +++++++++++++++++++++++++++------------------------
tests/test-utils.c | 33 ++++++++++++++++++++++++++++++
tests/test-utils.h | 15 +++++++++++++
5 files changed, 99 insertions(+), 36 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 11d15d0..b2daf6d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -5,13 +5,17 @@ TESTS = \
dimensions \
styles
+noinst_LTLIBRARIES = \
+ libtest-utils.la
+
LDADD = $(top_builddir)/librsvg-2.la \
+ $(top_builddir)/tests/libtest-utils.la \
$(top_builddir)/tests/pdiff/libpdiff.la
-INCLUDES = -I$(srcdir) \
- -I$(top_srcdir) \
- -I$(srcdir)/pdiff \
- -DTEST_DATA_DIR="\"$(srcdir)\"" \
+INCLUDES = -I$(srcdir) \
+ -I$(top_srcdir) \
+ -I$(srcdir)/pdiff \
+ -DTEST_DATA_DIR="\"$(srcdir)\"" \
$(LIBRSVG_CFLAGS)
EXTRA_PROGRAMS = $(TESTS)
@@ -21,6 +25,8 @@ CLEANFILES = $(TESTS)
DISTCLEANFILES = rsvg-test.html \
rsvg-test.log
+libtest_utils_la_SOURCES = test-utils.c
+
EXTRA_DIST = \
fixtures/dimensions/bug564527.svg \
fixtures/dimensions/bug614018.svg \
diff --git a/tests/dimensions.c b/tests/dimensions.c
index a6d723f..850bb45 100644
--- a/tests/dimensions.c
+++ b/tests/dimensions.c
@@ -2,6 +2,7 @@
#include <glib.h>
#include "rsvg.h"
+#include "test-utils.h"
typedef struct _FixtureData
{
@@ -17,9 +18,13 @@ test_dimensions (FixtureData *fixture)
{
RsvgHandle *handle;
RsvgDimensionData dimension;
+ gchar *target_file;
GError *error = NULL;
- handle = rsvg_handle_new_from_file (fixture->file_path, &error);
+ 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)
@@ -34,11 +39,11 @@ test_dimensions (FixtureData *fixture)
static FixtureData fixtures[] =
{
- {"/dimensions/no viewbox, width and height", "fixtures/dimensions/bug608102.svg", NULL, 16, 16},
- {"/dimensions/100% width and height", "fixtures/dimensions/bug612951.svg", NULL, 45, 45},
- {"/dimensions/viewbox only", "fixtures/dimensions/bug614018.svg", NULL, 3, 2},
- {"/dimensions/sub/rect no unit", "fixtures/dimensions/sub-rect-no-unit.svg", "#rect-no-unit", 44, 45},
- {"/dimensions/sub/rect with transform", "fixtures/dimensions/bug564527.svg", "#back", 144, 203}
+ {"/dimensions/no viewbox, width and height", "dimensions/bug608102.svg", NULL, 16, 16},
+ {"/dimensions/100% width and height", "dimensions/bug612951.svg", NULL, 45, 45},
+ {"/dimensions/viewbox only", "dimensions/bug614018.svg", NULL, 3, 2},
+ {"/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}
};
static const gint n_fixtures = G_N_ELEMENTS (fixtures);
diff --git a/tests/styles.c b/tests/styles.c
index 7107c6c..11ad5f2 100644
--- a/tests/styles.c
+++ b/tests/styles.c
@@ -6,6 +6,7 @@
#include "rsvg-defs.h"
#include "rsvg-styles.h"
#include "rsvg-paint-server.h"
+#include "test-utils.h"
union Expected {
guint color;
@@ -53,13 +54,16 @@ test_value (FixtureData *fixture)
{
RsvgHandle *handle;
RsvgNode *node;
+ gchar *target_file;
GError *error = NULL;
if (fixture->bug_id)
g_test_bug (fixture->bug_id);
- handle = rsvg_handle_new_from_file (fixture->file_path, &error);
- g_assert_no_error (error);
+ 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);
node = rsvg_defs_lookup (handle->priv->defs, fixture->id);
g_assert (node);
@@ -75,30 +79,30 @@ test_value (FixtureData *fixture)
static const FixtureData fixtures[] =
{
- {"/styles/selectors/type", NULL, "fixtures/styles/order.svg", "#black", "fill", .expected.color = 0x000000},
- {"/styles/selectors/class", NULL, "fixtures/styles/order.svg", "#blue", "fill", .expected.color = 0x0000ff},
- {"/styles/selectors/#id", NULL, "fixtures/styles/order.svg", "#brown", "fill", .expected.color = 0xa52a2a},
- {"/styles/selectors/style", NULL, "fixtures/styles/order.svg", "#gray", "fill", .expected.color = 0x808080},
- {"/styles/selectors/style property prior than class", NULL, "fixtures/styles/order.svg", "#red", "fill", .expected.color = 0xff0000},
- {"/styles/selectors/#id prior than class", NULL, "fixtures/styles/order.svg", "#green", "fill", .expected.color = 0x008000},
- {"/styles/selectors/type#id prior than class", NULL, "fixtures/styles/order.svg", "#pink", "fill", .expected.color = 0xffc0cb},
- {"/styles/selectors/class#id prior than class", NULL, "fixtures/styles/order.svg", "#yellow", "fill", .expected.color = 0xffff00},
- {"/styles/selectors/type.class#id prior than class", NULL, "fixtures/styles/order.svg", "#white", "fill", .expected.color = 0xffffff},
- {"/styles/selectors/#id prior than type", "418823", "fixtures/styles/bug418823.svg", "#bla", "fill", .expected.color = 0x00ff00},
- {"/styles/selectors/comma-separate (fill)", "614643", "fixtures/styles/bug614643.svg", "#red-rect", "fill", .expected.color = 0xff0000},
- {"/styles/selectors/comma-separete (stroke)", "614643", "fixtures/styles/bug614643.svg", "#red-path", "stroke", .expected.color = 0xff0000},
- {"/styles/override presentation attribute", "614704", "fixtures/styles/bug614704.svg", "#blue-rect", "fill", .expected.color = 0x0000ff},
- {"/styles/selectors/2 or more selectors (fill)", "592207", "fixtures/styles/bug592207.svg", "#target", "fill", .expected.color = 0xff0000},
- {"/styles/selectors/2 or more selectors (stroke)", "592207", "fixtures/styles/bug592207.svg", "#target", "stroke", .expected.color = 0x0000ff},
- {"/styles/svg-element-style", "615701", "fixtures/styles/svg-class.svg", "#svg", "fill", .expected.color = 0x0000ff},
- {"/styles/!important", "379629", "fixtures/styles/bug379629.svg", "#base_shadow", "stroke", .expected.color = 0xffc0cb /* pink */},
- {"/styles/!important", "379629", "fixtures/styles/bug379629.svg", "#base_shadow", "stroke-width", .expected.length = {POINTS_LENGTH(5.), 'i'}},
- {"/styles/!important/class", "614606", "fixtures/styles/bug614606.svg", "#path6306", "fill", .expected.color = 0xff0000 /* red */ },
- {"/styles/!important/element", "614606", "fixtures/styles/bug614606.svg", "#path6308", "fill", .expected.color = 0x000000},
- {"/styles/!important/#id prior than class", NULL, "fixtures/styles/important.svg", "#red", "fill", .expected.color = 0xff0000 },
- {"/styles/!important/class prior than type", NULL, "fixtures/styles/important.svg", "#blue", "fill", .expected.color = 0x0000ff },
- {"/styles/!important/presentation attribute is invalid", NULL, "fixtures/styles/important.svg", "#white", "fill", .expected.color = 0xffffff },
- {"/styles/selectors/descendant", "338160", "fixtures/styles/bug338160.svg", "#base_shadow", "stroke-width", .expected.length = {2., '\0'}},
+ {"/styles/selectors/type", NULL, "styles/order.svg", "#black", "fill", .expected.color = 0x000000},
+ {"/styles/selectors/class", NULL, "styles/order.svg", "#blue", "fill", .expected.color = 0x0000ff},
+ {"/styles/selectors/#id", NULL, "styles/order.svg", "#brown", "fill", .expected.color = 0xa52a2a},
+ {"/styles/selectors/style", NULL, "styles/order.svg", "#gray", "fill", .expected.color = 0x808080},
+ {"/styles/selectors/style property prior than class", NULL, "styles/order.svg", "#red", "fill", .expected.color = 0xff0000},
+ {"/styles/selectors/#id prior than class", NULL, "styles/order.svg", "#green", "fill", .expected.color = 0x008000},
+ {"/styles/selectors/type#id prior than class", NULL, "styles/order.svg", "#pink", "fill", .expected.color = 0xffc0cb},
+ {"/styles/selectors/class#id prior than class", NULL, "styles/order.svg", "#yellow", "fill", .expected.color = 0xffff00},
+ {"/styles/selectors/type.class#id prior than class", NULL, "styles/order.svg", "#white", "fill", .expected.color = 0xffffff},
+ {"/styles/selectors/#id prior than type", "418823", "styles/bug418823.svg", "#bla", "fill", .expected.color = 0x00ff00},
+ {"/styles/selectors/comma-separate (fill)", "614643", "styles/bug614643.svg", "#red-rect", "fill", .expected.color = 0xff0000},
+ {"/styles/selectors/comma-separete (stroke)", "614643", "styles/bug614643.svg", "#red-path", "stroke", .expected.color = 0xff0000},
+ {"/styles/override presentation attribute", "614704", "styles/bug614704.svg", "#blue-rect", "fill", .expected.color = 0x0000ff},
+ {"/styles/selectors/2 or more selectors (fill)", "592207", "styles/bug592207.svg", "#target", "fill", .expected.color = 0xff0000},
+ {"/styles/selectors/2 or more selectors (stroke)", "592207", "styles/bug592207.svg", "#target", "stroke", .expected.color = 0x0000ff},
+ {"/styles/svg-element-style", "615701", "styles/svg-class.svg", "#svg", "fill", .expected.color = 0x0000ff},
+ {"/styles/!important", "379629", "styles/bug379629.svg", "#base_shadow", "stroke", .expected.color = 0xffc0cb /* pink */},
+ {"/styles/!important", "379629", "styles/bug379629.svg", "#base_shadow", "stroke-width", .expected.length = {POINTS_LENGTH(5.), 'i'}},
+ {"/styles/!important/class", "614606", "styles/bug614606.svg", "#path6306", "fill", .expected.color = 0xff0000 /* red */ },
+ {"/styles/!important/element", "614606", "styles/bug614606.svg", "#path6308", "fill", .expected.color = 0x000000},
+ {"/styles/!important/#id prior than class", NULL, "styles/important.svg", "#red", "fill", .expected.color = 0xff0000 },
+ {"/styles/!important/class prior than type", NULL, "styles/important.svg", "#blue", "fill", .expected.color = 0x0000ff },
+ {"/styles/!important/presentation attribute is invalid", NULL, "styles/important.svg", "#white", "fill", .expected.color = 0xffffff },
+ {"/styles/selectors/descendant", "338160", "styles/bug338160.svg", "#base_shadow", "stroke-width", .expected.length = {2., '\0'}},
};
static const gint n_fixtures = G_N_ELEMENTS (fixtures);
diff --git a/tests/test-utils.c b/tests/test-utils.c
new file mode 100644
index 0000000..b1055ae
--- /dev/null
+++ b/tests/test-utils.c
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim: set sw=4 sts=4 ts=4 expandtab: */
+
+#include "config.h"
+#include "test-utils.h"
+
+static gchar *data_path = NULL;
+const gchar *
+test_utils_get_test_data_path (void)
+{
+ gchar *prgname;
+ gchar *dirname;
+
+ if (data_path)
+ return data_path;
+
+ prgname = g_get_prgname ();
+ dirname = g_path_get_dirname (prgname);
+
+#ifdef LT_OBJDIR
+ {
+ gchar *another_dirname;
+ another_dirname = g_path_get_dirname (dirname);
+ g_free (dirname);
+ dirname = another_dirname;
+ }
+#endif
+ data_path = g_build_filename (dirname, "fixtures", NULL);
+ g_free (dirname);
+
+ return data_path;
+}
+
diff --git a/tests/test-utils.h b/tests/test-utils.h
new file mode 100644
index 0000000..0b28764
--- /dev/null
+++ b/tests/test-utils.h
@@ -0,0 +1,15 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim: set sw=4 sts=4 ts=4 expandtab: */
+
+#ifndef TEST_UTILS_H
+#define TEST_UTILS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+const gchar *test_utils_get_test_data_path (void);
+
+G_END_DECLS
+
+#endif /* TEST_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]