summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-10-31 11:01:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-10-31 13:42:07 -0400
commit04a58c3ca28732f54fe3f87aa92f61c3e40b8867 (patch)
tree275cdde811a1dfad7a895f83186de80c2af6288b
parentfe1c54b984a92d8b82a3fdb9bc88716f17e81be3 (diff)
downloadpango-04a58c3ca28732f54fe3f87aa92f61c3e40b8867.tar.gz
Add tests for matrix transformations
-rw-r--r--tests/testmisc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 2e14f11e..75c40b0e 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -698,6 +698,44 @@ test_gravity_metrics (void)
g_object_unref (context);
}
+static void
+test_transform_rectangle (void)
+{
+ PangoMatrix matrix = PANGO_MATRIX_INIT;
+ PangoRectangle rect;
+ PangoRectangle rect2;
+
+ rect = rect2 = (PangoRectangle) { 10 * PANGO_SCALE, 20 * PANGO_SCALE, 30 * PANGO_SCALE, 40 * PANGO_SCALE };
+ pango_matrix_transform_rectangle (&matrix, &rect2);
+
+ g_assert_cmpint (rect2.x, ==, rect.x);
+ g_assert_cmpint (rect2.y, ==, rect.y);
+ g_assert_cmpint (rect2.width, ==, rect.width);
+ g_assert_cmpint (rect2.height, ==, rect.height);
+
+ matrix = (PangoMatrix) PANGO_MATRIX_INIT;
+ pango_matrix_translate (&matrix, 10, 20);
+
+ pango_matrix_transform_rectangle (&matrix, &rect2);
+
+ g_assert_cmpint (rect2.x, ==, rect.x + 10 * PANGO_SCALE);
+ g_assert_cmpint (rect2.y, ==, rect.y + 20 * PANGO_SCALE);
+ g_assert_cmpint (rect2.width, ==, rect.width);
+ g_assert_cmpint (rect2.height, ==, rect.height);
+
+ rect2 = rect;
+
+ matrix = (PangoMatrix) PANGO_MATRIX_INIT;
+ pango_matrix_rotate (&matrix, -90);
+
+ pango_matrix_transform_rectangle (&matrix, &rect2);
+
+ g_assert_cmpint (rect2.x, ==, - (rect.y + rect.height));
+ g_assert_cmpint (rect2.y, ==, rect.x);
+ g_assert_cmpint (rect2.width, ==, rect.height);
+ g_assert_cmpint (rect2.height, ==, rect.width);
+}
+
int
main (int argc, char *argv[])
{
@@ -730,6 +768,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/extents", test_extents);
g_test_add_func ("/layout/empty-line-height", test_empty_line_height);
g_test_add_func ("/layout/gravity-metrics", test_gravity_metrics);
+ g_test_add_func ("/matrix/transform-rectangle", test_transform_rectangle);
return g_test_run ();
}