diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-05-09 01:32:53 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-05-09 01:32:53 +0000 |
commit | 7570667d08c7bb968316a8a40c6e65cee9c4b35b (patch) | |
tree | 582ae0983ef4fb5857e652c4d4ef36d1b210709d /tests | |
parent | 99f4661a4f19802ba122fae09668a0b0e1cb7ca0 (diff) | |
parent | 00e222ab045f0956c16621aaadab4c76248f9bdb (diff) | |
download | pango-1-46.tar.gz |
Merge branch 'pango-1-46' into 'pango-1-46'pango-1-46
[1.46] Cherry pick various upstream fixes
See merge request GNOME/pango!322
Diffstat (limited to 'tests')
-rw-r--r-- | tests/meson.build | 2 | ||||
-rw-r--r-- | tests/test-font.c | 71 | ||||
-rw-r--r-- | tests/test-shape.c | 4 | ||||
-rw-r--r-- | tests/testmisc.c | 14 |
4 files changed, 88 insertions, 3 deletions
diff --git a/tests/meson.build b/tests/meson.build index 6e10e2b7..6f08c240 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -8,6 +8,8 @@ endif if host_system == 'windows' test_cflags += '-DHAVE_WIN32' +elif host_system == 'darwin' + test_cflags += '-DHAVE_CARBON' endif test_env = environment() diff --git a/tests/test-font.c b/tests/test-font.c index 486504f9..88e3cdc9 100644 --- a/tests/test-font.c +++ b/tests/test-font.c @@ -240,7 +240,74 @@ test_enumerate (void) g_object_unref (font); pango_font_description_free (desc); g_free (faces); - g_free (families); + g_free (families); + g_object_unref (context); +} + +static void +test_roundtrip_plain (void) +{ + PangoFontMap *fontmap; + PangoContext *context; + PangoFontDescription *desc, *desc2; + PangoFont *font; + +#ifdef HAVE_CARBON + /* We probably don't have the right fonts */ + g_test_skip ("Skipping font-dependent tests on OS X"); + return; +#endif + + fontmap = pango_cairo_font_map_get_default (); + context = pango_font_map_create_context (fontmap); + + desc = pango_font_description_from_string ("Cantarell 11"); + + font = pango_context_load_font (context, desc); + desc2 = pango_font_describe (font); + + g_assert (pango_font_description_equal (desc2, desc)); + + pango_font_description_free (desc2); + g_object_unref (font); + pango_font_description_free (desc); + g_object_unref (context); +} + +static void +test_roundtrip_emoji (void) +{ + PangoFontMap *fontmap; + PangoContext *context; + PangoFontDescription *desc, *desc2; + PangoFont *font; + +#ifdef HAVE_CARBON + /* We probably don't have the right fonts */ + g_test_skip ("Skipping font-dependent tests on OS X"); + return; +#endif + + fontmap = pango_cairo_font_map_get_default (); + context = pango_font_map_create_context (fontmap); + + /* This is how pango_itemize creates the emoji font desc */ + desc = pango_font_description_from_string ("Cantarell 11"); + pango_font_description_set_family_static (desc, "emoji"); + + font = pango_context_load_font (context, desc); + desc2 = pango_font_describe (font); + + /* We can't expect the family name to match, since we go in with + * a generic family + */ + pango_font_description_unset_fields (desc, PANGO_FONT_MASK_FAMILY); + pango_font_description_unset_fields (desc2, PANGO_FONT_MASK_FAMILY); + g_assert (pango_font_description_equal (desc2, desc)); + + pango_font_description_free (desc2); + g_object_unref (font); + pango_font_description_free (desc); g_object_unref (context); g_object_unref (fontmap); } @@ -261,6 +328,8 @@ main (int argc, char *argv[]) g_test_add_func ("/pango/fontdescription/variation", test_variation); g_test_add_func ("/pango/font/extents", test_extents); g_test_add_func ("/pango/font/enumerate", test_enumerate); + g_test_add_func ("/pango/font/roundtrip/plain", test_roundtrip_plain); + g_test_add_func ("/pango/font/roundtrip/emoji", test_roundtrip_emoji); return g_test_run (); } diff --git a/tests/test-shape.c b/tests/test-shape.c index c2488dbf..feca154e 100644 --- a/tests/test-shape.c +++ b/tests/test-shape.c @@ -185,8 +185,6 @@ test_file (const gchar *filename, GString *string) pango_attr_list_unref (itemize_attrs); pango_attr_list_unref (shape_attrs); - pango_attr_list_unref (attrs); - for (l = items; l; l = l->next) { PangoItem *item = l->data; @@ -281,6 +279,8 @@ test_file (const gchar *filename, GString *string) g_list_free_full (items, (GDestroyNotify)pango_item_free); g_free (contents); g_free (text); + + pango_attr_list_unref (attrs); } static gchar * diff --git a/tests/testmisc.c b/tests/testmisc.c index 2f6c148b..48f60ee9 100644 --- a/tests/testmisc.c +++ b/tests/testmisc.c @@ -54,6 +54,19 @@ test_itemize_empty_crash (void) g_object_unref (context); } +static void +test_itemize_utf8 (void) +{ + PangoContext *context; + GList *result = NULL; + + context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); + result = pango_itemize_with_base_dir (context, PANGO_DIRECTION_LTR, "\xc3\xa1\na", 3, 1, NULL, NULL); + g_assert (result != NULL); + + g_object_unref (context); +} + /* Test that pango_layout_set_text (layout, "short", 200) * does not lead to a crash. (pidgin does this) */ @@ -94,6 +107,7 @@ main (int argc, char *argv[]) g_test_add_func ("/layout/shape-tab-crash", test_shape_tab_crash); g_test_add_func ("/layout/itemize-empty-crash", test_itemize_empty_crash); + g_test_add_func ("/layout/itemize-utf8", test_itemize_utf8); g_test_add_func ("/layout/short-string-crash", test_short_string_crash); g_test_add_func ("/language/emoji-crash", test_language_emoji_crash); |