summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-11-25 21:17:21 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-11-25 23:02:18 -0500
commit030650c873b6544e82bbcbf6f6ca614c6eaca8b2 (patch)
treeb5dd04e391c172c24ea6a0cd95e022eb306d46ca
parentb96dedd4316f766ca8262a29d9c924c3fb3fce66 (diff)
downloadgtk+-030650c873b6544e82bbcbf6f6ca614c6eaca8b2.tar.gz
testsuite: Add tests for bounding boxes
These are not very interesting, but better safe than sorry.
-rw-r--r--testsuite/gsk/path.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/gsk/path.c b/testsuite/gsk/path.c
index 9ce9766830..a5a7986660 100644
--- a/testsuite/gsk/path.c
+++ b/testsuite/gsk/path.c
@@ -753,6 +753,35 @@ test_serialize (void)
gsk_path_unref (path1);
}
+static void
+test_bounds (void)
+{
+ GskPath *path;
+ GskPathMeasure *measure;
+ guint i, j;
+ graphene_rect_t bounds;
+ float length;
+
+ for (i = 0; i < 10; i++)
+ {
+ path = create_random_path ();
+ measure = gsk_path_measure_new (path);
+ length = gsk_path_measure_get_length (measure);
+ gsk_path_get_bounds (path, &bounds);
+
+ for (j = 0; j < 100; j++)
+ {
+ graphene_point_t p;
+
+ gsk_path_measure_get_point (measure, length / 100.f, &p, NULL);
+ g_assert_true (graphene_rect_contains_point (&bounds, &p));
+ }
+
+ gsk_path_measure_unref (measure);
+ gsk_path_unref (path);
+ }
+}
+
int
main (int argc,
char *argv[])
@@ -768,6 +797,7 @@ main (int argc,
g_test_add_func ("/path/from-string", test_from_string);
g_test_add_func ("/path/from-random-string", test_from_random_string);
g_test_add_func ("/path/serialize", test_serialize);
+ g_test_add_func ("/path/bounds", test_bounds);
return g_test_run ();
}