[pango/more-test-coverage: 6/8] tests: Print layout directions too




commit 0c31ef6a246a893b5106618b2761426a73ca2c56
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jul 5 22:00:21 2021 -0400

    tests: Print layout directions too
    
    Make test-layout print the values returned
    by pango_layout_get_direction too. Update
    expected test results to match.

 tests/layouts/valid-1.expected |  4 ++++
 tests/layouts/valid-2.expected |  4 ++++
 tests/layouts/valid-3.expected |  4 ++++
 tests/layouts/valid-4.expected |  4 ++++
 tests/layouts/valid-5.expected |  4 ++++
 tests/layouts/valid-6.expected |  4 ++++
 tests/test-layout.c            | 20 ++++++++++++++++++++
 7 files changed, 44 insertions(+)
---
diff --git a/tests/layouts/valid-1.expected b/tests/layouts/valid-1.expected
index 292d6f43..cbd07127 100644
--- a/tests/layouts/valid-1.expected
+++ b/tests/layouts/valid-1.expected
@@ -15,6 +15,10 @@ range 22 41
 [22,41]underline=1
 range 41 2147483647
 
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+
 --- lines
 
 i=1, index=0, paragraph-start=1, dir=ltr 'This is a test of the automatic emergency brake!
diff --git a/tests/layouts/valid-2.expected b/tests/layouts/valid-2.expected
index 2efc56fe..4b8e793d 100644
--- a/tests/layouts/valid-2.expected
+++ b/tests/layouts/valid-2.expected
@@ -16,6 +16,10 @@ range 20 25
 [20,25]underline=1
 range 25 2147483647
 
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+
 --- lines
 
 i=1, index=0, paragraph-start=1, dir=ltr 'test the blue drink after dinner
diff --git a/tests/layouts/valid-3.expected b/tests/layouts/valid-3.expected
index 247c61bf..e8a4d095 100644
--- a/tests/layouts/valid-3.expected
+++ b/tests/layouts/valid-3.expected
@@ -10,6 +10,10 @@ lines: 2
 
 range 0 2147483647
 
+--- directions
+
+0 0 0 0 0 0 0 
+
 --- lines
 
 i=1, index=0, paragraph-start=1, dir=ltr 'ABC😀️D
diff --git a/tests/layouts/valid-4.expected b/tests/layouts/valid-4.expected
index 66796cb5..33e01d8b 100644
--- a/tests/layouts/valid-4.expected
+++ b/tests/layouts/valid-4.expected
@@ -11,6 +11,10 @@ width: 192512
 
 range 0 2147483647
 
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+
 --- lines
 
 i=1, index=0, paragraph-start=1, dir=ltr 'This paragraph should ac­tual­'
diff --git a/tests/layouts/valid-5.expected b/tests/layouts/valid-5.expected
index 5c6fa749..4568137f 100644
--- a/tests/layouts/valid-5.expected
+++ b/tests/layouts/valid-5.expected
@@ -15,6 +15,10 @@ range 21 31
 [21,31]font-features=tnum=1
 range 31 2147483647
 
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+
 --- lines
 
 i=1, index=0, paragraph-start=1, dir=ltr 'A test with multiple '
diff --git a/tests/layouts/valid-6.expected b/tests/layouts/valid-6.expected
index b8f90c34..0f81967f 100644
--- a/tests/layouts/valid-6.expected
+++ b/tests/layouts/valid-6.expected
@@ -10,6 +10,10 @@ lines: 2
 
 range 0 2147483647
 
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+
 --- lines
 
 i=1, index=0, paragraph-start=1, dir=ltr ' 0️⃣ Keycap Digit Zero
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 9c5d13a0..70dfc3d1 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -177,6 +177,19 @@ dump_runs (PangoLayout *layout, GString *string)
   pango_layout_iter_free (iter);
 }
 
+static void
+dump_directions (PangoLayout *layout, GString *string)
+{
+  const char *text, *p;
+
+  text = pango_layout_get_text (layout);
+  for (p = text; *p; p = g_utf8_next_char (p))
+    {
+      g_string_append_printf (string, "%d ", pango_layout_get_direction (layout, p - text));
+    }
+  g_string_append (string, "\n");
+}
+
 static void
 parse_params (const gchar        *str,
               gint               *width,
@@ -266,16 +279,23 @@ test_file (const gchar *filename, GString *string)
   pango_layout_set_wrap (layout, wrap);
 
   g_string_append (string, pango_layout_get_text (layout));
+
   g_string_append (string, "\n--- parameters\n\n");
   g_string_append_printf (string, "wrapped: %d\n", pango_layout_is_wrapped (layout));
   g_string_append_printf (string, "ellipsized: %d\n", pango_layout_is_ellipsized (layout));
   g_string_append_printf (string, "lines: %d\n", pango_layout_get_line_count (layout));
   if (width != 0)
     g_string_append_printf (string, "width: %d\n", pango_layout_get_width (layout));
+
   g_string_append (string, "\n--- attributes\n\n");
   print_attr_list (pango_layout_get_attributes (layout), string);
+
+  g_string_append (string, "\n--- directions\n\n");
+  dump_directions (layout, string);
+
   g_string_append (string, "\n--- lines\n\n");
   dump_lines (layout, string);
+
   g_string_append (string, "\n--- runs\n\n");
   dump_runs (layout, string);
 


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