From 59c5b41f3d0d956fab9cc0ef968f12c538798744 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 9 Aug 2023 23:48:50 -0400 Subject: [PATCH 1/2] Cosmetics --- testsuite/gsk/path-special-cases.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/gsk/path-special-cases.c b/testsuite/gsk/path-special-cases.c index 8fe66ecd9e..24b605e820 100644 --- a/testsuite/gsk/path-special-cases.c +++ b/testsuite/gsk/path-special-cases.c @@ -563,8 +563,8 @@ main (int argc, char *argv[]) g_test_add_func ("/path/foreach", test_foreach); g_test_add_func ("/path/point", test_path_point); g_test_add_func ("/path/segments", test_path_segments); - g_test_add_func ("/measure/bad-in-fill", test_bad_in_fill); - g_test_add_func ("/measure/unclosed-in-fill", test_unclosed_in_fill); + g_test_add_func ("/path/bad-in-fill", test_bad_in_fill); + g_test_add_func ("/path/unclosed-in-fill", test_unclosed_in_fill); return g_test_run (); } From 421365cfc341de027fd463c994259e1f63be60f2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 9 Aug 2023 23:55:08 -0400 Subject: [PATCH 2/2] Add more path point tests --- testsuite/gsk/path-special-cases.c | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/testsuite/gsk/path-special-cases.c b/testsuite/gsk/path-special-cases.c index 24b605e820..01a875ba6b 100644 --- a/testsuite/gsk/path-special-cases.c +++ b/testsuite/gsk/path-special-cases.c @@ -423,21 +423,48 @@ test_foreach (void) } /* Test the basics of the path point api */ +typedef struct _GskRealPathPoint GskRealPathPoint; +struct _GskRealPathPoint +{ + gsize contour; + gsize idx; + float t; +}; + static void test_path_point (void) { GskPath *path; GskPathPoint point; + GskRealPathPoint *rp = (GskRealPathPoint *)&point; gboolean ret; graphene_point_t pos, center; graphene_vec2_t t1, t2, mx; float curvature; - path = gsk_path_parse ("M0,0L100,0L100,100L0,100Z"); + path = gsk_path_parse ("M 0 0 L 100 0 L 100 100 L 0 100 Z"); + + ret = gsk_path_get_start_point (path, &point); + g_assert_true (ret); + + g_assert_true (rp->contour == 0); + g_assert_true (rp->idx == 1); + g_assert_true (rp->t == 0); + + ret = gsk_path_get_end_point (path, &point); + g_assert_true (ret); + + g_assert_true (rp->contour == 0); + g_assert_true (rp->idx == 4); + g_assert_true (rp->t == 1); ret = gsk_path_get_closest_point (path, &GRAPHENE_POINT_INIT (200, 200), INFINITY, &point); g_assert_true (ret); + g_assert_true (rp->contour == 0); + g_assert_true (rp->idx == 2); + g_assert_true (rp->t == 1); + gsk_path_point_get_position (path, &point, &pos); gsk_path_point_get_tangent (path, &point, GSK_PATH_START, &t1); gsk_path_point_get_tangent (path, &point, GSK_PATH_END, &t2); @@ -449,6 +476,13 @@ test_path_point (void) g_assert_true (graphene_vec2_equal (&t2, &mx)); g_assert_true (curvature == 0); + ret = gsk_path_get_closest_point (path, &GRAPHENE_POINT_INIT (100, 50), INFINITY, &point); + g_assert_true (ret); + + g_assert_true (rp->contour == 0); + g_assert_true (rp->idx == 2); + g_assert_true (rp->t == 0.5); + gsk_path_unref (path); }