[pango/line-height-attribute: 30/30] Adapt tests




commit 336dca6530d9dc41b101018d7f4af4a27e70445d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 8 21:56:43 2021 -0400

    Adapt tests
    
    Now that we are using run extents for cursor positions,
    the vertical extents aren't necessarily constant across
    a line anymore. Adapt our assertions.

 tests/test-bidi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/tests/test-bidi.c b/tests/test-bidi.c
index 35f2a39d..7a137518 100644
--- a/tests/test-bidi.c
+++ b/tests/test-bidi.c
@@ -352,6 +352,9 @@ test_move_cursor_para (void)
   int index;
   int trailing;
   const char *text;
+  int line_no;
+  PangoLayoutLine *line;
+  PangoRectangle ext;
 
   layout = pango_layout_new (context);
 
@@ -387,9 +390,14 @@ test_move_cursor_para (void)
           if (index >= strlen (tests[i].text) - 1)
             break;
 
+          pango_layout_index_to_line_x (layout, index, FALSE, &line_no, NULL);
+          line = pango_layout_get_line (layout, line_no);
+          pango_layout_line_get_extents (line, NULL, &ext);
+
           pango_layout_get_cursor_pos (layout, index, &pos, NULL);
-          g_assert_true (pos.y > old_pos.y ||
-                         (pos.y == old_pos.y && pos.x > old_pos.x));
+          // assert that we are either moving to the right
+          // or jumping to the next line
+          g_assert_true (pos.y > ext.y + ext.height || pos.x > old_pos.x);
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]