~ubuntu-branches/debian/squeeze/librsvg/squeeze

« back to all changes in this revision

Viewing changes to tests/dimensions.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-05-01 14:23:09 UTC
  • mfrom: (1.1.22 upstream) (25.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100501142309-f0otyldu6gyratt9
Tags: 2.26.3-1
New upstream bugfix release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vim: set ts=4 nowrap ai expandtab sw=4: */
 
2
 
 
3
#include <glib.h>
 
4
#include "rsvg.h"
 
5
#include "test-utils.h"
 
6
 
 
7
typedef struct _FixtureData
 
8
{
 
9
    const gchar *test_name;
 
10
    const gchar *file_path;
 
11
    const gchar *id;
 
12
    gint width;
 
13
    gint height;
 
14
} FixtureData;
 
15
 
 
16
static void
 
17
test_dimensions (FixtureData *fixture)
 
18
{
 
19
    RsvgHandle *handle;
 
20
    RsvgDimensionData dimension;
 
21
    gchar *target_file;
 
22
    GError *error = NULL;
 
23
 
 
24
    target_file = g_build_filename (test_utils_get_test_data_path (),
 
25
                                    fixture->file_path, NULL);
 
26
    handle = rsvg_handle_new_from_file (target_file, &error);
 
27
    g_free (target_file);
 
28
    g_assert_no_error (error);
 
29
 
 
30
    if (fixture->id)
 
31
        rsvg_handle_get_dimensions_sub (handle, &dimension, fixture->id);
 
32
    else
 
33
        rsvg_handle_get_dimensions (handle, &dimension);
 
34
    g_assert_cmpint (fixture->width,  ==, dimension.width);
 
35
    g_assert_cmpint (fixture->height, ==, dimension.height);
 
36
 
 
37
    g_object_unref (handle);
 
38
}
 
39
 
 
40
static FixtureData fixtures[] =
 
41
{
 
42
    {"/dimensions/no viewbox, width and height", "dimensions/bug608102.svg", NULL, 16, 16},
 
43
    {"/dimensions/100% width and height", "dimensions/bug612951.svg", NULL, 45, 45},
 
44
    {"/dimensions/viewbox only", "dimensions/bug614018.svg", NULL, 3, 2},
 
45
    {"/dimensions/sub/rect no unit", "dimensions/sub-rect-no-unit.svg", "#rect-no-unit", 44, 45},
 
46
    {"/dimensions/sub/rect with transform", "dimensions/bug564527.svg", "#back", 144, 203}
 
47
};
 
48
 
 
49
static const gint n_fixtures = G_N_ELEMENTS (fixtures);
 
50
 
 
51
int
 
52
main (int argc, char *argv[])
 
53
{
 
54
    gint i;
 
55
    int result;
 
56
 
 
57
    rsvg_init ();
 
58
    g_test_init (&argc, &argv, NULL);
 
59
 
 
60
    for (i = 0; i < n_fixtures; i++)
 
61
        g_test_add_data_func (fixtures[i].test_name, &fixtures[i], (void*)test_dimensions);
 
62
 
 
63
    result = g_test_run ();
 
64
    rsvg_term ();
 
65
 
 
66
    return result;
 
67
}