[pango/pango2] Run all tests on MacOs
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2] Run all tests on MacOs
- Date: Thu, 16 Jun 2022 01:41:42 +0000 (UTC)
commit 4e3a47be5f3df37b808d6da8f6706b9246e38f4f
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jun 15 21:37:26 2022 -0400
Run all tests on MacOs
tests/test-font.c | 6 -
tests/testmisc.c | 442 ------------------------------------------------------
2 files changed, 448 deletions(-)
---
diff --git a/tests/test-font.c b/tests/test-font.c
index 6bb8be7f..7c3b06db 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -326,12 +326,6 @@ test_roundtrip_small_caps (void)
hb_feature_t features[32];
guint num = 0;
- if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
- {
- g_test_skip ("Small Caps support needs to be added to PangoCoreTextFontMap");
- return;
- }
-
context = pango_context_new ();
desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
diff --git a/tests/testmisc.c b/tests/testmisc.c
index c2158795..18271347 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -173,443 +173,7 @@ test_run_height (void)
PangoLayout *layout;
PangoLineIter *iter;
PangoRectangle logical1, logical2;
-
- if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
- {
- g_test_skip ("This test fails on macOS and needs debugging");
- return;
- }
-
- context = pango_context_new ();
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one", -1);
-
- iter = pango_lines_get_iter (pango_layout_get_lines (layout));
- pango_line_iter_get_run_extents (iter, NULL, &logical1);
- pango_line_iter_free (iter);
-
- pango_layout_set_text (layout, "", -1);
-
- iter = pango_lines_get_iter (pango_layout_get_lines (layout));
- pango_line_iter_get_run_extents (iter, NULL, &logical2);
- pango_line_iter_free (iter);
-
- g_assert_cmpint (logical1.height, ==, logical2.height);
-
- g_object_unref (layout);
- g_object_unref (context);
-}
-
-static void
-test_cursor_height (void)
-{
- PangoContext *context;
- PangoLayout *layout;
- PangoRectangle strong;
-
- context = pango_context_new ();
- layout = pango_layout_new (context);
-
- pango_layout_set_text (layout, "one\ttwo", -1);
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, 0, &strong, NULL);
- g_assert_cmpint (strong.height, >, 0);
-
- pango_layout_set_text (layout, "", -1);
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, 0, &strong, NULL);
- g_assert_cmpint (strong.height, >, 0);
-
- g_object_unref (layout);
- g_object_unref (context);
-}
-
-static void
-test_attr_list_update (void)
-{
- PangoAttribute *weight_attr;
- PangoAttribute *fg_attr;
- PangoAttrList *list;
-
- weight_attr = pango_attr_weight_new (700);
- weight_attr->start_index = 4;
- weight_attr->end_index = 6;
-
- fg_attr = pango_attr_foreground_new (&(PangoColor){0, 0, 65535});
- fg_attr->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
- fg_attr->end_index = PANGO_ATTR_INDEX_TO_TEXT_END;
-
- list = pango_attr_list_new();
- pango_attr_list_insert (list, weight_attr);
- pango_attr_list_insert (list, fg_attr);
-
- g_assert_cmpuint (weight_attr->start_index, ==, 4);
- g_assert_cmpuint (weight_attr->end_index, ==, 6);
- g_assert_cmpuint (fg_attr->start_index, ==, PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING);
- g_assert_cmpuint (fg_attr->end_index, ==, PANGO_ATTR_INDEX_TO_TEXT_END);
-
- // Delete 1 byte at position 2
- pango_attr_list_update (list, 2, 1, 0);
-
- g_assert_cmpuint (weight_attr->start_index, ==, 3);
- g_assert_cmpuint (weight_attr->end_index, ==, 5);
- g_assert_cmpuint (fg_attr->start_index, ==, PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING);
- g_assert_cmpuint (fg_attr->end_index, ==, PANGO_ATTR_INDEX_TO_TEXT_END);
-
- pango_attr_list_unref (list);
-}
-
-static void
-test_version_info (void)
-{
- char *str;
-
- g_assert_null (pango_version_check (1, 0, 0));
- g_assert_null (pango_version_check (PANGO_VERSION_MAJOR, PANGO_VERSION_MINOR, PANGO_VERSION_MICRO));
- g_assert_nonnull (pango_version_check (2, 0, 0));
-
- str = g_strdup_printf ("%d.%d.%d", PANGO_VERSION_MAJOR, PANGO_VERSION_MINOR, PANGO_VERSION_MICRO);
- g_assert_cmpstr (str, ==, pango_version_string ());
- g_free (str);
-}
-
-static void
-test_is_zero_width (void)
-{
- g_assert_true (pango_is_zero_width (0x00ad));
- g_assert_true (pango_is_zero_width (0x034f));
- g_assert_false (pango_is_zero_width ('a'));
- g_assert_false (pango_is_zero_width ('c'));
-
- g_assert_true (pango_is_zero_width (0x2066));
- g_assert_true (pango_is_zero_width (0x2067));
- g_assert_true (pango_is_zero_width (0x2068));
- g_assert_true (pango_is_zero_width (0x2069));
-
- g_assert_true (pango_is_zero_width (0x202a));
- g_assert_true (pango_is_zero_width (0x202b));
- g_assert_true (pango_is_zero_width (0x202c));
- g_assert_true (pango_is_zero_width (0x202d));
- g_assert_true (pango_is_zero_width (0x202e));
-}
-
-static void
-test_gravity_to_rotation (void)
-{
- g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_SOUTH) == 0);
- g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_NORTH) == G_PI);
- g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_EAST) == -G_PI_2);
- g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_WEST) == G_PI_2);
-}
-
-static void
-test_gravity_from_matrix (void)
-{
- PangoMatrix m = PANGO_MATRIX_INIT;
-
- g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_SOUTH);
-
- pango_matrix_rotate (&m, 90);
- g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_WEST);
-
- pango_matrix_rotate (&m, 90);
- g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_NORTH);
-
- pango_matrix_rotate (&m, 90);
- g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_EAST);
-}
-
-static void
-test_gravity_for_script (void)
-{
- struct {
- GUnicodeScript script;
- PangoGravity gravity;
- PangoGravity gravity_natural;
- PangoGravity gravity_line;
- } tests[] = {
- { G_UNICODE_SCRIPT_ARABIC, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_NORTH },
- { G_UNICODE_SCRIPT_BOPOMOFO, PANGO_GRAVITY_EAST, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
- { G_UNICODE_SCRIPT_LATIN, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
- { G_UNICODE_SCRIPT_HANGUL, PANGO_GRAVITY_EAST, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
- { G_UNICODE_SCRIPT_MONGOLIAN, PANGO_GRAVITY_WEST, PANGO_GRAVITY_SOUTH },
- { G_UNICODE_SCRIPT_OGHAM, PANGO_GRAVITY_WEST, PANGO_GRAVITY_NORTH, PANGO_GRAVITY_SOUTH },
- { G_UNICODE_SCRIPT_TIBETAN, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
- };
-
- for (int i = 0; i < G_N_ELEMENTS (tests); i++)
- {
- g_assert_true (pango_gravity_get_for_script (tests[i].script, PANGO_GRAVITY_AUTO,
PANGO_GRAVITY_HINT_STRONG) == tests[i].gravity);
-
- g_assert_true (pango_gravity_get_for_script_and_width (tests[i].script, FALSE, PANGO_GRAVITY_EAST,
PANGO_GRAVITY_HINT_NATURAL) == tests[i].gravity_natural);
- g_assert_true (pango_gravity_get_for_script_and_width (tests[i].script, FALSE, PANGO_GRAVITY_EAST,
PANGO_GRAVITY_HINT_STRONG) == PANGO_GRAVITY_EAST);
- g_assert_true (pango_gravity_get_for_script_and_width (tests[i].script, FALSE, PANGO_GRAVITY_EAST,
PANGO_GRAVITY_HINT_LINE) == tests[i].gravity_line);
- }
-}
-
-static void
-test_fallback_shape (void)
-{
- PangoContext *context;
- const char *text;
- GList *items, *l;
- PangoDirection dir;
-
- context = pango_context_new ();
- dir = pango_context_get_base_dir (context);
-
- text = "Some text to shape ﺄﻧﺍ ﻕﺍﺩﺭ ﻊﻟﻯ ﺄﻜﻟ ﺎﻟﺰﺟﺎﺟ ﻭ ﻩﺫﺍ ﻻ ﻱﺆﻠﻤﻨﻳ";
- items = pango_itemize (context, dir, text, 0, strlen (text), NULL);
- for (l = items; l; l = l->next)
- {
- PangoItem *item = l->data;
- PangoGlyphString *glyphs;
-
- /* We want to test fallback shaping, which happens when we don't have a font */
- g_clear_object (&item->analysis.font);
-
- glyphs = pango_glyph_string_new ();
- pango_shape (text + item->offset, item->length, NULL, 0, &item->analysis, glyphs, PANGO_SHAPE_NONE);
-
- for (int i = 0; i < glyphs->num_glyphs; i++)
- {
- PangoGlyph glyph = glyphs->glyphs[i].glyph;
- g_assert_true (glyph == PANGO_GLYPH_EMPTY || (glyph & PANGO_GLYPH_UNKNOWN_FLAG));
- }
-
- pango_glyph_string_free (glyphs);
- }
-
- g_list_free_full (items, (GDestroyNotify)pango_item_free);
-
- g_object_unref (context);
-}
-
-/* https://bugzilla.gnome.org/show_bug.cgi?id=547303 */
-static void
-test_get_cursor_crash (void)
-{
- PangoContext *context;
- PangoLayout *layout;
- int i;
-
- const char *string = "foo\n\rbar\r\nbaz\n\nqux\n\n..";
-
- context = pango_context_new ();
-
- layout = pango_layout_new (context);
-
- pango_layout_set_text (layout, string, -1);
-
- for (i = 0; string[i]; i++)
- {
- PangoRectangle rectA, rectB;
-
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, i, &rectA, &rectB);
- g_assert_cmpint (rectA.x, ==, rectB.x);
- }
-
- g_object_unref (layout);
- g_object_unref (context);
-}
-
-/* Test that get_cursor returns split cursors in the
- * expected situations. In particular, this was broken
- * at the end of the string here.
- */
-static void
-test_get_cursor (void)
-{
- const char *text = "abאב";
- PangoContext *context;
- PangoLayout *layout;
- PangoRectangle strong, weak;
-
- context = pango_context_new ();
-
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, text, -1);
-
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, 0, &strong, &weak);
- g_assert_cmpint (strong.x, ==, weak.x);
-
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, 1, &strong, &weak);
- g_assert_cmpint (strong.x, ==, weak.x);
-
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, 2, &strong, &weak);
- g_assert_cmpint (strong.x, !=, weak.x);
-
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, 4, &strong, &weak);
- g_assert_cmpint (strong.x, ==, weak.x);
-
- pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, 6, &strong, &weak);
- g_assert_cmpint (strong.x, !=, weak.x);
-
- g_object_unref (layout);
- g_object_unref (context);
-}
-
-static void
-test_index_to_x (void)
-{
- PangoContext *context;
- const char *tests[] = {
- "acually", // soft hyphen
- "acually", // zero-width space
- };
-
- context = pango_context_new ();
-
- for (int i = 0; i < G_N_ELEMENTS (tests); i++)
- {
- PangoLayout *layout;
- const char *text;
- const char *p;
-
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, tests[i], -1);
- text = pango_layout_get_text (layout);
-
- for (p = text; *p; p = g_utf8_next_char (p))
- {
- int index = p - text;
- PangoLine *line;
- int x;
- int index2, trailing;
- gunichar ch;
-
- ch = g_utf8_get_char (p);
-
- pango_lines_index_to_line (pango_layout_get_lines (layout), index, &line, NULL, NULL, NULL);
- g_assert_nonnull (line);
-
- pango_line_index_to_x (line, index, 0, &x);
- pango_line_x_to_index (line, x, &index2, &trailing);
- if (!pango_is_zero_width (ch))
- g_assert_cmpint (index, ==, index2);
- }
-
- g_object_unref (layout);
- }
-
- g_object_unref (context);
-}
-
-static gboolean
-pango_rectangle_contains (const PangoRectangle *r1,
- const PangoRectangle *r2)
-{
- return r2->x >= r1->x &&
- r2->y >= r1->y &&
- r2->x + r2->width <= r1->x + r1->width &&
- r2->y + r2->height <= r1->y + r1->height;
-}
-
-static void
-test_extents (void)
-{
- PangoContext *context;
- struct {
- const char *text;
- int width;
- } tests[] = {
-#if 0
- { "Some long text that has multiple lines that are wrapped by Pango.", 60 },
- { "This paragraph should actually have multiple lines, unlike all the other wannabe äöü paragraph
tests in this ugh test-case. Grow some lines!\n", 188 },
- { "你好 Hello שלום Γειά σας", 60 },
-#endif
- { "line 1
line 2
line 3\nline 4\r\nline 5", -1 }, // various separators
- { "abc😂️def", -1 },
- { "abcאבגdef", -1 },
- { "אבabcב",
- -1 },
- { "aאב12b", -1 },
- { "paragraph", -1 }, // soft hyphens
- };
-
- context = pango_context_new ();
-
- for (int i = 0; i < G_N_ELEMENTS (tests); i++)
- {
- PangoLayout *layout;
- PangoLines *lines;
- PangoLineIter *iter;
- PangoRectangle layout_extents;
- PangoRectangle line_extents;
- PangoRectangle run_extents;
- PangoRectangle cluster_extents;
- PangoRectangle char_extents;
- PangoRectangle pos;
- PangoRectangle strong, weak;
- int index;
-
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, tests[i].text, -1);
- pango_layout_set_width (layout, tests[i].width > 0 ? tests[i].width * PANGO_SCALE : tests[i].width);
-
- lines = pango_layout_get_lines (layout);
- pango_lines_get_extents (lines, NULL, &layout_extents);
-
- iter = pango_lines_get_iter (lines);
-
- do
- {
- PangoLeadingTrim trim = PANGO_LEADING_TRIM_NONE;
- PangoLine *line;
-
- line = pango_line_iter_get_line (iter);
- if (pango_line_is_paragraph_start (line))
- trim |= PANGO_LEADING_TRIM_START;
- if (pango_line_is_paragraph_end (line))
- trim |= PANGO_LEADING_TRIM_END;
-
- pango_line_iter_get_trimmed_line_extents (iter, trim, &line_extents);
-
- pango_line_iter_get_run_extents (iter, NULL, &run_extents);
- pango_line_iter_get_cluster_extents (iter, NULL, &cluster_extents);
- pango_line_iter_get_char_extents (iter, &char_extents);
- index = pango_line_iter_get_index (iter);
- pango_lines_index_to_pos (lines, NULL, index, &pos);
- if (pos.width < 0)
- {
- pos.x += pos.width;
- pos.width = - pos.width;
- }
- pango_lines_get_cursor_pos (lines, NULL, index, &strong, &weak);
-
- g_assert_true (pango_rectangle_contains (&layout_extents, &line_extents));
- g_assert_true (pango_rectangle_contains (&line_extents, &run_extents));
- g_assert_true (pango_rectangle_contains (&run_extents, &cluster_extents));
- g_assert_true (pango_rectangle_contains (&cluster_extents, &char_extents));
-
- g_assert_true (pango_rectangle_contains (&run_extents, &pos));
- g_assert_true (pango_rectangle_contains (&run_extents, &pos));
- g_assert_true (pango_rectangle_contains (&line_extents, &strong));
- g_assert_true (pango_rectangle_contains (&line_extents, &weak));
- }
- while (pango_line_iter_next_char (iter));
-
- pango_line_iter_free (iter);
- g_object_unref (layout);
- }
-
- g_object_unref (context);
-}
-
-static void
-test_empty_line_height (void)
-{
- PangoContext *context;
- PangoLayout *layout;
PangoFontDescription *description;
- PangoRectangle ext1, ext2, ext3;
- cairo_font_options_t *options;
- int hint;
- int size;
-
- if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
- {
- g_test_skip ("This test fails on macOS and needs debugging");
- return;
- }
context = pango_context_new ();
description = pango_font_description_new ();
@@ -813,12 +377,6 @@ test_small_caps_crash (void)
PangoFontDescription *desc;
PangoRectangle ext;
- if (strcmp (G_OBJECT_TYPE_NAME (pango_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
- {
- g_test_skip ("This test needs a fontmap that supports Small-Caps");
- return;
- }
-
context = pango_context_new ();
layout = pango_layout_new (context);
desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]