diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-11-03 12:30:21 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-11-04 22:29:03 +0000 |
commit | 73b46b04c724335ad73534cc69955baa2388b861 (patch) | |
tree | f36453a2be34e92b9f8c0a3de43031a164ddec42 | |
parent | 5483069c9897ce03305585cb9a218158fd582caf (diff) | |
download | pango-73b46b04c724335ad73534cc69955baa2388b861.tar.gz |
Add a test for ellipsis shaping
-rw-r--r-- | tests/test-ellipsize.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test-ellipsize.c b/tests/test-ellipsize.c index 20819d0b..a9441d5a 100644 --- a/tests/test-ellipsize.c +++ b/tests/test-ellipsize.c @@ -78,6 +78,34 @@ test_ellipsize_crash (void) g_object_unref (layout); } +/* Check that the width of a fully ellipsized paragraph + * is the same as that of an explicit ellipsis. + */ +static void +test_ellipsize_fully (void) +{ + PangoLayout *layout; + PangoRectangle ink, logical; + PangoRectangle ink2, logical2; + + layout = pango_layout_new (context); + + pango_layout_set_text (layout, "…", -1); + pango_layout_get_extents (layout, &ink, &logical); + + pango_layout_set_text (layout, "ellipsized", -1); + + pango_layout_set_width (layout, 10 * PANGO_SCALE); + pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); + + pango_layout_get_extents (layout, &ink2, &logical2); + + g_assert_cmpint (ink.width, ==, ink2.width); + g_assert_cmpint (logical.width, ==, logical2.width); + + g_object_unref (layout); +} + int main (int argc, char *argv[]) { @@ -90,6 +118,7 @@ main (int argc, char *argv[]) g_test_add_func ("/layout/ellipsize/height", test_ellipsize_height); g_test_add_func ("/layout/ellipsize/crash", test_ellipsize_crash); + g_test_add_func ("/layout/ellipsize/fully", test_ellipsize_fully); return g_test_run (); } |