From aac1da9be2ccf25918f9bd47f3008a775a2a52cd Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Sun, 18 Nov 2018 12:13:31 +0200 Subject: 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. --- tests/api.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests/api.c') 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 #include +#include #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)); -- cgit v1.2.1