[pango/baseline-shift] test-layout: Disable fragile checks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/baseline-shift] test-layout: Disable fragile checks
- Date: Mon, 30 Aug 2021 16:44:37 +0000 (UTC)
commit 55b512dcff65bd103c98a8e72a621d3456e7e6c8
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Aug 30 12:40:31 2021 -0400
test-layout: Disable fragile checks
I added these for improved coverage, but they
get in the way, Should probably just move these
kind of checks to another place and leave this
test focused on dumps.
tests/test-layout.c | 175 ----------------------------------------------------
1 file changed, 175 deletions(-)
---
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 0139c138..3320920b 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -388,14 +388,7 @@ test_file (const char *filename, GString *string)
PangoFontDescription *desc;
const PangoFontDescription *desc2;
guint serial;
- PangoRectangle ink_rect, logical_rect;
- PangoRectangle ink_rect1, logical_rect1;
- int width, height;
- int width1, height1;
PangoTabArray *tabs;
- GSList *lines, *l;
- PangoLayoutIter *iter;
- PangoLayoutIter *iter2;
if (context == NULL)
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
@@ -483,174 +476,6 @@ test_file (const char *filename, GString *string)
g_assert_cmpint (pango_layout_get_character_count (layout), ==, g_utf8_strlen (pango_layout_get_text
(layout), -1));
- /* Some checks on extents - we have to be careful here,
- * since we don't want to depend on font metrics.
- */
- pango_layout_get_size (layout, &width, &height);
- pango_layout_get_extents (layout, &ink_rect, &logical_rect);
- g_assert_cmpint (width, ==, logical_rect.width);
- g_assert_cmpint (height, ==, logical_rect.height);
-
- pango_extents_to_pixels (&ink_rect, NULL);
- pango_extents_to_pixels (&logical_rect, NULL);
- pango_layout_get_pixel_extents (layout, &ink_rect1, &logical_rect1);
- pango_layout_get_pixel_size (layout, &width1, &height1);
-
- assert_rectangle_equal (&ink_rect, &ink_rect1);
- assert_rectangle_equal (&logical_rect, &logical_rect1);
- g_assert_cmpint (width1, ==, logical_rect1.width);
- g_assert_cmpint (height1, ==, logical_rect1.height);
-
- lines = pango_layout_get_lines (layout);
- for (l = lines; l; l = l->next)
- {
- PangoLayoutLine *line = l->data;
- int line_width;
- int line_x;
- PangoRectangle line_ink, line_logical;
- PangoRectangle line_ink1, line_logical1;
- gboolean done;
-
- pango_layout_line_get_extents (line, &line_ink, &line_logical);
- line_x = line_logical.x;
- line_width = line_logical.width;
- pango_extents_to_pixels (&line_ink, NULL);
- pango_extents_to_pixels (&line_logical, NULL);
- pango_layout_line_get_pixel_extents (line, &line_ink1, &line_logical1);
-
- /* Not in layout coordinates, so just compare sizes */
- assert_rectangle_size_contained (&line_ink, &ink_rect);
- assert_rectangle_size_contained (&line_logical, &logical_rect);
- assert_rectangle_size_contained (&line_ink1, &ink_rect1);
- assert_rectangle_size_contained (&line_logical1, &logical_rect1);
-
- if (pango_layout_is_ellipsized (layout))
- continue;
-
- /* FIXME: should have a way to position iters */
- iter = pango_layout_get_iter (layout);
- while (pango_layout_iter_get_line_readonly (iter) != line)
- pango_layout_iter_next_line (iter);
-
- done = FALSE;
- while (!done && pango_layout_iter_get_line_readonly (iter) == line)
- {
- int prev_index, index, next_index;
- int x;
- int *ranges;
- int n_ranges;
- gboolean found_range;
- PangoLayoutRun *run;
-
- index = pango_layout_iter_get_index (iter);
- run = pango_layout_iter_get_run_readonly (iter);
-
- if (!pango_layout_iter_next_cluster (iter))
- done = TRUE;
-
- pango_layout_line_index_to_x (line, index, 0, &x);
- g_assert_cmpint (0, <=, x);
- g_assert_cmpint (x, <=, line_width);
-
- if (!run)
- break;
-
- prev_index = run->item->offset;
- next_index = run->item->offset + run->item->length;
-
- {
- PangoGlyphItem *run2 = pango_glyph_item_copy (run);
- g_assert_cmpint (run2->item->offset, ==, run->item->offset);
- g_assert_cmpint (run2->item->length, ==, run->item->length);
- pango_glyph_item_free (run2);
- }
-
- pango_layout_line_get_x_ranges (line, prev_index, next_index, &ranges, &n_ranges);
-
- /* The index is within the run, so the x should be in one of the ranges */
- if (n_ranges > 0)
- {
- found_range = FALSE;
- for (int k = 0; k < n_ranges; k++)
- {
- if (x + line_x >= ranges[2*k] && x + line_x <= ranges[2*k + 1])
- {
- found_range = TRUE;
- break;
- }
- }
- }
-
- g_assert_true (found_range);
- g_free (ranges);
- }
-
- pango_layout_iter_free (iter);
- }
-
- iter = pango_layout_get_iter (layout);
- g_assert_true (pango_layout_iter_get_layout (iter) == layout);
- g_assert_cmpint (pango_layout_iter_get_index (iter), ==, 0);
- pango_layout_iter_get_layout_extents (iter, &ink_rect, &logical_rect);
-
- iter2 = pango_layout_iter_copy (iter);
-
- do
- {
- PangoRectangle line_ink, line_logical;
- int baseline;
- PangoLayoutLine *line;
- PangoLayoutRun *run;
-
- line = pango_layout_iter_get_line (iter);
-
- pango_layout_iter_get_line_extents (iter, &line_ink, &line_logical);
- baseline = pango_layout_iter_get_baseline (iter);
-
- assert_rectangle_contained (&line_ink, &ink_rect);
- assert_rectangle_contained (&line_logical, &logical_rect);
-
- g_assert_cmpint (line_logical.y, <=, baseline);
- g_assert_cmpint (baseline, <=, line_logical.y + line_logical.height);
-
- if (pango_layout_iter_get_index (iter) == pango_layout_iter_get_index (iter2))
- {
- g_assert_cmpint (baseline, ==, pango_layout_get_baseline (layout));
- g_assert_true (line->is_paragraph_start);
- }
-
- if (pango_layout_iter_at_last_line (iter))
- {
- g_assert_cmpint (line->start_index + line->length, <=, strlen (pango_layout_get_text (layout)));
- }
-
- run = pango_layout_iter_get_run (iter);
-
- if (run)
- {
- const char *text;
- int *widths;
- int *widths2;
-
- text = pango_layout_get_text (layout);
-
- widths = g_new (int, run->item->num_chars);
- pango_glyph_item_get_logical_widths (run, text, widths);
-
- widths2 = g_new (int, run->item->num_chars);
- pango_glyph_string_get_logical_widths (run->glyphs, text + run->item->offset, run->item->length,
run->item->analysis.level, widths2);
-
- g_assert_true (memcmp (widths, widths2, sizeof (int) * run->item->num_chars) == 0);
-
- g_free (widths);
- g_free (widths2);
- }
- }
- while (pango_layout_iter_next_line (iter));
-
- pango_layout_iter_free (iter);
- pango_layout_iter_free (iter2);
-
/* generate the dumps */
g_string_append (string, pango_layout_get_text (layout));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]