Add roundtrip tests for rounded rect contours

These should survive roundtrips through the
path parser as well now.
This commit is contained in:
Matthias Clasen 2023-08-27 09:04:17 -04:00
parent 822e988efe
commit 0796c72049

View File

@ -47,12 +47,46 @@ test_roundtrip_circle (void)
gsk_path_unref (path);
}
static void
test_roundtrip_rounded_rect (void)
{
GskRoundedRect rr;
GskPathBuilder *builder;
GskPath *path, *path2;
const GskContour *contour;
char *s;
rr.bounds = GRAPHENE_RECT_INIT (100, 100, 200, 150);
rr.corner[GSK_CORNER_TOP_LEFT] = GRAPHENE_SIZE_INIT (10, 10);
rr.corner[GSK_CORNER_TOP_RIGHT] = GRAPHENE_SIZE_INIT (20, 10);
rr.corner[GSK_CORNER_BOTTOM_RIGHT] = GRAPHENE_SIZE_INIT (20, 0);
rr.corner[GSK_CORNER_BOTTOM_LEFT] = GRAPHENE_SIZE_INIT (0, 0);
builder = gsk_path_builder_new ();
gsk_path_builder_add_rounded_rect (builder, &rr);
path = gsk_path_builder_free_to_path (builder);
contour = gsk_path_get_contour (path, 0);
g_assert_cmpstr (gsk_contour_get_type_name (contour), ==, "GskRoundedRectContour");
s = gsk_path_to_string (path);
path2 = gsk_path_parse (s);
contour = gsk_path_get_contour (path2, 0);
g_assert_cmpstr (gsk_contour_get_type_name (contour), ==, "GskRoundedRectContour");
g_free (s);
gsk_path_unref (path2);
gsk_path_unref (path);
}
int
main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/path/roundtrip/circle", test_roundtrip_circle);
g_test_add_func ("/path/roundtrip/rounded-rect", test_roundtrip_rounded_rect);
return g_test_run ();
}