summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/itemize/one.expected1
-rw-r--r--tests/itemize/two.expected1
-rw-r--r--tests/test-itemize.c24
-rw-r--r--tests/test-layout.c6
4 files changed, 27 insertions, 5 deletions
diff --git a/tests/itemize/one.expected b/tests/itemize/one.expected
index deaa544d..aacf60d1 100644
--- a/tests/itemize/one.expected
+++ b/tests/itemize/one.expected
@@ -1,6 +1,7 @@
<span font="Cantarell 11" fallback="false">a b
c</span>
Items: a b |[0x2028] |c
+Chars: 3(0) |1(3) |1(4)
Font: Cantarell 11 |Cantarell 11 |Cantarell 11
Script: latin |latin |latin
Lang: en-us |en-us |en-us
diff --git a/tests/itemize/two.expected b/tests/itemize/two.expected
index ebe9757c..06518c88 100644
--- a/tests/itemize/two.expected
+++ b/tests/itemize/two.expected
@@ -1,6 +1,7 @@
<span font="Cantarell 11">one <span font_features="tnum=0">tw<u>o</u> <span font_features="dlig=1">two</span> </span>th<b>r</b>ee</span>
Items: one tw |o | two th |r |ee
+Chars: 6(0) |1(6) |7(7) |1(14) |2(15)
Font: Cantarell 11 |Cantarell 11 |Cantarell 11 |Cantarell Bold 11|Cantarell 11
Script: latin |latin |latin |latin |latin
Lang: en-us |en-us |en-us |en-us |en-us
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index 105b453d..00af2256 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -31,6 +31,8 @@
#include <pango/pangocairo.h>
#include "test-common.h"
+#include "pango/pango-item-private.h"
+
static PangoContext *context;
@@ -104,13 +106,22 @@ apply_attributes_to_items (GList *items,
pango_attr_iterator_destroy (iter);
}
+static int
+get_item_char_offset (PangoItem *item)
+{
+ if (item->analysis.flags & PANGO_ANALYSIS_FLAG_HAS_CHAR_OFFSET)
+ return ((PangoItemPrivate *)item)->char_offset;
+
+ return -1;
+}
+
static void
test_file (const gchar *filename, GString *string)
{
gchar *contents;
gsize length;
GError *error = NULL;
- GString *s1, *s2, *s3, *s4, *s5, *s6;
+ GString *s1, *s2, *s3, *s4, *s5, *s6, *s7;
char *test;
char *text;
PangoAttrList *attrs;
@@ -136,6 +147,7 @@ test_file (const gchar *filename, GString *string)
s4 = g_string_new ("Lang: ");
s5 = g_string_new ("Bidi: ");
s6 = g_string_new ("Attrs: ");
+ s7 = g_string_new ("Chars: ");
length = strlen (text);
if (text[length - 1] == '\n')
@@ -168,6 +180,7 @@ test_file (const gchar *filename, GString *string)
g_string_append_printf (s4, "%s%s", sep, pango_language_to_string (item->analysis.language));
g_string_append_printf (s5, "%s%d", sep, item->analysis.level);
g_string_append_printf (s6, "%s", sep);
+ g_string_append_printf (s7, "%s%d(%d)", sep, item->num_chars, get_item_char_offset (item));
for (a = item->analysis.extra_attrs; a; a = a->next)
{
PangoAttribute *attr = a->data;
@@ -189,10 +202,12 @@ test_file (const gchar *filename, GString *string)
g_string_append_printf (s4, "%*s", (int)(m - s4->len), "");
g_string_append_printf (s5, "%*s", (int)(m - s5->len), "");
g_string_append_printf (s6, "%*s", (int)(m - s6->len), "");
+ g_string_append_printf (s7, "%*s", (int)(m - s7->len), "");
}
g_string_append_printf (string, "%s\n", test);
g_string_append_printf (string, "%s\n", s1->str);
+ g_string_append_printf (string, "%s\n", s7->str);
g_string_append_printf (string, "%s\n", s2->str);
g_string_append_printf (string, "%s\n", s3->str);
g_string_append_printf (string, "%s\n", s4->str);
@@ -205,6 +220,7 @@ test_file (const gchar *filename, GString *string)
g_string_free (s4, TRUE);
g_string_free (s5, TRUE);
g_string_free (s6, TRUE);
+ g_string_free (s7, TRUE);
g_list_free_full (items, (GDestroyNotify)pango_item_free);
pango_attr_list_unref (attrs);
@@ -313,13 +329,11 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
- g_test_init (&argc, &argv, NULL);
-
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
pango_context_set_language (context, pango_language_from_string ("en-us"));
/* allow to easily generate expected output for new test cases */
- if (argc > 1)
+ if (argc > 1 && argv[1][0] != '-')
{
GString *string;
@@ -330,6 +344,8 @@ main (int argc, char *argv[])
return 0;
}
+ g_test_init (&argc, &argv, NULL);
+
path = g_test_build_filename (G_TEST_DIST, "itemize", NULL);
dir = g_dir_open (path, 0, &error);
g_free (path);
diff --git a/tests/test-layout.c b/tests/test-layout.c
index f142228b..0139c138 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -127,6 +127,10 @@ dump_lines (PangoLayout *layout, GString *string)
pango_layout_iter_free (iter);
}
+#define ANALYSIS_FLAGS (PANGO_ANALYSIS_FLAG_CENTERED_BASELINE | \
+ PANGO_ANALYSIS_FLAG_IS_ELLIPSIS | \
+ PANGO_ANALYSIS_FLAG_NEED_HYPHEN)
+
static void
dump_runs (PangoLayout *layout, GString *string)
{
@@ -160,7 +164,7 @@ dump_runs (PangoLayout *layout, GString *string)
g_string_append_printf (string, "i=%d, index=%d, chars=%d, level=%d, gravity=%s, flags=%d, font=%s, script=%s, language=%s, '%s'\n",
i, index, item->num_chars, item->analysis.level,
gravity_name (item->analysis.gravity),
- item->analysis.flags,
+ item->analysis.flags & ANALYSIS_FLAGS,
opt_show_font ? font : "OMITTED", /* for some reason, this fails on build.gnome.org, so leave it out */
script_name (item->analysis.script),
pango_language_to_string (item->analysis.language),