summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-08-04 18:07:40 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-08-04 18:13:04 -0400
commitd53e5123b6fa797495af4f0cb5ceb69074278d8f (patch)
tree313f55bf6eec8081ac07f417f0da088a01e3f21e
parent1010394a034293dd977e319c413d42b6cf4e9c7e (diff)
downloadpango-fix-split-cursors-at-end.tar.gz
Add a test for pango_layout_get_cursor_posfix-split-cursors-at-end
This checks that we get split cursors in some cases where we expect it. One of the cases was broken until the previous commit.
-rw-r--r--tests/testmisc.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/testmisc.c b/tests/testmisc.c
index c305a168..54566f78 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -329,6 +329,42 @@ test_get_cursor_crash (void)
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_font_map_create_context (pango_cairo_font_map_get_default ());
+
+ layout = pango_layout_new (context);
+ pango_layout_set_text (layout, text, -1);
+
+ pango_layout_get_cursor_pos (layout, 0, &strong, &weak);
+ g_assert_cmpint (strong.x, ==, weak.x);
+
+ pango_layout_get_cursor_pos (layout, 1, &strong, &weak);
+ g_assert_cmpint (strong.x, ==, weak.x);
+
+ pango_layout_get_cursor_pos (layout, 2, &strong, &weak);
+ g_assert_cmpint (strong.x, !=, weak.x);
+
+ pango_layout_get_cursor_pos (layout, 4, &strong, &weak);
+ g_assert_cmpint (strong.x, ==, weak.x);
+
+ pango_layout_get_cursor_pos (layout, 6, &strong, &weak);
+ g_assert_cmpint (strong.x, !=, weak.x);
+
+ g_object_unref (layout);
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[])
{
@@ -349,6 +385,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/fallback-shape", test_fallback_shape);
g_test_add_func ("/language/to-tag", test_language_to_tag);
g_test_add_func ("/bidi/get-cursor-crash", test_get_cursor_crash);
+ g_test_add_func ("/bidi/get-cursor", test_get_cursor);
return g_test_run ();
}