diff options
author | Julian Sparber <julian@sparber.net> | 2018-11-18 12:13:31 +0200 |
---|---|---|
committer | Julian Sparber <julian@sparber.net> | 2018-11-28 15:17:03 +0100 |
commit | aac1da9be2ccf25918f9bd47f3008a775a2a52cd (patch) | |
tree | 8f758aca55ce8fc0b570603a87112df0003edd51 /tests/api.c | |
parent | 936430cc5ebe69a815fd5de072b3fbd46976ff97 (diff) | |
download | librsvg-aac1da9be2ccf25918f9bd47f3008a775a2a52cd.tar.gz |
handle: add new API to get node geometry
This adds a new API called rsvg_handle_get_geometry_sub(), it returns the
exact position and dimension of a svg node.
Diffstat (limited to 'tests/api.c')
-rw-r--r-- | tests/api.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/api.c b/tests/api.c index 587f06d5..33504e3b 100644 --- a/tests/api.c +++ b/tests/api.c @@ -5,6 +5,7 @@ #include <stdio.h> #include <glib.h> +#include <cairo.h> #define RSVG_DISABLE_DEPRECATION_WARNINGS /* so we can test deprecated API */ #include "librsvg/rsvg.h" @@ -499,8 +500,18 @@ dimensions_and_position (void) g_assert_cmpint (pos.x, ==, EXAMPLE_TWO_X); g_assert_cmpint (pos.y, ==, EXAMPLE_TWO_Y); + /* TODO: test logical_rect */ + cairo_rectangle_t ink_rect; + cairo_rectangle_t logical_rect; + g_assert (rsvg_handle_get_geometry_sub (handle, &ink_rect, &logical_rect, EXAMPLE_TWO_ID)); + g_assert_cmpint (ink_rect.x, ==, EXAMPLE_TWO_X); + g_assert_cmpint (ink_rect.y, ==, EXAMPLE_TWO_Y); + g_assert_cmpint (ink_rect.width, ==, EXAMPLE_TWO_W); + g_assert_cmpint (ink_rect.height, ==, EXAMPLE_TWO_H); + g_assert (!rsvg_handle_get_position_sub (handle, &pos, EXAMPLE_NONEXISTENT_ID)); g_assert (!rsvg_handle_get_dimensions_sub (handle, &dim, EXAMPLE_NONEXISTENT_ID)); + g_assert (!rsvg_handle_get_geometry_sub (handle, &ink_rect, &logical_rect, EXAMPLE_NONEXISTENT_ID)); g_object_unref (handle); } @@ -519,7 +530,6 @@ detects_cairo_context_in_error (void) /* this is wrong; it is to simulate creating a surface and a cairo_t in error */ cairo_surface_t *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, -1, -1); cairo_t *cr = cairo_create (surf); - /* rsvg_handle_render_cairo() should return FALSE when it gets a cr in an error state */ g_assert (!rsvg_handle_render_cairo (handle, cr)); |